|
- package christin.test;
- import java.util.concurrent.TimeUnit;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.chrome.ChromeDriver;
- import org.openqa.selenium.firefox.FirefoxDriver;
- import org.openqa.selenium.remote.DesiredCapabilities;
- public class testC {
- public static void main(String[] args) {
- System.setProperty("webdriver.chrome.driver","C:/Program Files (x86)/Google/Chrome/Application/chromedriver.exe");
- //System.setProperty("webdriver.gecko.driver","F:/firefox/geckodriver.exe");
- //初始化一个chrome浏览器实例,实例名称叫driver
- //WebDriver driver = new FirefoxDriver();
- WebDriver driver = new ChromeDriver();
- //最大化窗口
- driver.manage().window().maximize();
- //设置隐性等待时间
- driver.manage().timeouts().implicitlyWait(8, TimeUnit.SECONDS);
- // get()打开一个站点
- driver.get("https://www.baidu.com");
- //getTitle()获取当前页面title的值
- System.out.println("当前打开页面的标题是: "+ driver.getTitle());
- //关闭并退出浏览器
- driver.quit();
- }
- }
复制代码 报错如下:
- Exception in thread "main" java.lang.IllegalAccessError: tried to access method com.google.common.util.concurrent.SimpleTimeLimiter.<init>(Ljava/util/concurrent/ExecutorService;)V from class org.openqa.selenium.net.UrlChecker
- at org.openqa.selenium.net.UrlChecker.<init>(UrlChecker.java:67)
- at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:190)
- at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:181)
- at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
- at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
- at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
- at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
- at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
- at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:184)
- at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:171)
- at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:124)
- at christin.test.testC.main(testC.java:21)
- Process finished with exit code 1
复制代码
|
|