我试图在iframe中单击“不谢谢”,但不断收到“预期条件失败:等待框架可用”
我的代码:
WebDriver driver = new ChromeDriver();
driver.get("http://www.qaclickacademy.com");
new WebDriverWait(driver,40).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt
(By.xpath("//div[@class='sumome-react-wysiwyg-popup-animation-group']")));
driver.findElement(By.xpath("//div[@class='sumome-react-wysiwyg-popup-animation-group']/span/div/div[6]/div//div/button")).click();
初始加载页面后,iframe确实需要一些时间才能弹出,但是我在20、30、40和60处等待,但它不起作用。
该元素不存在任何<iframe>
。
要单击,NO THANKS您需要为引入WebDriverWait,elementToBeClickable()
然后可以使用以下定位器策略:
使用XPATH
:
driver.get("http://www.qaclickacademy.com")
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[text()='NO THANKS']"))).click();
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句