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

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

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 条件,用于脚本执行失败:

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();
    }
}

错误信息如下:

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

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)

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:\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}
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

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

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();
		    	}
	    	}

答案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:

确定