Exemplo n.º 1
0
        public players Firstplayer()

        {
            var DropDown = driver.FindElement(By.CssSelector(".si-stats-dropdown-container"));
            var action1  = new OpenQA.Selenium.Interactions.Actions(driver);

            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
            action1.MoveToElement(DropDown);
            action1.Perform();
            DropDown = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                       .Until(driver => driver.FindElement(By.CssSelector(".si-stats-dropdown-container")));

            var name = driver.FindElement(By.CssSelector(".si-awdPlyrName")).Text;
            var id   = driver.FindElement(By.CssSelector(".si-statHeadRow")).GetAttribute("data-playerid");

            var redcard = driver.FindElement(By.CssSelector(".si-points span")).Text;

            return(new players
            {
                Name = name,
                Id = id,

                Redcard = redcard
            });
        }
Exemplo n.º 2
0
        public void rightClick(IWebElement elementToRightClick)
        {
            var action = new OpenQA.Selenium.Interactions.Actions(this.driver);

            action.ContextClick(elementToRightClick);
            action.Perform();
        }
Exemplo n.º 3
0
        public IWebElement GetYellowcardData()
        {
            var DropDown = driver.FindElement(By.CssSelector(".si-stats-dropdown-container"));
            var action1  = new OpenQA.Selenium.Interactions.Actions(driver);

            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
            action1.MoveToElement(DropDown);
            action1.Perform();
            DropDown = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                       .Until(driver => driver.FindElement(By.CssSelector(".si-stats-dropdown-container")));


            var players = new List <players>
            {
                Firstplayer()
            };

            var allDivs = driver.FindElements(By.CssSelector(".si-tRow")).Skip(2);

            foreach (var div in allDivs)
            {
                var name       = div.FindElement(By.CssSelector(".si-fullName ")).Text;
                var id         = div.GetAttribute("data-playerid");
                var yellowcard = div.FindElement(By.CssSelector(".si-plyStats-gamplyd ")).Text;

                players.Add(new players {
                    Name = name, Id = id, Yellowcard = yellowcard
                });
                TestContext.Out.WriteLine($"NAME: { name }| Id:{id}|Yellowcard: { yellowcard } ");
            }


            CreateXlSheet(players);
            return(null);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Find a system for a given user and hospital and double click on it
        /// </summary>
        /// <param name="systemText">The system to click on</param>
        /// <param name="username">The user that is performing the action</param>
        /// <param name="hospital">The hospital associated with the system</param>
        private void FindSystemAndDoubleClickOnIt(string systemText, string username, string hospital)
        {
            WebBrowser.Current.Navigate().GoToUrl("crs.crisphealth.org/reports");
            IWebElement currentSystemElement =
                Utility.Utility.GetElement(
                    By.XPath(String.Format("//div[contains(text(), '{0}')]",
                                           systemText.Substring(0, systemText.IndexOf(" ", System.StringComparison.Ordinal)))));

            if (currentSystemElement == null)
            {
                throw new Exception(String.Format("Cannot find system element on page for {0}",
                                                  systemText));
            }
            try
            {
                currentSystemElement.Click();
            }
            catch (ElementNotVisibleException e)
            {
                throw new Exception(String.Format("Element is not visible by browser for {0} {1} {2}",
                                                  username, systemText, hospital));
            }
            Actions action = new Actions(WebBrowser.Current);

            action.DoubleClick(currentSystemElement);
            action.Perform();
        }
        /// <summary>
        /// Scrolls down a web page using the page down key.
        /// </summary>
        /// <param name="timesToScroll">An abstract quantification of how much to scroll</param>
        public static void ScrollPage(this RemoteWebDriver remoteWebDriver, int timesToScroll)
        {
            // Webdriver examples had scrolling by executing Javascript. That approach seemed troublesome because the
            // browser is scrolling in a way very different from how it would with a real user, so we don't do it.
            // Page down seemed to be the best compromise in terms of it behaving like a real user scrolling, and it
            // working reliably across browsers.
            // Use the page down key.

            var userAction = new OpenQA.Selenium.Interactions.Actions(remoteWebDriver);

            userAction.SendKeys(Keys.PageDown);

            for (int i = 0; i < timesToScroll; i++)
            {
                ScenarioEventSourceProvider.EventLog.ScrollEvent();
                if (remoteWebDriver.ToString().ToLower().Contains("firefoxdriver"))
                {
                    // Send the commands to the body element for Firefox.
                    IWebElement body = remoteWebDriver.FindElementByTagName("body");
                    body.SendKeys(Keys.PageDown);
                }
                else
                {
                    userAction.Perform();
                }
                Thread.Sleep(1000);
            }
        }
Exemplo n.º 6
0
        public void UploadSuccessful()
        {
            string url = "http://testpan.chinacloudapp.cn/";
            string userName = "******";
            string Password = "******";
            var driver = Helper.DMLogin(url, userName, Password);
            driver.FindElement(By.CssSelector("a.menuBtn_upload > span.icontxt")).Click();
            driver.FindElement(By.CssSelector("a.a-pw_add > span.icontxt")).Click();

            //使用autoit操作windows窗口
            Helper.AutoitHelper(@"D:\temp\test.xls");
            Thread.Sleep(2000);
            driver.FindElement(By.Id("upload-done")).Click();
            Thread.Sleep(2000);

            //找到上传的文件,删除,测试通过
            var ExistTableElement =
                driver.FindElement(
                    By.CssSelector("table[data-name='test.xls']"));

            var mouseOverAction = new OpenQA.Selenium.Interactions.Actions(driver);
            mouseOverAction.MoveToElement(ExistTableElement);
            mouseOverAction.Perform();
            ExistTableElement.FindElement(By.CssSelector("div.menuBtn > a.delete")).Click();
            driver.FindElement(By.XPath("//*[@id='window_delete']/div/div[3]/table/tbody/tr/td[1]/a")).Click();

            driver.Quit();
        }
 public static void DoubleClickOnObject(IControl control)
 {
     ScrollIntoView(control.WebElement);
     OpenQA.Selenium.Interactions.Actions actions = new OpenQA.Selenium.Interactions.Actions(BrowserUtilities.WebDriver);
     actions.DoubleClick(control.WebElement);
     actions.Perform();
 }
Exemplo n.º 8
0
        public void NewHomepage()
        {
            string handle = driver.CurrentWindowHandle;

            var comment2 = driver.FindElement(By.XPath("/html/body/div[1]/div/myapp/section[3]/div/div/div/div[1]/div/section[1]/div/div/div[1]/div/a"));

            //string title = driver.FindElement(By.XPath("/html/body/div[1]/div/myapp/section[3]/div/div/div/div[1]/div/section[1]/div/div/div[1]/div/h2")).Text;


            var action1 = new OpenQA.Selenium.Interactions.Actions(driver);

            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
            action1.MoveToElement(comment2);
            action1.Perform();

            comment2 = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                       .Until(driver => driver.FindElement(By.XPath("/html/body/div[1]/div/myapp/section[3]/div/div/div/div[1]/div/section[1]/div/div/div[1]/div/a")));
            Thread.Sleep(2000);
            comment2.Click();
            Thread.Sleep(2000);

            driver.SwitchTo().Window(handle);


            /*if (title.Contains("Cricket News"))
             *
             * {
             *  driver.FindElement(By.XPath("/html/body/div[1]/div/myapp/section[3]/div/div/div/div[1]/div/section[1]/div/div/div[1]/div/a")).Click();
             *
             * }*/
        }
        public void SubmitUserDetails()
        {
            Wait.Until(ElementExtensions.ElementToBeClickable(Objects.Pages.CreateBuyerUser.CreateUser));
            var element = Driver.FindElement(Objects.Pages.CreateBuyerUser.CreateUser);
            var actions = new OpenQA.Selenium.Interactions.Actions(Driver);

            actions.MoveToElement(element);
            actions.Perform();
            element.Click();
        }
Exemplo n.º 10
0
        private void Statsdropdownscroll()
        {
            var DropDown = driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section/div/div/div/div/section/component/div[2]/div/div/div/div/div[2]/div[1]/div[1]/div/div/div[2]/ul/li[13]"));
            var action1  = new OpenQA.Selenium.Interactions.Actions(driver);

            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
            action1.MoveToElement(DropDown);
            action1.Perform();
            DropDown = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                       .Until(driver => driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section/div/div/div/div/section/component/div[2]/div/div/div/div/div[2]/div[1]/div[1]/div/div/div[2]/ul/li[13]")));
        }
Exemplo n.º 11
0
        private void Teamtracker()
        {
            var tracker = driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section[7]/div/div/div/div/section/component/div[1]/h2"));
            var action1 = new OpenQA.Selenium.Interactions.Actions(driver);

            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
            action1.MoveToElement(tracker);
            action1.Perform();
            tracker = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                      .Until(driver => driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section[7]/div/div/div/div/section/component/div[1]/h2")));
        }
Exemplo n.º 12
0
        private void TeamsLogo()
        {
            var Logo    = driver.FindElement(By.CssSelector(".teams-logo"));
            var action1 = new OpenQA.Selenium.Interactions.Actions(driver);

            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
            action1.MoveToElement(Logo);
            action1.Perform();
            Logo = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                   .Until(driver => driver.FindElement(By.CssSelector(".teams-logo")));
        }
Exemplo n.º 13
0
        public void ClickManageBookingsLink()
        {
            Waits.WaitForElement(Driver, ManageBookingsLink);
            Thread.Sleep(2000);
            OpenQA.Selenium.Interactions.Actions act = new OpenQA.Selenium.Interactions.Actions(Driver);
            act.MoveToElement(ManageBookingsLink);
            act.Perform();

            ManageBookingsLink.Click();
            ManageBookingsLink.Click();
        }
Exemplo n.º 14
0
        private void Statsdropdown()
        {
            var DropDown = driver.FindElement(By.CssSelector(".si-stats-dropdown-container"));
            var action1  = new OpenQA.Selenium.Interactions.Actions(driver);

            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
            action1.MoveToElement(DropDown);
            action1.Perform();
            DropDown = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                       .Until(driver => driver.FindElement(By.CssSelector(".si-stats-dropdown-container")));
            DropDown.Click();
        }
Exemplo n.º 15
0
        private void LoadMoreButton()
        {
            WebDriverWait wait   = new WebDriverWait(driver, new TimeSpan(0, 1, 0));
            var           button = wait.Until(driver => driver.FindElement(By.CssSelector(".si-stats-more-btn")));

            while (button.GetCssValue("display") != "none")
            {
                var action = new OpenQA.Selenium.Interactions.Actions(driver);
                action.MoveToElement(button);
                action.Perform();
                button.Click();
                button = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                         .Until(driver => driver.FindElement(By.CssSelector(".si-stats-more-btn")));
            }
        }
Exemplo n.º 16
0
        private void clubstats()
        {
            //driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section/div/div/div/div/section/component/div[2]/div/div/div/div/div[2]/div[1]/div[1]/div/div/div[1]")).Click();


            var clubstat = driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section/div/div/div/div/section/component/div[2]/div/div/div/div/div[2]/div[1]/div[1]/div/div/div[1]"));
            var action1  = new OpenQA.Selenium.Interactions.Actions(driver);

            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
            action1.MoveToElement(clubstat);
            action1.Perform();
            clubstat = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                       .Until(driver => driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section/div/div/div/div/section/component/div[2]/div/div/div/div/div[2]/div[1]/div[1]/div/div/div[1]")));
            clubstat.Click();
        }
Exemplo n.º 17
0
 /// <summary>
 /// Drags the <paramref name="sourceElement"/> to the <paramref name="destinationElement"/>.
 /// </summary>
 /// <param name="sourceElement"></param>
 /// <param name="destinationElement"></param>
 public void DragAndDrop(By sourceElement, By destinationElement)
 {
     try
     {
         var builder = new OpenQA.Selenium.Interactions.Actions(driver);
         builder.ClickAndHold(driver.FindElement(sourceElement));
         builder.MoveToElement(driver.FindElement(destinationElement));
         builder.Release();
         builder.Build();
         builder.Perform();
     }
     catch (Exception e)
     {
         MyLogger.Log.Error($"Failed to drag source element: {sourceElement} to destination element: {destinationElement}. {e.Message}");
         throw e;
     }
 }
Exemplo n.º 18
0
        public void GetTeamRedcardData()
        {
            var clubstat = driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section/div/div/div/div/section/component/div[2]/div/div/div/div/div[2]/div[1]/div[1]/div/div/div[1]"));
            var action1  = new OpenQA.Selenium.Interactions.Actions(driver);

            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
            action1.MoveToElement(clubstat);
            action1.Perform();
            clubstat = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                       .Until(driver => driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section/div/div/div/div/section/component/div[2]/div/div/div/div/div[2]/div[1]/div[1]/div/div/div[1]")));
            Thread.Sleep(1000);

            string actualvalue = driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section/div/div/div/div/section/component/div[2]/div/div/div/div/div[3]/div[1]/div")).Text;

            if (actualvalue == "Data unavailable.")
            {
                Assert.IsTrue(actualvalue.Contains("Data unavailable."), actualvalue + " Data unavailable.");
            }
            else
            {
                var Team = new List <Team>();

                Thread.Sleep(2000);
                var allDivs = driver.FindElements(By.CssSelector(".si-team-data"));
                foreach (var div in allDivs)
                {
                    var teamname = div.FindElement(By.CssSelector(".si-fullName ")).Text;

                    var teamRedcard = div.FindElement(By.CssSelector(".si-goals")).Text;

                    Team.Add(new Team {
                        TeamName = teamname, TeamRedcard = teamRedcard
                    });
                    TestContext.Out.WriteLine($"TeamName: { teamname }| TeamRedcard: { teamRedcard } ");
                }
                CreateXlSheet(Team);
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// Verifies that user can see every system, hospital and casemix folder for his permissions
        /// Also verifies that if casemix = false in CSV file, user cannot see a casemix folder
        /// </summary>
        /// <param name="username">The user to check for</param>
        private void CheckEachPermittedSystemAndHospitalAndCasemixFolderForUser(string username)
        {
            string systemText = "";

            GetListOfUserPermittedCasemixFolders(username);

            // Check each permitted system and hospital folder for the user
            if (_userPermittedHospitalFolders != null)
            {
                foreach (string hospital in _userPermittedHospitalFolders)
                {
                    // Check system element (if the hospital for this system is statewide) and double click on it if this is the first time we've checked for it.
                    // Collapsing the system folder is needed to see the hospital folders
                    if (_hospitalAndStatewideMapping != null && (_hospitalAndStatewideMapping[hospital] == "1"))
                    {
                        // Update systemText for the current hospital
                        if (AllDistinctHospitalAndSystemFolders != null)
                        {
                            systemText = AllDistinctHospitalAndSystemFolders[hospital];
                            FindSystemAndDoubleClickOnIt(systemText, username, hospital);
                        }
                    }

                    // Verify that hospital is present if it is a statewide hospital
                    if (_hospitalAndStatewideMapping != null && _hospitalAndStatewideMapping[hospital] == "1")
                    {
                        Assert.IsTrue(
                            Utility.Utility.IsElementPresent(
                                By.XPath(String.Format("//div[contains(., '{0}')]", hospital))));
                        Console.WriteLine("{0} can see {1} with hospital {2}", username, systemText,
                                          hospital);
                    }

                    // Verify that casemix folder is present if user has casemix permission
                    if (_userPermittedHospitalAndCasemixMapping != null)
                    {
                        if (_userPermittedHospitalAndCasemixMapping[hospital])
                        {
                            IWebElement hospitalElement =
                                Utility.Utility.GetElement(By.XPath(String.Format("//div[contains(., '{0}')]", hospital)));
                            Actions action = new Actions(WebBrowser.Current);
                            action.DoubleClick(hospitalElement);
                            action.Perform();
                            Assert.IsTrue(
                                Utility.Utility.IsElementPresent(
                                    By.XPath(String.Format("//div[contains(., '{0}')]", "Patient Level Detail"))));
                            Console.WriteLine(String.Format("{0} can see patient level detail for system {1} and hospital {2}", username, systemText, hospital));
                        }
                        else
                        {
                            IWebElement hospitalElement =
                                Utility.Utility.GetElement(By.XPath(String.Format("//div[contains(., '{0}')]", hospital)));
                            Actions action = new Actions(WebBrowser.Current);
                            action.DoubleClick(hospitalElement);
                            action.Perform();
                            Assert.IsFalse(
                                Utility.Utility.IsElementPresent(
                                    By.XPath(String.Format("//div[contains(., '{0}')]", "Patient Level Detail"))));
                            Console.WriteLine(String.Format("{0} cannot see patient level detail for system {1} and hospital {2}", username, systemText, hospital));
                        }
                    }
                }
            }
        }
Exemplo n.º 20
0
        public void upLoad()
        {
            //Thread.Sleep(3000);
            //driver.FindElement(By.CssSelector("a.menuBtn_upload")).Click();
            //driver.FindElement(By.CssSelector("#a-pw_add > span.icontxt")).Click();
            //Thread.Sleep(1000);
            //Thread x = new Thread(new ThreadStart(Upload_File));
            //x.Start();
            //Thread.Sleep(1000);
            //driver.FindElement(By.CssSelector("table.table-pw_next a.btn_upload")).Click();
            //Thread.Sleep(2000);

            ////如果进度元素不是显示100,那么继续上传
            //if (driver.FindElement(By.XPath("//[@id='efaf3e61-c983-4dc3-9622-436d51d5a88c']/sapn[3]")).Text.Contains()!=100)
            //{

            //}

            //下载
            Thread.Sleep(1000);
            //driver.FindElement(By.XPath("//ul[@id='commandList']/li/table/tbody/tr/td/div/span")).Click();
            ////driver.FindElement(By.CssSelector("div.fileCommand span.MixiTai_Checkbox")).Click();
            ////driver.FindElement(By.XPath("//ul[@id='commandList']/li[1]/table/tbody/tr/td[2]/div/table/tbody/tr[2]/td/span")).Click();
            //driver.FindElement(By.XPath("(//input[@value='Open'])")).Click();
            ////driver.FindElement(By.CssSelector("a.option_Open")).Click();
            //Thread.Sleep(100);
            ////driver.FindElement(By.CssSelector("div.fileCommand span.MixiTai_Checkbox")).Click();
            //driver.FindElement(By.XPath("//ul[@id='commandList']/li/table/tbody/tr/td/div/span")).Click();
            //Thread.Sleep(100);
            //driver.FindElement(By.XPath("(//input[@value='Open'])")).Click();
            ////driver.FindElement(By.CssSelector("a.menuBtn_return > span.icontxt")).Click();
            //driver.FindElement(By.XPath("//ul[@id='commandList']/li[2]/table/tbody/tr/td[2]/div/table/tbody/tr[2]/td/span")).Click();
            //driver.FindElement(By.XPath("(//input[@value='Open'])[2]")).Click();
            //driver.FindElement(By.CssSelector("a.menuBtn_downLoad > span.icontxt")).Click();
            //driver.FindElement(By.CssSelector("a.menuBtn_downLoad > span.icontxt")).Click();
            //driver.FindElement(By.XPath("//div[@id='FilesView']/div[3]/a/span")).Click();

            var openFolderTableElement =
                driver.FindElement(
                    By.CssSelector("table[data-name='Angkor']"));

            var mouseOverAction = new OpenQA.Selenium.Interactions.Actions(driver);
            mouseOverAction.MoveToElement(openFolderTableElement);
            //notice: Actions必须要执行perform
            mouseOverAction.Perform();
            openFolderTableElement.FindElement(By.CssSelector("div.menuBtn a.option_Open")).Click();

            Thread.Sleep(1000);
            var openFileTableElement =
                driver.FindElement(
                    By.CssSelector("table[data-name='AppCertKitArmSetup.exe']"));

            var mouseOverAction1 = new OpenQA.Selenium.Interactions.Actions(driver);
            mouseOverAction1.MoveToElement(openFileTableElement);
            //notice: Actions必须要执行perform
            mouseOverAction1.Perform();
            openFileTableElement.FindElement(By.CssSelector("div.menuBtn a.option_Open")).Click();
            //driver.FindElement(By.LinkText("Download File")).Click();
            driver.FindElement(By.CssSelector("a.menuBtn_downLoad")).Click();
            Thread.Sleep(1000);
            var auto = new AutoItX3();
            //auto.Send("{BROWSE}");
            //Thread.Sleep(1000);

            //auto.Send("{TAB}");
            //auto.Send("{TAB}");
            //auto.Send("{ENTER}");
            Thread.Sleep(1000);
            const string widowTitle = "[Class:#32770]";
            auto.ControlFocus(widowTitle, "Choose Download Folder:", "[CLASS:Edit; INSTANCE:1]");
            auto.Send(@"C:");
            auto.ControlClick(widowTitle, "Choose Download Folder", "[CLASS:Button; INSTANCE:1]");
            auto.Send("{ENTER}");
            Thread.Sleep(5000);

            //driver.FindElement(By.LinkText("退出")).Click();
        }
Exemplo n.º 21
0
        public void Searchplayers()
        {
            driver.Navigate().GoToUrl("https://www.indiansuperleague.com/");

            driver.Manage().Window.Maximize();

            string ReadExcel;
            int    rctn = 6;

            excel.Application x1app       = new excel.Application();
            excel.Workbook    x1workbook  = x1app.Workbooks.Open(@"D:\Automation\ISL\Player search file\player_data1.xlsx");
            excel.Worksheet   x1worksheet = x1workbook.Sheets[1];


            excel.Range x1range = x1worksheet.UsedRange;



            for (int i = 6; i <= rctn; i++)
            {
                for (int j = 2; j <= 78; j++)
                {
                    ReadExcel = x1range.Cells[i][j].Text.ToString();
                    driver.FindElement(By.XPath("/html/body/div[1]/header/section/div/div/div[3]/div/div[2]/div[1]/ul/li[5]/a")).Click();

                    var search = driver.FindElement(By.XPath("/html/body/div[1]/div[1]/div/div[2]/input"));
                    search.SendKeys(ReadExcel);
                    search.SendKeys(Keys.Enter);

                    var visible = driver.FindElement(By.XPath("//*[@id='cookiebtn']"));

                    if (visible.Displayed)
                    {
                        //Assert.AreEqual(true, visible.Displayed);
                        visible.Click();
                    }


                    /* FunctionalLibrary.TryFindElement(driver, "//*[@id='cookiebtn']" );
                     *
                     *   var visible =  IsElementVisible(element);
                     *   if (visible)
                     *   {
                     *   element.Click();
                     *   }*/



                    var viewprofile = driver.FindElement(By.Id("player-list"));
                    var action1     = new OpenQA.Selenium.Interactions.Actions(driver);
                    ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
                    action1.MoveToElement(viewprofile);
                    action1.Perform();
                    viewprofile = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                                  .Until(driver => driver.FindElement(By.Id("player-list")));

                    var playername = driver.FindElement(By.CssSelector(".article-name")).Text;

                    if (ReadExcel.Equals(playername))
                    {
                        Debug.WriteLine(playername, "player name is correct");
                    }
                    else
                    {
                        Debug.WriteLine(playername, "player name is incorrect");
                    }
                    var webe = driver.FindElement(By.Id("player-list"));


                    var href = webe.FindElement(By.CssSelector("a")).GetAttribute("href");


                    // WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromMinutes(1));

                    //wait.Until(ExpectedConditions.UrlContains(href));

                    if (href == null)
                    {
                        Debug.WriteLine(playername, "Player not clikable");
                    }
                    else
                    {
                        Debug.WriteLine(playername, "player is clikable");
                        webe.Click();
                        Thread.Sleep(1000);
                        var playerdetail = driver.FindElement(By.CssSelector(".si-player-name")).Text;
                        if (playername.Equals(playerdetail))
                        {
                            Debug.WriteLine("Redirected on detail page");
                        }
                    }



                    Thread.Sleep(2000);

                    /*var viewprofilesroll = driver.FindElement(By.CssSelector(".article-content"));
                     * var action2 = new OpenQA.Selenium.Interactions.Actions(driver);
                     * ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
                     * action2.MoveToElement(viewprofilesroll);
                     * action2.Perform();
                     * viewprofilesroll = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                     *         .Until(driver => driver.FindElement(By.CssSelector(".article-content")));*/
                    //svar viewprofilesroll = driver.FindElement(By.CssSelector(".si-player-name"));
                }
            }
        }
Exemplo n.º 22
0
        public IWebElement GetLeagueTrackerData()
        {
            var Leaguetrackerdata = driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section[7]/div/div/div/div/section/component/div"));
            var action1           = new OpenQA.Selenium.Interactions.Actions(driver);

            ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
            action1.MoveToElement(Leaguetrackerdata);
            Thread.Sleep(2000);
            action1.Perform();
            Leaguetrackerdata = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                                .Until(driver => driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section[7]/div/div/div/div/section/component/div")));


            excel.Application x1app       = new excel.Application();
            excel.Workbook    x1workbook  = x1app.Workbooks.Open(@"C:\Users\aditya.bhosle\source\repos\Data\Data\NewFolder1\Excel_stats.xlsx", ReadOnly: false);
            excel.Worksheet   xlWorkSheet = (excel.Worksheet)x1workbook.Worksheets[1];

            excel.Range x1range = xlWorkSheet.UsedRange;



            driver.FindElements(By.CssSelector(".si-league-tracker"));

            var goals1             = driver.FindElement(By.CssSelector(".si-fkt-bOne .si-fkt-sctn-number")).Text;
            var minspergoal        = driver.FindElement(By.CssSelector(".si-fkt-bTwo-col1 .si-fkt-sctn-number")).Text;
            var avggoalsmatch      = driver.FindElement(By.CssSelector(".si-fkt-bTwo-col2 .si-fkt-sctn-number")).Text;
            var goalconversionrate = driver.FindElement(By.CssSelector(".si-fkt-bTwo-col3 .si-fkt-sctn-number")).Text;
            var passes             = driver.FindElement(By.CssSelector(".si-fkt-bTwo-col4 .si-fkt-sctn-number")).Text;
            var avgpasspergame     = driver.FindElement(By.CssSelector(".si-fkt-bThree .si-fkt-sctn-number")).Text;
            var redcards           = driver.FindElement(By.CssSelector(".si-fkt-bSeven .si-fkt-sctn-number")).Text;
            var yellowcards        = driver.FindElement(By.CssSelector(".si-fkt-bEight .si-fkt-sctn-number")).Text;
            var tackles            = driver.FindElement(By.CssSelector(".si-fkt-bEight.AEight .si-fkt-sctn-number")).Text;
            var fouls         = driver.FindElement(By.CssSelector(".si-fkt-bNine .si-fkt-sctn-number")).Text;
            var interceptions = driver.FindElement(By.CssSelector(".si-fkt-bTen .si-fkt-sctn-number")).Text;
            var blocks        = driver.FindElement(By.CssSelector(".si-fkt-bEleven .si-fkt-sctn-number")).Text;
            var cleansheet    = driver.FindElement(By.CssSelector(".si-fkt-bTwelve .si-fkt-sctn-number")).Text;

            var leaguetracker = new Leaguetracker
            {
                Goals1             = goals1,
                MinsPerGoal        = minspergoal,
                AvgGoalsMatch      = avggoalsmatch,
                GoalConversionRate = goalconversionrate,
                Passes             = passes,
                AvgPassPerGame     = avgpasspergame,
                RedCards           = redcards,
                YellowCards        = yellowcards,
                Tackles            = tackles,
                Fouls         = fouls,
                Interceptions = interceptions,
                Blocks        = blocks,
                CleanSheets   = cleansheet
            };

            TestContext.Out.WriteLine($"Goals1: { goals1 } | MinsPerGoal: { minspergoal } | AvgGoalsMatch: { avggoalsmatch } | AvgGoalsMatch: { avggoalsmatch }" +
                                      $"| GoalConversionRate: { goalconversionrate } | Passes: { passes } | AvgPassPerGame: { avgpasspergame } | RedCards: { redcards }" +
                                      $"| YellowCards: { yellowcards } | Tackles: { tackles } | Fouls: { fouls } | Interceptions: { interceptions }" +
                                      $" | Blocks: { blocks } | CleanSheets: { cleansheet }");



            CreateXlSheet(leaguetracker);
            return(null);
        }
Exemplo n.º 23
0
        public void ElementAction(objIdentifier oI, Enum action, string ActionValue)
        {
            string      StepStartTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff");
            IWebElement WebElement    = getElement(oI);

            switch (action.ToString())
            {
            case "Click":
                WebElement.Click();
                spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + " Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff"));
                break;

            case "jsClick":
                JS = (IJavaScriptExecutor)driver;
                JS.ExecuteScript("document." + oI.jsId + oI.IdValue + "\").click();");
                spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + " Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff"));
                break;

            case "jsSetText":
                JS = (IJavaScriptExecutor)driver;
                JS.ExecuteScript("document." + oI.jsId + oI.IdValue + "\").style.value=\"" + ActionValue + "\";");
                spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + " Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff"));
                break;

            case "Clear":
                WebElement.Clear();
                spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + "Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff"));
                break;

            case "NavigateToElement":
                OpenQA.Selenium.Interactions.Actions actions = new OpenQA.Selenium.Interactions.Actions(driver);
                actions.MoveToElement(WebElement);
                actions.Perform();
                spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + "Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff"));
                break;

            case "VerifyText":
                if (WebElement.Text.Equals(ActionValue))
                {
                    spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + "Expected Text = " + ActionValue + " Actual Text = " + WebElement.Text + " Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff") + "text verification passed");
                }
                else
                {
                    ProjectDetails["CurrentTestResult"] = "Fail";
                    spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + "Expected Text = " + ActionValue + " Actual Text = " + WebElement.Text + " Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff") + "text verification failed");
                }
                break;

            case "InnerHtml":
                if (WebElement.Text.Equals(ActionValue))
                {
                    spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + "Expected Text = " + ActionValue + " Actual Text = " + WebElement.Text + " Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff") + "text verification passed");
                }
                else
                {
                    ProjectDetails["CurrentTestResult"] = "Fail";
                    spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + "Expected Text = " + ActionValue + " Actual Text = " + WebElement.Text + " Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff") + "text verification failed");
                }
                break;

            case "VerifyContains":
                if (WebElement.Text.Contains(ActionValue))
                {
                    spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + "Expected Text = " + ActionValue + " Actual Text = " + WebElement.Text + " Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff") + "contains verification passed");
                }
                else
                {
                    ProjectDetails["CurrentTestResult"] = "Fail";
                    spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + "Expected Text = " + ActionValue + " Actual Text = " + WebElement.Text + " Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff") + "contains verification failed");
                }
                break;

            case "VerifyTitle":
                if (driver.Title.Equals(ActionValue))
                {
                    spReporter.WriteLine("Waiting Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + "Expected Text = " + ActionValue + " Actual Text = " + driver.Title + " Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff") + "title verification passed");
                }
                else
                {
                    ProjectDetails["CurrentTestResult"] = "Fail";
                    spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + "Expected Text = " + ActionValue + " Actual Text = " + driver.Title + " Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff") + "title verification failed");
                }
                break;

            case "SendKeys":
                WebElement.SendKeys(ActionValue);
                spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + " Value is " + ActionValue + " Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff"));
                break;

            case "ClearAndSendKeys":
                WebElement.Clear();
                WebElement.SendKeys(ActionValue);
                spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + " Value is " + ActionValue + " Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff"));
                break;

            case "ClearAndSendKeysAndTab":
                WebElement.Clear();
                WebElement.SendKeys(ActionValue);
                WebElement.SendKeys(Keys.Tab);
                spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + " Value is " + ActionValue + " Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff"));
                break;

            case "SelectByIndex":
                new SelectElement(WebElement).SelectByIndex(Int32.Parse(ActionValue));
                System.Threading.Thread.Sleep(250);
                spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + "Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff") + " Action was SelectByText(" + ActionValue + ")");
                break;

            case "SelectByText":
                new SelectElement(WebElement).SelectByText(ActionValue);
                System.Threading.Thread.Sleep(250);
                spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + "Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff") + " Action was SelectByText(" + ActionValue + ")");
                break;

            case "SelectByValue":
                new SelectElement(WebElement).SelectByValue(ActionValue);
                System.Threading.Thread.Sleep(250);
                spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + "Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff") + " Action was SelectByText(" + ActionValue + ")");
                break;

            case "SetProperty":
                JS = (IJavaScriptExecutor)driver;
                JS.ExecuteScript("document." + oI.jsId + oI.IdValue + "\").style." + oI.IdProperty + "=\"" + oI.IdPropertyValue + "\";");
                spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + " Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff"));
                break;

            case "Check":
                try
                {
                    if (!WebElement.GetAttribute("checked").Equals("true"))
                    {
                        WebElement.Click();
                    }
                }
                catch { }
                spReporter.WriteLine("Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff") + " Action was Checked(" + ActionValue + ")");
                break;

            case "Displayed":
                int synccounter = 0;
                while (!WebElement.Displayed)
                {
                    System.Threading.Thread.Sleep(100);
                    synccounter = synccounter + 1;
                    if (synccounter > 5)
                    {
                        ActionValue = "Not Displayed";
                        break;
                    }
                }
                spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + "Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff") + " Action was CheckDisplayed(" + ActionValue + ")");
                break;

            case "WaitResolveStaleElementAndClick":
                for (int i = 0; i < 60; i++)
                {
                    try
                    {
                        WebElement.Click();
                        i = 60;
                    }
                    catch (Exception e)
                    {
                        if (e.Message.Contains("stale element"))
                        {
                            System.Threading.Thread.Sleep(100);
                            WebElement = getElement(oI);
                        }
                        else
                        {
                            i = 60;
                        }
                    }
                }
                spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + " Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff"));
                break;

            case "Uncheck":
                WebElement.Click();
                spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + "Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff") + " Action was Uncheck(" + ActionValue + ")");
                break;

            case "ClickHandleModal":
                WebElement.Click();
                spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + "Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff") + " Action was ClickHandleModal() ");
                break;

            case "Submit":
                WebElement.Submit();
                spReporter.WriteLine("Object was " + oI.IdName.ToString() + " Action was " + action.ToString() + "Started at : " + StepStartTime + " Completed at: " + DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss:fff") + " Action was ClickHandleModal() ");
                break;

            default:
                break;
            }
        }
