Selenium 问题汇总

  1. 第1种情况

问题背景 seleniuim 使用版本是2.52.0, FirefoxWebDriver, 23寸显示屏
在调用wd.findelement(By.xpath(“your path”)).click();
报错:
org.openqa.selenium.WebDriverException: Element is not clickable at point (1870, 821.8499755859375). Other element would receive the click:

Command duration or timeout: 70 milliseconds Build info: version: ‘2.52.0’, revision: ‘4c2593cfc3689a7fcd7be52549167e5ccc93ad28’, time: ‘2016-02-11 11:22:43’ System info: host: ‘chenchen-desktop’, ip: ‘192.168.1.112’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_66’ Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=44.0.2, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}] Session ID: 9d708d4b-fa75-42fd-b276-42ba84e367ff at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678) at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327) at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:85) at swiftcoder2_0.Swiftcoder2_0.sc_selectAvailPreset(Swiftcoder2_0.java:3747) at swiftcoder2_0.TC_Operation.Scoder_445(TC_Operation.java:3351)

在这段信息中 org.openqa.selenium.WebDriverException: Element is not clickable at point (1870, 821.8499755859375). Other element would receive the click:

解决方案:先关闭button的页面上的对话框,然后在点击button,即可!

  1. 第2种情况

问题背景 seleniuim 使用版本是2.52.0, FirefoxWebDriver, 14寸的显示屏
报错:
org.openqa.selenium.WebDriverException: Element is not clickable at point (xxx, xx.xxxx). Other element would receive the click:…
同样case在23寸显示屏跑过,14寸显示屏跑就出现大量的not clickable的信息错误。
刚开始没有分析到这显示屏的上面,一直认为页面加载时间太短,导致not clickable;然后延长页面加载时间,现象依然,最后想到显示屏大小,导致滚动条存在。
如果要点击的页面元素,不在可视范围内,也会导致not clickable错误。
所以增加了处理方法:将滚动条滚动到要指定元素上,同时此元素置顶页面,等待1s,既可。
用js方法处理:
WebElement e = wd.findElement(By.xpath(“指定元素”));
scroll = (JavascriptExecutor) wd;
scroll.executeScript(“arguments[0].scrollIntoView();”, e);
GL.wait(1);

你可能感兴趣的:(Selenium)