基本信息: Selenium WebDriver, 日食, Java中, Firefox驱动程序
我收到此错误:
`
Exception in thread "main" org.openqa.selenium.ElementNotVisibleException:
Build info: version: 'unknown', revision: '5234b32', time: '2017-03-10 09:00:17 -0800'
System info: host: 'MILTON-MENDIETA', ip: '10.77.60.197', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{moz:profile=C:\Users\Milton\AppData\Local\Temp\rust_mozprofile.POZZHDGnD1QQ, rotatable=false, timeouts={implicit=0, page load=300000, script=30000}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=52.0.2, platformVersion=10.0, moz:processID=14868, browserName=firefox, platformName=windows_nt}]
Session ID: 3172ee71-f22c-4699-a723-3c27a87c6ce5
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:133)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:99)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:43)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:274)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
`
一旦我在调用get()后登陆页面,就会发生这种情况。
以下是我必须等待元素可见的代码:
WebDriverWait wait = new WebDriverWait(driver, 20);
for(int counter = 25; counter < 50; counter++){
// Navigate to Site
driver.get("https://sandbox.webcomserver.com/wpm/adminHome.do?&tenantName=walkme_test");
//Wait for SmartTip to be visible
// wait.until(ExpectedConditions.visibilityOfElementLocated((By.cssSelector("a#helpLink"))));
//Wait for Widget to be visible (Could be a method? MyClass.openWidget() ?
wait.until(ExpectedConditions.visibilityOfElementLocated((By.id("walkme-player"))));
driver.findElement(By.id("walkme-player")).click();
//Start Add Status to WorkFlow WT
wait.until(ExpectedConditions.visibilityOfElementLocated((By.cssSelector("div.walkme-walkthru-219559"))));
driver.findElement(By.cssSelector("div.walkme-walkthru-219559")).click();
//Wait for Step (Hover over Workflows) to be visible
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("walkme-balloon-2412584")));
一旦页面加载,它就会给我错误。它是否应该在抛出错误之前等待20秒?
我尝试使用不同的选择器,例如className
,cssSelectors
和id
。
HTML代码段:
<div id="walkme-player" class="walkme-player walkme-colorado walkme-theme-white-green walkme-direction-ltr walkme-notie walkme-position-major-bottom walkme-position-minor-right walkme-dynamic-size walkme-to-destroy walkme-override walkme-css-reset walkme-language-default" style="display: block; bottom: 0px;" data-inanimation="0">
<div class="walkme-in-wrapper walkme-override walkme-css-reset" style="width: 154px;">
<div class="walkme-question-mark walkme-override walkme-css-reset"></div>
<div class="walkme-title walkme-override walkme-css-reset">Need help?</div>
</div>
</div>
我很确定它只是在元素加载之前将其评估为不可见,因为它偶尔会起作用。我甚至尝试添加隐式等待thread.sleep()
,但它仍然没有等待。不知道还能做什么。