我在运行硒测试用例时遇到类似脚本返回意外结果的错误

时间:2019-08-12 07:43:27

标签: java selenium selenium-chromedriver

我正在使用最新的chrome版本(76.0.3809.100)和硒的最新版本(3.141.59)以及最新的webdriver Manager版本(3.6.2),并且出现了显示脚本返回意外结果的问题。

根据与stackoverflow上此问题相关的搜索,我检查了所有链接并尝试升级每种铬和硒,但均无效果。

这是pom.xml

      <dependency>
        <groupId>io.github.bonigarcia</groupId>
        <artifactId>webdrivermanager</artifactId>
        <version>3.6.2</version>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.141.59</version>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.14.3</version>
    </dependency>

正在访问xpath的代码

List<WebElement> allVINs = null;
try {
         allVINs =     driver.findElements(By.xpath("//a[@target='_blank']"));
    } catch (Exception e1) {
        Log.info("Something wrong with storing element in the list and the issue is: " + e1);
        e1.printStackTrace();
    }

我希望它能成功运行且没有错误,但是它显示如下异常

INFO: Detected dialect: W3C
org.openqa.selenium.WebDriverException: unknown error: script returns unexpected result
(Session info: chrome=76.0.3809.100)
Build info: version: '3.141.59', revision: 'e82be7d358', time:'2018-11-14T08:17:03'
System info: host: 'PC name', ip: 'ipAddress', os.name: 'Windows 10',     os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_144'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome,     browserVersion: 76.0.3809.100, chrome: {chromedriverVersion: 76.0.3809.68 (420c9498db8ce..., userDataDir: C:\Users\VIVEK~1.SIN\AppDat...}, goog:chromeOptions: {debuggerAddress: localhost:59659}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: dbb14cb4d3a103864093b7d121bd29f0
*** Element info: {Using=xpath, value=//a[@target='_blank']}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
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.findElements(RemoteWebDriver.java:353)
at org.openqa.selenium.remote.RemoteWebDriver.findElementsByXPath(RemoteWebDriver.java:432)
at org.openqa.selenium.By$ByXPath.findElements(By.java:348)
at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:311)
at com.Adesa.Utilities.WebDriverUtils.getVINlist(WebDriverUtils.java:896)
at com.Adesa.Utilities.Environment.WriteExcelData(Environment.java:76)
at com.Adesa.Actions.DDO.DDOActions.createExcelFileToUpload(DDOActions.java:41)
at com.Adesa.Local.TestCases.DDO.DDOFunctionalTestCases.AddVINsToDDOTest(DDOFunctionalTestCases.java:24)
at com.Adesa.Local.TestCases.Functional.Admin_FunctionalTestCases.AdminFunctionalTestCases(Admin_FunctionalTestCases.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
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)

0 个答案:

没有答案