We have some UI tests written in selenium running with Browserstack on TeamCity. These tests randomly fail because (in my opinion) the wait.Untils are not working correctly as the error always is 'could not click element ... because element would receive the click. As you can see in the code i apply multiple waits and still it randomly ignores them.
driver.FindElement(By.XPath("//input[@value='Login']")).Click();
//wait for the page to be loaded, check the title and open a booking
wait.Until(ExpectedConditions.ElementExists(By.LinkText("To be completed")));
wait.Until(ExpectedConditions.ElementToBeClickable(By.LinkText("To be completed")));
Assert.AreEqual("Booking Overview", driver.Title);
wait = new WebDriverWait(driver, TimeSpan.FromSeconds(60));
wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//button")));
wait.Until(ExpectedConditions.ElementToBeClickable(By.LinkText("To be completed")));
driver.FindElement(By.LinkText("To be completed")).Click();
//wait for step 2 to load
wait.Until(ExpectedConditions.ElementExists(By.XPath("//div[@id='WiredWizardsteps']/div[2]/div/form/div/div[2]/label/span")));
wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//div[@id='WiredWizardsteps']/div[2]/div/form/div/div[2]/label/span")));
//verify we are at step 2
var step2 = driver.FindElement(By.XPath("//ul[contains(@class, 'steps')]/li[contains(@class, 'active')]"));
Assert.AreEqual("2", step2.GetAttribute("data-target"));
//click the radiobutton with a movetoelement
var option = driver.FindElement(By.XPath("//div[@id='WiredWizardsteps']/div[2]/div/form/div/div[2]/label/span"));
new Actions(driver).MoveToElement(option).Click().Perform();
//retry programmatically
driver.FindElement(By.XPath("//div[@id='WiredWizardsteps']/div[2]/div/form/div/div[2]/label/span")).Click();
//wait for the textbox to appear
wait.Until(ExpectedConditions.ElementToBeClickable(By.Name("commodityNonOperative")));
anybody has a suggestion or had the same problems please let me know.
Aucun commentaire:
Enregistrer un commentaire