我试图运行在windows机器上创建的selenium测试。我将驱动程序更改为linux版本。把它加到了小路上。但每次我得到
org.selenium.NoSUchSessionException
我使用最新的浏览器和最新的驱动程序。
我是这样定义司机的:
public class AuthTestSteps {
private static WebDriver driver;
private static WebDriverWait wait;
@Given("^blah_blah$")
public void method() throws MalformedURLException{
driver = new ChromeDriver();
wait = new WebDriverWait(driver, 30);
System.setProperty("webdriver.chrome.driver","chromedriver");
}
解决方案:
我的案例解决方案是添加驱动程序管理器和选项到铬像“-无沙箱”,因为它是从根用户运行。
发布于 2018-03-03 10:57:57
在执行Selenium测试时,您需要首先通过WebDriver行传递System.setProperty()
二进制文件的绝对路径,然后按如下方式初始化Web浏览器:
public class AuthTestSteps
{
private static WebDriver driver;
@Given("^blah_blah$")
public void method() throws MalformedURLException
{
System.setProperty("webdriver.chrome.driver","/path/to/chromedriver");
driver = new ChromeDriver();
}
}
发布于 2018-03-02 07:23:08
使用铬驱动程序的绝对路径。这样改变你的代码。
public class AuthTestSteps {
private static WebDriver driver;
private static WebDriverWait wait;
@Given("^blah_blah$")
public void method() throws MalformedURLException{
// assuming that your chrome driver is located inside
// your project(src/main/resources/browser_driver/chromedriver)
// take absolute path for chrome driver
File file = new File("src/main/resources/browser_driver/chromedriver");
String absolutePath = file.getAbsolutePath();
driver = new ChromeDriver();
wait = new WebDriverWait(driver, 30);
System.setProperty("webdriver.chrome.driver", absolutePath);
}
https://stackoverflow.com/questions/49063657
复制相似问题