我的项目是在 mvc 中,我想使用 selenium web 驱动程序来测试它。 某些按钮点击可以正常工作。但是,当我导航到不同的页面时,说在该页面上继续,“保存”按钮不起作用。
下面是我的代码
driver.FindElement(By.Id("BtnAddNew")).Click();
IWebElement cat = driver.FindElement(By.Id("Cat"));
cat.SendKeys("Single-family house");
IWebElement ext_id = driver.FindElement(By.Id("ExternalId"));
ext_id.SendKeys("SAR_47");
IWebElement zip = driver.FindElement(By.Id("AddressZipTown"));
zip.SendKeys("1205 Genève");
IWebElement street = driver.FindElement(By.Id("AddressStreet"));
street.SendKeys("Tramstrasse 10");
driver.FindElement(By.Id("btnContinue")).Click();
driver.FindElement(By.Id("btnSave")).Click();
driver.Quit();
谁能解决我的问题吗?
最佳答案
您可以通过检查 DOM 一段时间来尝试找到您的 WebElement 来解决此问题。您可以使用隐式或显式等待。
文档:
http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp#explicit-waits http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp#implicit-waits
关于javascript - Selenium Webdriver 不会点击 Chrome 和 Firefox 中的“保存”按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31069843/