51Testing软件测试论坛

标题: Selenium 报错问题,请大侠帮忙看看,不知道啥原因! [打印本页]

作者: gongbo    时间: 2016-11-1 21:05
标题: Selenium 报错问题,请大侠帮忙看看,不知道啥原因!

import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;


public class NewTest2 {
        WebDriver driver;
  @Test
  public void f() {
                driver=new ChromeDriver();

                        driver.get("http://www.baidu.com");
  }
  @BeforeMethod
  public void beforeMethod() {

          System.setProperty("webdriver.chrome.driver", "D:\\selenium\\chromedriver.exe");

  }

  @AfterMethod
  public void afterMethod() {
  }


}



报错:
[Utils] Attempting to create D:\workspace\Test01\test-output\Default suite\Default test.xml
[Utils]   Directory D:\workspace\Test01\test-output\Default suite exists: true
FAILED: f
org.openqa.selenium.NoSuchSessionException: no such session
  (Driver info: chromedriver=2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129),platform=Windows NT 6.1.7601 SP1 x86) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 17 milliseconds
Build info: version: '3.0.0', revision: '350cf60', time: '2016-10-13 10:48:16 -0700'
System info: host: 'PC201610221438', ip: '192.168.128.129', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{message=session not created exception
from unknown error: Runtime.executionContextCreated has invalid 'context': {"auxData":{"frameId":"2608.1","isDefault":true},"id":1,"name":"","origin":"://"}
  (Session info: chrome=54.0.2840.71)
  (Driver info: chromedriver=2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129),platform=Windows NT 6.1.7601 SP1 x86), platform=ANY}]
Session ID: fa1ffa8c99526237cf001696b6b2ba87
        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.ErrorHandler.createThrowable(ErrorHandler.java:216)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635)
        at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:322)
        at package01.NewTest2.f(NewTest2.java:19)
        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:100)
        at org.testng.internal.Invoker.invokeMethod(Invoker.java:646)
        at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:811)
        at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1137)
        at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
        at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
        at org.testng.TestRunner.privateRun(TestRunner.java:753)
        at org.testng.TestRunner.run(TestRunner.java:607)
        at org.testng.SuiteRunner.runTest(SuiteRunner.java:368)
        at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:363)
        at org.testng.SuiteRunner.privateRun(SuiteRunner.java:321)
        at org.testng.SuiteRunner.run(SuiteRunner.java:270)
        at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
        at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
        at org.testng.TestNG.runSuitesSequentially(TestNG.java:1284)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:1209)
        at org.testng.TestNG.runSuites(TestNG.java:1124)
        at org.testng.TestNG.run(TestNG.java:1096)
        at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
        at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
        at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)




作者: 梦想家    时间: 2016-11-2 11:14
额太长了 建议直接接错误部分的图。还有录制什么哪里出的错,你直接贴代码没人看的
作者: gongbo    时间: 2016-11-2 13:28
org.openqa.selenium.NoSuchSessionException: no such session
  (Driver info: chromedriver=2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129),platform=Windows NT 6.1.7601 SP1 x86) (WARNING: The server did not provide any stacktrace information)
作者: joykao    时间: 2016-11-2 16:35
把chromedriver的包更新下,现在最新的是2.25,还有检查下testng的jar包有没有问题
作者: gongbo    时间: 2016-11-2 19:25
谢谢4楼的朋友,就是driver的问题,。谢谢
作者: jingzizx    时间: 2016-11-8 18:44
4楼赞一个




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2