【Selenium异常】WebDriverException

来源:互联网 发布:linux程序权限 编辑:程序博客网 时间:2024/06/02 06:49

异常类
org.openqa.selenium.WebDriverException


异常信息

org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (255, 575)  (Session info: chrome=60.0.3112.113)  (Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 6.1.7600 x86_64) (WARNING: The server did not provide any stacktrace information)Command duration or timeout: 249 millisecondsBuild info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'System info: host: '***', ip: '***', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_77'Driver info: org.openqa.selenium.remote.RemoteWebDriverCapabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8), userDataDir=C:\Users\Think\AppData\Local\Temp\scoped_dir35164_16594}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=60.0.3112.113, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]Session ID: 73b0eb77cee85d6c901ce4cb459daa9c    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_77]    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_77]    ...

或者

org.openqa.selenium.WebDriverException: unknown error: Element <a ui-sref="loanTrialDetail({type:'audit',id:'20170801090014C6A92B6B765411E7905BFA163E034260'})" class="btn btn-outline btn-circle btn-sm red" href="#/loan_trial_detail/audit/20170801090014C6A92B6B765411E7905BFA163E034260">...</a> is not clickable at point (1200, 41). Other element would receive the click: <a href="#" class="dropdown-toggle" dropdown-menu-hover="" data-toggle="dropdown" data-close-others="true" aria-haspopup="true" aria-expanded="false">...</a>  (Session info: chrome=60.0.3112.113)  (Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 6.1.7600 x86_64) (WARNING: The server did not provide any stacktrace information)Command duration or timeout: 230 millisecondsBuild info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'System info: host: '***', ip: '***', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_77'Driver info: org.openqa.selenium.remote.RemoteWebDriverCapabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8), userDataDir=C:\Users\Think\AppData\Local\Temp\scoped_dir33688_30564}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=60.0.3112.113, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]Session ID: 1a91284ce6e7c0ef6ca6adcc29d53091    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_77]    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_77]    ...

要点击的元素被其他元素全部或部分覆盖

解决方案:

(1)滚动窗口到该元素所在位置后再进行点击,参考Selenium之滚动。需要说明的一点是,这里使用Actions类进行滚动可能无法解决该问题,建议使用Element.scrollIntoView()window.scrollTo(x,y)

(2)修改定位路径,选择其他也可实现点击效果的元素路径替换原来的路径。比如我遇到的问题中使用By.xpath("//span[text()='»']")代替By.xpath("//span[text()='»']//parent::li")后问题解决。具体原因,暂且未明。

阅读全文
0 0
原创粉丝点击