public void ThenIWillLogout() { var driver = (IWebDriver)context["webdriver"]; inbox.LogOut(driver); Assert.IsTrue(logIn.VerifyLogOut(driver)); DriverFactory.CloseDriver(); }
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); }
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(); }
public void TearDown() { DriverFactory.CloseDriver(); }
public void CleanBrowserSessions() { DriverFactory.CloseDriver(); }
public void TearDown() { DriverFactory.CloseDriver(); NodeFactory.Instance.CloseNodeServer(); }
public void cleanUp() { Console.WriteLine("Stop run test...."); DriverFactory.CloseDriver(); }