我试图在Katalon Studio中使用executeJavascript方法,并编写了几行代码,看起来与文档示例中的代码非常相似:
我还在我的脚本中导入了WebElement:
但是,当我运行测试时,我收到以下错误消息:
Test Cases/Forms/Test1 - fill in maintenance request form FAILED because (of) Unable to execute JavaScript. (Root cause: org.openqa.selenium.WebDriverException: unknown error: element is not defined
(Session info: chrome=66.0.3359.181)
(Driver info: chromedriver=2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef),platform=Mac OS X 10.13.4 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z'
System info: host: 'Nikkis-MacBook-Pro.local', ip: 'fe80:0:0:0:18e2:b2c7:8b31:3164%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_102'
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.35.528157 (4429ca2590d698..., userDataDir: /var/folders/fl/d70hxqb520v...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 66.0.3359.181, webStorageEnabled: true}
Session ID: 05ebb4c39e0862af7f3893c442527a3b)
Test Cases/Forms/Test1 - fill in maintenance request form.run:65
然后,我更新了我的selenium,chrome驱动程序和java,但我仍然收到此错误:
Unable to execute JavaScript. (Root cause: org.openqa.selenium.WebDriverException: unknown error: element is not defined (Session info: chrome=66.0.3359.181) (Driver info: chromedriver=2.38.552518 (183d19265345f54ce39cbb94cf81ba5f15905011),platform=Mac OS X 10.13.4 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds Build info: version: '3.12.0', revision: '7c6e0b3', time: '2018-05-08T15:15:08.936Z' System info: host: 'Nikkis-MacBook-Pro.local', ip: 'fe80:0:0:0:18e2:b2c7:8b31:3164%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.4', java.version: '1.8.0_102' Driver info: com.kms.katalon.selenium.driver.CChromeDriver Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.38.552518 (183d19265345f5..., userDataDir: /var/folders/fl/d70hxqb520v...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version:
66.0.3359.181, webStorageEnabled: true} Session ID: 2c4f4643acb4d1c0a106ac0fb9e31254)
我不明白为什么我仍然会收到此错误,以及我如何解决此错误。
答案 0 :(得分:0)
此错误消息......
org.openqa.selenium.WebDriverException: unknown error: element is not defined
...表示 ChromeDriver 无法与浏览上下文即 Chrome浏览器会话进行通信。
您的主要问题是您使用的二进制文件之间的版本兼容性,如下所示:
支持 Chrome v62-64
支持 Chrome v65-67
因此 JDK v8u102 , Selenium客户端 v3.7.1 , ChromeDriver 版 v2.35 和 Chrome浏览器 v66.0
@Test
。