Exemplo n.º 24
0
 public void Perform() => actions.Perform();
Exemplo n.º 25
0
        public void Searchplayers()
        {
            driver.Navigate().GoToUrl("https://www.indiansuperleague.com/");

            driver.Manage().Window.Maximize();

            string ReadExcel;
            int    rctn = 6;

            excel.Application x1app       = new excel.Application();
            excel.Workbook    x1workbook  = x1app.Workbooks.Open(@"D:\Automation\ISL\Player search file\player_data1.xlsx");
            excel.Worksheet   x1worksheet = x1workbook.Sheets[1];


            excel.Range x1range = x1worksheet.UsedRange;



            for (int i = 6; i <= rctn; i++)
            {
                for (int j = 2; j <= 78; j++)
                {
                    ReadExcel = x1range.Cells[i][j].Text.ToString();
                    driver.FindElement(By.XPath("/html/body/div[1]/header/section/div/div/div[3]/div/div[2]/div[1]/ul/li[5]/a")).Click();

                    var search = driver.FindElement(By.XPath("/html/body/div[1]/div[1]/div/div[2]/input"));
                    search.SendKeys(ReadExcel);
                    search.SendKeys(Keys.Enter);

                    var visible = driver.FindElement(By.XPath("//*[@id='cookiebtn']"));

                    if (visible.Displayed)
                    {
                        //Assert.AreEqual(true, visible.Displayed);
                        visible.Click();
                    }
                    var record = driver.FindElement(By.XPath("/html/body/div[1]/section/myapp/section/div/div/div/div/section/component/div/div/div[2]/div[2]/span")).Text;
                    if (record.StartsWith("0 records for"))
                    {
                        Console.WriteLine(ReadExcel, "player is deleted");
                    }

                    /* FunctionalLibrary.TryFindElement(driver, "//*[@id='cookiebtn']" );
                     *
                     *   var visible =  IsElementVisible(element);
                     *   if (visible)
                     *   {
                     *   element.Click();
                     *   }*/


                    else if (IsElementPresent(By.Id("player-list")))
                    {
                        var viewprofile = driver.FindElement(By.Id("player-list"));
                        var action1     = new OpenQA.Selenium.Interactions.Actions(driver);
                        ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(document.body.scrollHeight, 0)");
                        action1.MoveToElement(viewprofile);
                        action1.Perform();
                        viewprofile = new WebDriverWait(driver, new TimeSpan(0, 1, 0))
                                      .Until(driver => driver.FindElement(By.Id("player-list")));

                        var playername = driver.FindElement(By.CssSelector(".article-name")).Text;

                        if (ReadExcel.Equals(playername))
                        {
                            Console.WriteLine(playername, "player name is correct");
                        }
                        else
                        {
                            Console.WriteLine(playername, "player name is incorrect");
                        }
                        var webe = driver.FindElement(By.Id("player-list"));


                        var href = webe.FindElement(By.CssSelector("a")).GetAttribute("href");



                        if (href == null)
                        {
                            Console.WriteLine(playername, "Player not clikable");
                        }
                        else
                        {
                            Debug.WriteLine(playername, "player is clikable");
                            webe.Click();
                            Thread.Sleep(1000);
                            var playerdetail = driver.FindElement(By.CssSelector(".si-player-name")).Text;
                            if (playername.Equals(playerdetail))
                            {
                                Console.WriteLine(playername, "Redirected on detail page");
                            }
                            var error = driver.FindElement(By.CssSelector(".txt-1")).Text;
                            if (error.Equals("Oops!Page Not Found."))
                            {
                                String currenturl = driver.Url;
                                Console.WriteLine(currenturl, "404 page");
                            }
                        }
                    }


                    else
                    {
                        String currenturl = driver.Url;
                        Console.WriteLine(currenturl, "player profile isn't available");
                    }
                }
            }
        }