I am trying to run selenium code and get this error. I already downloaded the latest chromedriver version. Any suggestion is highly appreciated

huangapple 未分类评论47阅读模式
英文:

I am trying to run selenium code and get this error. I already downloaded the latest chromedriver version. Any suggestion is highly appreciated

问题

我正在尝试运行Selenium代码并且遇到了这个错误。我已经下载了最新版本的chromedriver。非常感谢您的任何建议。
异常信息如下:

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: 无法创建会话。

代码部分如下:

package basics.selenuim;

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;

public class LunchBrowsers {

    public static void main(String[] args) throws InterruptedException {

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

        WebDriver driver = new ChromeDriver();
        driver.manage().window().maximize();
        driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 

        driver.get("https://www.cnn.com/");

        String siteTitle = driver.getTitle();
        System.out.println(siteTitle);

        Thread.sleep(5000);
        driver.close();

    } 
}
英文:

I am trying to run selenium code and get this error. I already downloaded the latest chromedriver version. Any suggestion is highly appreciated.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created.

package basics.selenuim;

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;

public class LunchBrowsers {

   public static void main(String[] args) throws InterruptedException {

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

   	WebDriver driver = new ChromeDriver();
   	driver.manage().window().maximize();
   	driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
   	driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 

       driver.get("https://www.cnn.com/");

   	String siteTitle = driver.getTitle();
   	System.out.println(siteTitle);

   	Thread.sleep(5000);
   	driver.close();

   } 
}

huangapple
  • 本文由 发表于 2020年7月24日 07:10:43
  • 转载请务必保留本文链接:https://java.coder-hub.com/63064419.html
匿名

发表评论

匿名网友

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

确定