/// <summary> /// Sends Selenium to the Posts page in the admin wordpress site /// </summary> /// <param name="driver"></param> public static void GoToPosts(IWebDriver driver) { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); String[] creds = Formatting.getCreds(); driver.Navigate().GoToUrl("https://zed.exioite.com/wp-login.php"); wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.XPath("//input[@id='user_login']"))); IWebElement username = driver.FindElement(By.XPath("//input[@id='user_login']")); IWebElement password = driver.FindElement(By.XPath("//input[@id='user_pass']")); Thread.Sleep(500); username.Clear(); username.SendKeys(creds[0]); Thread.Sleep(500); password.Clear(); password.SendKeys(creds[1]); Thread.Sleep(500); driver.FindElement(By.XPath("//input[@id='wp-submit']")).Click(); wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.XPath("//div [@class = 'wp-menu-name' and contains(text(),'Posts')]"))); driver.FindElement(By.XPath("//div [@class = 'wp-menu-name' and contains(text(),'Posts')]")).Click(); wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.XPath("//a[contains(text(),'Add New')]"))); }
//This function search the hide record video and verify the same public void verifyingNoresultFound(IWebDriver driver, IWait <IWebDriver> iWait, string videoname) { appURL = cf.readingXMLFile("WebPortal", "Login", "startURL", "Config.xml"); driver.Navigate().GoToUrl(appURL); driver.Manage().Window.Maximize(); //wait till jquery gets completed uf.isJqueryActive(driver); iWait.Until(ExpectedConditions.ElementExists(By.Id(or.readingXMLFile("VideoLandingPage", "SearchTB", "TVWebPortalOR.xml")))); //search the required video IWebElement SearchTextField = driver.FindElement(By.Id(or.readingXMLFile("VideoLandingPage", "SearchTB", "TVWebPortalOR.xml"))); SearchTextField.SendKeys(videoname); iWait.Until(ExpectedConditions.ElementToBeClickable(By.Id(or.readingXMLFile("VideoLandingPage", "SearchIcon", "TVWebPortalOR.xml")))); //Click on searchIcon IWebElement SearchIcon = driver.FindElement(By.Id(or.readingXMLFile("VideoLandingPage", "SearchIcon", "TVWebPortalOR.xml"))); SearchIcon.Click(); uf.isJqueryActive(driver); iWait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.CssSelector("div > span#result > p"))); //verifying the video with no result found String NoResultFound = driver.FindElement(By.CssSelector("div > span#result > p")).Text; Thread.Sleep(1000); Assert.AreEqual("No result found", NoResultFound); }
public IList <IWebElement> getWebElements(IWebDriver driver, By by, int timeout = 30) { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeout)); wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(by)); return(driver.FindElements(by)); }
public LeavePageObject() { PageFactory.InitElements(PropertiesCollection.driver, this); PropertiesCollection.wait = new WebDriverWait(PropertiesCollection.driver, new TimeSpan(0, 0, 10)); PropertiesCollection.wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.Name("txtBegin"))); }
public IWebElement WaitUntilDisplayed() { Wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(Locator)); Wait.Until(drv => drv.FindElement(Locator).Displayed&& drv.FindElement(Locator).Enabled); Element = Browser.GetDriver().FindElement(Locator); return(Element); }
protected SeleniqBaseElement ReInit() { var elements = Driver.Wait().Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(RootBy)); Root = elements[_elIndex]; return(this); }
private bool isAt() { try { wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.TagName("body"))); if (Logo.Displayed) { StopTimer(); if (TestCaseGenerator.CurrentTestCase.StepExist("Verify Trip Search is Displayed on Home Page")) { if (TestCaseGenerator.CurrentTestCase.IsResponseTimeRequired) { TestCaseGenerator.CurrentTestCase.SetResponseTime(timer2 - timer1); TestCaseGenerator.CurrentTestCase.MarkStepAsDone("Verify Trip Search is Displayed on Home Page"); } } Console.WriteLine("Concur (" + portalenvironment + ") Home Page Took: " + LoadTime + " to load using " + SSOProvider); Console.WriteLine("</br>"); return(true); } } catch (Exception ex) { if (TestCaseGenerator.CurrentTestCase.StepExist("Verify Trip Search is Displayed on Home Page")) { TestCaseGenerator.CurrentTestCase.MarkStepAsFailed("Verify Trip Search is Displayed on Home Page", ex.Message); } throw (ex); } return(false); }
public void verifyRecentSubscriptionDetails() { log.Info("inside verifyRecentSubscriptionDetails " + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber()); IList <IWebElement> subscriptionList; Thread.Sleep(2000); iWait.Until(ExpectedConditions.ElementExists((OR.GetElement("AccountManagement", "grdSubscriptionDetails", "TVAdminPortalOR.xml")))); IWebElement tblSubscriptionListing = driver.FindElement((OR.GetElement("AccountManagement", "grdSubscriptionDetails", "TVAdminPortalOR.xml"))); iWait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.TagName("tr"))); subscriptionList = (IList <IWebElement>)tblSubscriptionListing.FindElements(By.TagName("tr")); foreach (IWebElement currentrow in subscriptionList) { if (currentrow.GetAttribute("class").Equals("GridRowStyle") || currentrow.GetAttribute("class").Equals("AltGridStyle")) { string columnChannelName = driver.FindElements(By.TagName("td"))[1].FindElement(By.TagName("li")).Text.Trim(); string ChannelName = cf.readingXMLFile("Admin", "Channel Management", "channelname", "TestCopy.xml"); Assert.AreEqual(ChannelName, columnChannelName); break; } } }
public void TextPage_PageLoads() { driver.Navigate().GoToUrl(baseURL + "/Text"); var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.CssSelector("html body puppet-client"))); }
public void AccountLogin() { log.Info("inside AccountLogin " + " at line:" + new StackTrace(true).GetFrame(0).GetFileLineNumber()); iWait.Until(ExpectedConditions.ElementExists((OR.GetElement("NonIETMemberRegistration", "LoginLink", "TVWebPortalOR.xml")))); IWebElement loginLink = driver.FindElement((OR.GetElement("NonIETMemberRegistration", "LoginLink", "TVWebPortalOR.xml"))); executor.ExecuteScript("arguments[0].click();", loginLink); string userName = cf.readingXMLFile("Admin", "Account Management", "UserEmailAddress", "TestCopy.xml"); //string userName = "******"; string userPassword = cf.readingXMLFile("Admin", "Account Management", "Password", "TestCopy.xml"); log.Info("username " + userName); log.Info("Password " + userPassword); iWait.Until(ExpectedConditions.ElementIsVisible(OR.GetElement("VideoRequestByUser", "UserNameTB", "TVWebPortalOR.xml"))); driver.FindElement(OR.GetElement("VideoRequestByUser", "UserName", "TVWebPortalOR.xml")).SendKeys(userName); Thread.Sleep(1000); driver.FindElement(OR.GetElement("VideoRequestByUser", "Password", "TVWebPortalOR.xml")).SendKeys(userPassword); iWait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(OR.GetElement("VideoRequestByUser", "Login", "TVWebPortalOR.xml"))); driver.FindElement(OR.GetElement("VideoRequestByUser", "Login", "TVWebPortalOR.xml")).Click(); Thread.Sleep(2000); ClickTermsandConditionsAcceptButton(); }
public static void verifyImagePresent() { try { logger.Log(Status.Info, "Current URL : " + driver.Url); //check big images var bigImgSelector = "#carousel-photos > div.carousel-inner > div"; wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.CssSelector(bigImgSelector))); var box1 = driver.FindElements(By.CssSelector(bigImgSelector)); foreach (var item in box1) { string imglink = item.FindElement(By.TagName("img")).GetAttribute("data-original"); checkImageExist(imglink); } //check small images var smallImgSelector = "#carousel-photos > ol > li"; wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.CssSelector(smallImgSelector))); var box2 = driver.FindElements(By.CssSelector(smallImgSelector)); foreach (var item in box2) { string imglink = item.FindElement(By.TagName("img")).GetAttribute("data-original"); checkImageExist(imglink); } } catch (Exception e) { logger.Log(Status.Fail, e.ToString()); } }
public void OpenDocument(MS2013documents doc) { switch (doc) { case MS2013documents.QA_ReadinessChecklist_v4: try { wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.TagName("a"))); SecondTopic.Click(); // this try catch is to expand the topic dropdown if you are on the km workspace // if you're not in the km workspace program wil continue. } catch (Exception e) { } wait.Timeout = TimeSpan.FromSeconds(5); wait.Until(e => WordDoc.Displayed); AutoITDriver.currentWorkingDocTitle = WordDoc.Text; WordDoc.Click(); break; case MS2013documents.SampleAVMetrics: try { wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.TagName("a"))); SecondTopic.Click(); // this try catch is to expand the topic dropdown if you are on the km workspace // if you're not in the km workspace program wil continue. } catch (Exception e) { } wait.Timeout = TimeSpan.FromSeconds(5); wait.Until(e => PowerPointDoc.Displayed); AutoITDriver.currentWorkingDocTitle = PowerPointDoc.Text; PowerPointDoc.Click(); break; case MS2013documents.ITMetrics: try { wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.TagName("a"))); SecondTopic.Click(); // this try catch is to expand the topic dropdown if you are on the km workspace // if you're not in the km workspace program wil continue. } catch (Exception e) { } wait.Timeout = TimeSpan.FromSeconds(5); wait.Until(e => ExcelDoc.Displayed); AutoITDriver.currentWorkingDocTitle = ExcelDoc.Text; ExcelDoc.Click(); break; default: break; } }
public IList <IWebElement> GetMessagesFrom(string email) { fluentWait = FluentWait.GetFluentWait(this.driver); IList <IWebElement> tempFoundMessages; List <IWebElement> listOfFoundMessages = new List <IWebElement>(); try { tempFoundMessages = fluentWait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(this.allMessages)); foreach (IWebElement message in tempFoundMessages) { if (message.GetAttribute("email") == email) { listOfFoundMessages.Add(message); } } return(listOfFoundMessages); } catch (OpenQA.Selenium.WebDriverTimeoutException e) { Console.WriteLine(e.Message + $"\nMessages from {email} not found"); return(listOfFoundMessages); } }
public void SetUp(string locator) { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); //можно вернуть элементы IWebElement element = wait.Until(d => d.FindElement(By.CssSelector(locator))); IList <IWebElement> element2 = wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.CssSelector(locator))); }
internal void AddProductsToCart(int count) { storeMainPage.Open(); var productQuantity = 0; while (productQuantity < count) { storeMainPage.Open(); storeMainPage.MostPopularProduct.Click(); wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.CssSelector("button[name=add_cart_product]"))); productPage = new ProductPage(driver); if (IsElementPresent(driver, By.CssSelector(("select[name*=options]")))) { productPage.SelectSizeByIndex(1); } productPage.AddToCartButton.Click(); wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.CssSelector("span.quantity[style]"))); productQuantity = GetProductQuantityOnProductPage(); } }
public static void WaintPresenceOfAllElementsLocated(string StrProp, string StrValue) { if (StrProp.Trim() == ".id") { Wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.Id(StrValue.Trim()))); } else if (StrProp.Trim() == ".name") { Wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.Name(StrValue.Trim()))); } else if (StrProp.Trim() == ".className") { Wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.ClassName(StrValue.Trim()))); } else if (StrProp.Trim() == ".tagName") { Wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.TagName(StrValue.Trim()))); } else if (StrProp.Trim() == ".linkText") { Wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.LinkText(StrValue.Trim()))); } else if (StrProp.Trim() == ".cssSelector") { Wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.CssSelector(StrValue.Trim()))); } else if (StrProp.Trim() == ".partialLinkText") { Wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.PartialLinkText(StrValue.Trim()))); } else if (StrProp.Trim() == ".xPath") { Wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.XPath(StrValue.Trim()))); } }
/// <summary> /// Waits for ALL the element specified via the given By to be present/visible /// Depending on whether or not waitForVisibility = TRUE /// NOTE: This seems to be getting used incorrectly in places where only 1 element is expected. /// </summary> /// <param name="by">Used to locate the element to be waited for</param> /// <param name="waitSeconds">Timeout</param> /// <param name="retry">Whether to retry, defaults to TRUE</param> /// <param name="waitForVisibility">Whether to wait for visibility or just presence, defaults to FALSE</param> /// <returns>List of web elements</returns> protected IReadOnlyCollection <IWebElement> WaitForElements(By by, int?waitSeconds = null, bool retry = true, bool waitForVisibility = false) { int seconds = waitSeconds ?? WebDriverTimeout; var wait = new WebDriverWait(baseDriver, TimeSpan.FromSeconds(seconds)); try { if (waitForVisibility) { return(wait.Until(ExpectedConditions.VisibilityOfAllElementsLocatedBy(by))); } return(wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(by))); } catch (Exception e) { if (retry) { try { WaitForElements(by, seconds, retry: false); //Call itself, but don't do another retry } catch (Exception) { //failed again, throw original error throw new WebDriverTimeoutException($"Cannot find element via: " + by + " Failing method = " + UtilityMethods.GetCurrentMethod(), e); } } else { throw new WebDriverTimeoutException($"Cannot find element via: " + by + " Failing method = " + UtilityMethods.GetCurrentMethod(), e); } } return(null); }
public List <IWebElement> get_LicenseCompaniesTableCompaniesName() { return(extWait.Until( ExpectedConditions.PresenceOfAllElementsLocatedBy( By.XPath("//table//tr//td[1]//a[contains(@href,'java')]"))) .ToList()); }
public void Setup() { _wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); driver.Navigate().GoToUrl(baseURL + "/Autocomplete"); _wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.CssSelector("html body puppet-client"))); _wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(PlacesSearchSelector)); }
public List <IWebElement> get_materialCompositionType() { return(extWait.Until( ExpectedConditions.PresenceOfAllElementsLocatedBy( By.XPath("//*[@class='materialCompositionType']"))) .ToList()); }
public void RealizarPagamento() { var pagamentoPO = new PagamentoPO(driver); var randon = new Random(); var formaPagamento = randon.Next(2); if (formaPagamento == 0) { driver.FindElement(pagamentoPO.byFormaPagamentoTransferencia).Click(); } else { driver.FindElement(pagamentoPO.byFormaPagamentoCheck).Click(); } wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(pagamentoPO.byBotaoConfirmarOrdem)); driver.FindElement(pagamentoPO.byBotaoConfirmarOrdem).Click(); Assert.True(driver.FindElement(pagamentoPO.byBotaoVoltarParaOrdens).Displayed); driver.FindElement(pagamentoPO.byBotaoVoltarParaOrdens).Click(); Screenshot _shot = ((ITakesScreenshot)driver).GetScreenshot(); _shot.SaveAsFile(Environment.CurrentDirectory + @"\ResumoCompras.png"); }
public List <IWebElement> get_LicenseCompaniesTableRowRecordName() { return(extWait.Until( ExpectedConditions.PresenceOfAllElementsLocatedBy( By.XPath("//table//tr//td[text()='Inactive']/preceding-sibling::td[3]"))) .ToList()); }
public void Test_CountryEditLinksNewWindow() { LoginAdminPart(); List <ICollection <string> > windowsId = new List <ICollection <string> >(); var uls = driver.FindElement(By.Id("box-apps-menu")); Sleep(1000); var lis = uls.FindElements(By.Id("app-")); lis[2].Click(); driver.FindElement(By.LinkText("Add New Country")).Click(); string mainCountryWindow = driver.CurrentWindowHandle; var oldWindows = driver.WindowHandles; windowsId.Add(oldWindows); var links = driver.FindElements(By.XPath("//*[@id='content']/form/table[1]/tbody/tr/td/a/i[1]")); for (int i = 0; i < links.Count; i++) { links[i].Click(); ICollection <string> oldWindows1 = driver.WindowHandles; windowsId.Add(oldWindows1); var secondWindow = windowsId[1]; driver.SwitchTo().Window(secondWindow.ToString()); wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.CssSelector("h1"))); driver.Close(); driver.SwitchTo().Window(mainCountryWindow); } }
public List <IWebElement> get_LicenseCompaniesTableRowRecordCheckbox() { return(extWait.Until( ExpectedConditions.PresenceOfAllElementsLocatedBy( By.XPath("//table//tr//input[@type='checkbox']"))) .ToList()); }
public void ClickMainTabBooks() { Browser.Wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy((By.XPath("//a[@title='książki']")))); var BooksField = Browser.Driver.FindElement(By.XPath("//a[@title='książki']")); BooksField.Click(); }
public void Signups() { WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(20)); IWebElement Signup = driver.FindElement(By.LinkText("Sign up")); Signup.Click(); wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.Id("sign-username"))); IWebElement Username = driver.FindElement(By.Id("sign-username")); Username.SendKeys(username); IWebElement Password = driver.FindElement(By.Id("sign-password")); Password.SendKeys(passwords); IWebElement SignupButton = driver.FindElement(By.XPath("//button[contains(text(),'Sign up')]")); SignupButton.Click(); wait.Until(ExpectedConditions.AlertIsPresent()); String AlertMsg = driver.SwitchTo().Alert().Text; Console.WriteLine(AlertMsg); Thread.Sleep(3000); Assert.AreEqual("Sign up successful.", AlertMsg); driver.SwitchTo().Alert().Accept(); }
public void deveAcessarSwipe() { WebDriverWait wait = new WebDriverWait(DriverFactory.getDriver(), TimeSpan.FromSeconds(10)); wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.XPath("//*[@text='Formulário']"))); menu.scroll(0.9, 0.10); menu.acessarSwipe(); Assert.True(menu.existeElementoPorTexto("a esquerda")); menu.swipeRight(); esperar(1000); Assert.True(menu.existeElementoPorTexto("E veja se")); menu.clicarTexto("›"); esperar(3000); //Assert.True(menu.existeElementoPorTexto("fim")); menu.clicarTexto("‹"); esperar(1000); Assert.True(menu.existeElementoPorTexto("E veja se")); menu.swipeLeft(); esperar(1000); Assert.True(menu.existeElementoPorTexto("a esquerda")); }
public static void clickDropdownValue(By element, string text) { IList <IWebElement> list = FindElements(element); wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(element)); try { if (list.Count > 0) { foreach (IWebElement dd_value in list) { if (dd_value.Text.ToLower().Contains(text.ToLower())) { dd_value.Click(); break; } } } else { throw new Exception("Value is not available in the dropdown"); } } catch (Exception) { throw new Exception("No values found in the dropdown"); } }
public static void WaitElementIsPresenceByCss(String cssSelector, long timeout = 30) { WebDriverWait wait = new WebDriverWait(DriverManager.GetWebDriver(), TimeSpan.FromSeconds(timeout)); wait.PollingInterval = TimeSpan.FromSeconds(1); wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.CssSelector(cssSelector))); }
/// <summary> /// gets the amazon link of a post from the website /// </summary> /// <param name="driver"></param> /// <param name="wait"></param> /// <param name="post"></param> /// <returns></returns> public static String getLink(IWebDriver driver, WebDriverWait wait, Post post) { int totalPages; String tag = Wordpress.SendGetTag(Wordpress.GetTag(post)); driver.FindElement(By.XPath("//div [@class = 'wp-menu-image dashicons-before dashicons-admin-post']")).Click(); if (driver.FindElements(By.XPath("//span [@class = 'total-pages']")).Count > 0) { totalPages = int.Parse(driver.FindElement(By.XPath("//span [@class = 'total-pages']")).Text); } else { totalPages = 1; } for (int x = 1; x <= totalPages; x++) { List <IWebElement> elements = driver.FindElements(By.XPath("//td [@class = 'tags column-tags']")).ToList(); foreach (IWebElement element in elements) { if (element.Text == tag) { return(driver.FindElement(By.XPath("(//span [@class = 'url'])[" + (elements.IndexOf(element) + 1).ToString() + "]")).GetAttribute("innerHTML")); } } if (x != totalPages) { driver.FindElement(By.XPath("//a [@class = 'next-page button']")).Click(); wait.Until(ExpectedConditions.PresenceOfAllElementsLocatedBy(By.XPath("//td [@id = 'cb']"))); } } MessageBox.Show("Link not found"); return("Not Found"); }