Selenium Webdriver等待似乎无法正常工作

无限的

每当单击“登录”按钮时,就会出现一个覆盖层(灰色半透明屏幕),并且停留几秒钟。因此,Selenium Web驱动程序无法找到元素,因为这种重叠类型将它们隐藏了一段时间,或者至少对我来说是这样。我该如何处理?我发现Thread.sleep这里不是一种有效的方法。

我试过了 -

    public void login(){
        WebDriverWait wait = new WebDriverWait(driver, 60);     

        wait.until(ExpectedConditions.invisibilityOfElementLocated((By.id("ajax-overlay"))));
        wait.until(ExpectedConditions.elementToBeClickable((By.id("okbutton))));
        driver.findElement(By.id("username)).sendKeys("admin");
        driver.findElement(By.id("password")).sendKeys("admin123");
        driver.findElement(By.id("okbutton")).click();   
        wait.until(ExpectedConditions.invisibilityOfElementLocated((By.id("ajax-overlay"))));
}

但似乎没有任何效果,但我仍然出现错误-

org.openqa.selenium.WebDriverException: unknown error: Element <button id="loginDialog:okButton" name="loginDialog:okButton" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-panel-titlebar-icon synchronous" onclick="PrimeFaces.ab({source:'loginDialog:okButton',process:'loginDialog:okButton loginDialog:username loginDialog:password loginDialog:okButton',update:'startingCashFocus loginDialog:dialogFocus loginDialog:lblPassword loginDialog:lblUsername loginDialog:messages',oncomplete:function(xhr,status,args){handleLoginAttempt(xhr, status, args, loginWidget, null); ;}});return false;" tabindex="1" type="submit" role="button" aria-disabled="false">...</button> is not clickable at point (931, 250). Other element would receive the click: <div id="ajax-overlay" class="ui-blockui ui-widget-overlay ui-helper-hidden eternal" style="display: block;"></div>

另外,没有办法找出叠加层ID,谢天谢地,Selenium在错误详细信息中给出了它。

石田莎

尝试使用以下方法之一单击元素,这将解决此Exception:

Actions action = new Actions(driver);
action.moveToElement(driver.findElement(By.id('okbutton'))).click().perform(); 

要么

JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].click();", driver.findElement(By.id('okbutton')));

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Python Selenium Webdriver click()无法正常工作

Python Selenium Webdriver ActionChains似乎无法以任何方式工作

Selenium Explicit等待在Python中无法正常工作

Selenium Python无头Webdriver(PhantomJS)无法正常工作

Watir无法正常工作-Selenium :: WebDriver :: Error :: UnknownError

Selenium DragnDrop无法正常工作

Selenium / Firefox无法正常工作

无法让Selenium WebDriver等待指定的时间

Selenium Webdriver-在其中插入变量时,driver.get()无法正常工作

Selenium Webdriver中的日期选择器中的月份下拉菜单无法正常工作

代码工作正常,但突然“无法解析导入 org.openqa.selenium.WebDriver”

SetSize()无法正常工作:Selenium + Java

无法运行 selenium Chromedriver(之前工作正常)

Selenium中的pageLoadTimeout无法正常工作

使用Selenium时Cookies无法正常工作

Selenium脚本无法正常工作

ActionChains Selenium Python无法正常工作

Python Selenium:Microsoftonline登录无法正常工作

将Cookie导入Selenium无法正常工作

Python Selenium多线程无法正常工作

循环在 Selenium Python 中无法正常工作

Selenium + Java + Firefox + Windows无法正常工作

Selenium webdriver 等待元素并单击

无法在 selenium webdriver 中写入 Excel 工作表

selenium webdriver .click() 不工作

为什么Selenium WebDriverWait无法在Python类中正常工作?

使用Selenium的WhatsApp Web自动化无法正常工作

python selenium:move_to_element()无法正常工作

带有Selenium的Powershell:我无法使“滚动显示”正常工作