在将List webelements存储到List集合中后,我无法单击元素。
List<WebElement> links = driver.findElements(By.xpath("//ul[@class='dropdown-menu']/li/a"));
System.out.println(links.size());
for (int i = 0; i < links.size(); i++) {
String text = links.get(i).getText();
System.out.println(text);
if (text.contentEquals("CSS")) {
links.get(i).click();
break;
}
}
我使用动作类来查找下拉菜单,并在bootstrap中开发下拉列表。 下面提到的完整错误:
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (183, 560)
(Session info: chrome=63.0.3239.132)
(Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 71 milliseconds
Build info: version: 'unknown', revision: '5234b32', time: '2017-03-10 09:00:17 -0800'
System info: host: 'RAV-LAP-503', ip: '192.168.2.55', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.28.455520 (cc17746adff54984afff480136733114c6b3704b), userDataDir=C:\Users\SAJITH~1.KUM\AppData\Local\Temp\scoped_dir13096_30556}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=63.0.3239.132, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=}]
Session ID: 697295b27acff024727ad8efd7d66c14
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:638)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:274)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
at Yahoo.bootstrap.main(bootstrap.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
答案 0 :(得分:-1)
如您所见,错误为:
org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (183, 560)
那样指出了解决方案
但您的主要问题是您使用的二进制文件中的版本兼容性,如下所示:
chromedriver=2.28.455520
chromedriver=2.28.455520
的发行说明明确提及以下内容:可与Chrome 57 +一起使用的各种更新
chrome=63.0.3239.132
chrome=63.x
,您必须使用 ChromeDriver 2.34 作为ChromeDriver 2.34的发行说明明确提及:支持Chrome v61-63
ChromeDriver
升级为 ChromeDriver v2.34
。Chrome
降级为 Chrome v57.x
级别。