コード例 #1
0
        public void ThenIWillLogout()
        {
            var driver = (IWebDriver)context["webdriver"];

            inbox.LogOut(driver);
            Assert.IsTrue(logIn.VerifyLogOut(driver));
            DriverFactory.CloseDriver();
        }
コード例 #2
0
        public void SearchGoogleTest()
        {
            _driver = DriverFactory.CreateDriver();
            //Navigate to google
            _driver.Navigate().GoToUrl("http://www.google.com");

            //do a search
            ////type search text
            IWebElement searchTextbox = _driver.FindElement(By.XPath("//div[@id='gs_lc0']/input[@type='text']"));

            int counter = 0;

            while (counter < 1000 && !searchTextbox.Displayed)
            {
                //Do Nothing
            }

            searchTextbox.SendKeys("cat");

            ////click search
            IWebElement searchButton = _driver.FindElement(By.XPath("//div[@class='lsbb kpbb']//button[@type='submit' and @value='Search']"));

            searchButton.Click();

            //wait for search results to populate

            //click first search result
            IWebElement firstLink = null;

            int      waitTime = 3;
            DateTime start    = DateTime.Now;

            while (firstLink == null && DateTime.Now.Subtract(start).TotalSeconds < waitTime)
            {
                try
                {
                    firstLink = _driver.FindElement(By.XPath("//div[@id='rso']//a"));
                }
                catch
                {
                    Console.WriteLine("Couldnt find it.");
                    //Do Nothing, Look for element again in loop
                }
            }

            if (firstLink == null)
            {
                throw new Exception("No hyperlink could be found");
            }

            firstLink.Click();

            //Print title of first search

            System.Console.WriteLine(_driver.Title);

            DriverFactory.CloseDriver(_driver);
        }
コード例 #3
0
        public void Event()
        {
            ChromeOptions op = new ChromeOptions();

            op.EnableMobileEmulation("Apple iPhone 4");
            //DriverFactory.Instance.DriverOption = op;
            DriverFactory.StartDriver(DriverType.Chrome, true);
            IWebDriver driver = DriverFactory.WebDriver;

            driver.Url = "https://www.whatismybrowser.com/";
            IWebElement el = driver.FindElement(By.XPath("//*[@id='holder']//*[@class='detection-primary content-block']"));

            WebKeywords.Instance.GetScreenShot();
            Utilities.Instance.GetWebElementBaseImage(el, formatType: System.Drawing.Imaging.ImageFormat.Jpeg);
            driver.Dispose();
            DriverFactory.CloseDriver();
        }
コード例 #4
0
 public void TearDown()
 {
     DriverFactory.CloseDriver();
 }
コード例 #5
0
 public void CleanBrowserSessions()
 {
     DriverFactory.CloseDriver();
 }
コード例 #6
0
 public void TearDown()
 {
     DriverFactory.CloseDriver();
     NodeFactory.Instance.CloseNodeServer();
 }
コード例 #7
0
 public void cleanUp()
 {
     Console.WriteLine("Stop run test....");
     DriverFactory.CloseDriver();
 }