我面临着无法解决的硒问题。我收到以下错误”
no such element: Unable to locate element:{"method":"id","selector":"menu-supply-approval-queue"}
我知道问题在于等待。所以我做了下一个方法:
public static WebElement getWebElementByIdWithWait(String id)
{
WebDriverWait wait = new WebDriverWait(WebDriverMgr.getDriver(), 300000000);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("menu-supply-approval-queue")));
return WebDriverMgr.waitForElementToBeClickable(By.id(id));
}
然而,selenium 不会等待,并再次出现此错误:
Thu Sep 12 16:56:45 IDT 2019:ERROR: no such element: Unable to locate element: {"method":"id","selector":"menu-supply-approval-queue"}
(Session info: chrome=76.0.3809.132)
(Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: '', ip: '', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_65'
Driver info: org.openqa.selenium.chrome.ChromeDriver
有人可以建议如何让硒等待元素显示/可点击吗?它一刻也不等
更奇怪的是,selenium 实际上返回了该元素,然后单击它,所以如果他找不到它,他如何返回它?它只会弄乱日志
这是有效的代码,但它使用睡眠
public static WebElement getWebElementByIdWithWait(String id)
{
Logger.sleep(60000);
// WebDriverWait wait = new WebDriverWait(WebDriverMgr.getDriver(), 8);
// wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("menu-supply-approval-queue")));
return WebDriverMgr.waitForElementToBeClickable(By.id(id));
}
问候
守着星空守着你
米脂
冉冉说
慕哥6287543
相关分类