无法读取 null Web 驱动程序异常的原型属性正在显示。

huangapple go评论113阅读模式
英文:

Cannot read property prototype of null web driver exception is getting displayed

问题

我正在尝试运行 Selenium 脚本,之前成功运行了 100 次。但现在出现以下错误,代码没有任何更改,连一个字母都没有改动。我尝试以下方式来解决我的问题:

由于我知道问题不在于代码,我猜测问题可能出现在 WebDriver 或 Chrome Driver 的配置中。

-> 将脚本中使用的 Chrome Driver 更新到版本 81,因为我的 Chrome 浏览器也是版本 81。
-> 将 Selenium JAR 包更新到最新版本。(使用旧版本时我仍然遇到相同的问题,使用新版本时也遇到相同的问题)

错误日志指向了下面的 if 条件,用于脚本执行失败:

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

错误信息如下:

  1. org.openqa.selenium.WebDriverException: unknown error: Runtime.evaluate threw exception: TypeError: Cannot read property 'prototype' of null
  2. ...

Session 信息:chrome=81.0.4044.92

Driver 信息:org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 81.0.4044.92, ...}

错误日志指向了 if 条件处,这是脚本执行失败的原因。

英文:

I am trying to run selenium script which ran 100 times successfully previously. But now It is displaying the below error, there is no change in the code not even a single letter. I tried to resolve my issue in the below following ways:

As i know the issue is not with the code and i guess the issue somewhere lies between WebDriver or Chrome Driver configurations

->Updated my chorme driver which i am using in the script to version 81 as my chrome browser is also version 81
->Updated selenium jar to latest version. (with old version also i am facing the same issue and with the new version also i am facing the same issue)

  1. org.openqa.selenium.WebDriverException: unknown error: Runtime.evaluate threw exception: TypeError: Cannot read property 'prototype' of null
  2. at Function.Object.create (https://gom/openiam-ui-static/js/common/openiam.common.js?3.3.1.RELEASE:8:25)
  3. at new CacheWithUUID (<anonymous>:85:24)
  4. at getPageCache (<anonymous>:247:18)
  5. at callFunction (<anonymous>:435:17)
  6. at <anonymous>:464:23
  7. at <anonymous>:465:3
  8. (Session info: chrome=81.0.4044.92)
  9. Driver info: org.openqa.selenium.chrome.ChromeDriver
  10. Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 81.0.4044.92, chrome: {chromedriverVersion: 81.0.4044.69 (6813546031a4b..., userDataDir: C:\Users38~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}
  11. Session ID: d75cb3cd1e56a69fa922c007bfe36072
  12. at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  13. at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
  14. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
  15. at java.lang.reflect.Constructor.newInstance(Unknown Source)
  16. at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
  17. at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
  18. at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
  19. at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
  20. at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
  21. at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
  22. at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:609)
  23. at org.openqa.selenium.remote.RemoteWebDriver.getTitle(RemoteWebDriver.java:281)
  24. at testclasses.Baseclass.invokeBrowser(Baseclass.java:83)
  25. at testclasses.NewTest.Test1(NewTest.java:31)
  26. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  27. at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
  28. at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  29. at java.lang.reflect.Method.invoke(Unknown Source)
  30. at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
  31. at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
  32. at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
  33. at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
  34. at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
  35. at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
  36. at org.testng.TestRunner.privateRun(TestRunner.java:767)
  37. at org.testng.TestRunner.run(TestRunner.java:617)
  38. at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
  39. at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
  40. at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
  41. at org.testng.SuiteRunner.run(SuiteRunner.java:240)
  42. at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
  43. at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
  44. at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
  45. at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
  46. at org.testng.TestNG.run(TestNG.java:1057)
  47. at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
  48. at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
  49. at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
  50. ===============================================
  51. Default test
  52. Tests run: 1, Failures: 1, Skips: 0
  53. ===============================================
  54. ===============================================
  55. Default suite
  56. Total tests run: 1, Failures: 1, Skips: 0
  57. ===============================================
  58. [TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@3b6eb2ec: 681 ms
  59. [TestNG] Time taken by org.testng.reporters.JUnitReportReporter@96532d6: 12 ms
  60. [TestNG] Time taken by org.testng.reporters.XMLReporter@7e0ea639: 10 ms
  61. [TestNG] Time taken by org.testng.reporters.jq.Main@34ce8af7: 74 ms
  62. [TestNG] Time taken by org.testng.reporters.EmailableReporter2@2d6e8792: 9 ms
  63. [TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 13 ms

Error log points to the if condition below for the script failure

  1. if(driver.getTitle().contains(" MyAccount - Log In"))
  2. {
  3. driver.findElement(By.id("aSsoLogin")).click();
  4. driver.findElement(By.id("username")).clear();
  5. driver.findElement(By.id("username")).sendKeys(prop.getProperty("id"));
  6. driver.findElement(By.id("password")).clear();
  7. driver.findElement(By.id("password")).sendKeys(prop.getProperty("pwd"));
  8. driver.findElement(By.id("submitFrm")).click();
  9. if(driver.getTitle().equalsIgnoreCase("GE Browser Security Check")) {
  10. wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath("//*[text()='Remind me later']"))));
  11. driver.findElement(By.xpath("//*[text()='Remind me later']")).click();
  12. }
  13. }

答案1

得分: 0

我找到了问题所在。Chrome浏览器自动更新到了81版本,尽管我使用了81版本的chrome驱动,但是执行失败了。所以我将Chrome浏览器降级到了79版本,并且使用了79版本的chrome驱动来运行Selenium脚本,它成功了。新版本的Chrome浏览器存在问题(80和81版本)。

英文:

I figured out the issue. Chrome browser automatically updated to version 81, though i used chrome driver version 81 it is failing. So i downgraded chrome browser to version 79 and used 79 version of chrome driver to run the selenium script it worked. There are issue with new version of chrome browsers(80 & 81)

huangapple
  • 本文由 发表于 2020年4月10日 04:35:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/61129787.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定