java - 显示无法读取 null Web 驱动程序异常的属性原型(prototype)

标签 java selenium webdriver selenium-chromedriver

我正在尝试运行 selenium 脚本,该脚本之前已成功运行 100 次。但现在它显示以下错误,代码没有变化,甚至连一个字母都没有变化。我尝试通过以下方式解决我的问题:

据我所知,问题不在于代码,我猜问题出在 WebDriver 或 Chrome 驱动程序配置之间

->将我在脚本中使用的 chorme 驱动程序更新为版本 81,因为我的 chrome 浏览器也是版本 81 ->将 Selenium jar 更新到最新版本。 (使用旧版本我也面临同样的问题,使用新版本我也面临同样的问题)

org.openqa.selenium.WebDriverException: unknown error: Runtime.evaluate threw exception: TypeError: Cannot read property 'prototype' of null
    at Function.Object.create (https://gom/openiam-ui-static/js/common/openiam.common.js?3.3.1.RELEASE:8:25)
    at new CacheWithUUID (<anonymous>:85:24)
    at getPageCache (<anonymous>:247:18)
    at callFunction (<anonymous>:435:17)
    at <anonymous>:464:23
    at <anonymous>:465:3
  (Session info: chrome=81.0.4044.92)
  Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 81.0.4044.92, chrome: {chromedriverVersion: 81.0.4044.69 (6813546031a4b..., userDataDir: C:\Users\5038~1\AppData\L...}, goog:chromeOptions: {debuggerAddress: localhost:57252}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}
Session ID: d75cb3cd1e56a69fa922c007bfe36072
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:609)
    at org.openqa.selenium.remote.RemoteWebDriver.getTitle(RemoteWebDriver.java:281)
    at testclasses.Baseclass.invokeBrowser(Baseclass.java:83)
    at testclasses.NewTest.Test1(NewTest.java:31)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
    at org.testng.TestRunner.privateRun(TestRunner.java:767)
    at org.testng.TestRunner.run(TestRunner.java:617)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
    at org.testng.SuiteRunner.run(SuiteRunner.java:240)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
    at org.testng.TestNG.run(TestNG.java:1057)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)


===============================================
    Default test
    Tests run: 1, Failures: 1, Skips: 0
===============================================


===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
===============================================

[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@3b6eb2ec: 681 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@96532d6: 12 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter@7e0ea639: 10 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@34ce8af7: 74 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@2d6e8792: 9 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 13 ms

错误日志指向脚本失败的以下 if 条件

if(driver.getTitle().contains(" MyAccount - Log In"))
            {
                driver.findElement(By.id("aSsoLogin")).click();             
                driver.findElement(By.id("username")).clear();
                driver.findElement(By.id("username")).sendKeys(prop.getProperty("id"));
                driver.findElement(By.id("password")).clear();
                driver.findElement(By.id("password")).sendKeys(prop.getProperty("pwd"));
                driver.findElement(By.id("submitFrm")).click();
                if(driver.getTitle().equalsIgnoreCase("GE Browser Security Check")) {
                    wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath("//*[text()='Remind me later']"))));
                    driver.findElement(By.xpath("//*[text()='Remind me later']")).click();
                }
            }

最佳答案

我发现了这个问题。 Chrome 浏览器自动更新到版本 81,尽管我使用 Chrome 驱动程序版本 81,但它失败了。所以我将 chrome 浏览器降级到版本 79 并使用 79 版本的 chrome 驱动程序来运行它起作用的 selenium 脚本。新版本chrome浏览器(80和81)存在问题

关于java - 显示无法读取 null Web 驱动程序异常的属性原型(prototype),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61129787/

相关文章:

java - 在 Java Applet 中运行 OrientDB

java - 我该如何处理这个自定义异常?

java - Java 中子类和集合之间的类转换异常问题

python - 如何使用 Python 字符串加载 PhantomJS

python - 使用 ChromeDriver 进行拖放

selenium - 无法检索文本 Selenium

java - 使用 for 循环将数组元素传递到 Oracle 数据库表

c# - 检测浏览器中是否弹出打开文件对话框

java - 通过 Appium 启动 (whatsapp) 移动应用程序会导致 "' com.whatsapp.Main' never started"错误

java - 无法获得演讲者