在Selenium maven项目中无法午餐chrome浏览器



java.lang.IllegalStateException:驱动程序可执行文件的路径必须由 webdriver.chrome.driver system 属性设置;有关详细信息,请参阅 https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver。最新版本可以从 http://chromedriver.storage.googleapis.com/index.html 下载 at com.google.common.base.Preconditions.checkState(Preconditions.java:847( at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:134( at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:35( at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:159( at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:355( at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94( at org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123( 在物联网数据规范化。Datanormalization.beforeClass(Datanormalization.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(

enter code here
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>2.2.5</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>2.50.0</version>//Your chrome driver version
</dependency>
package example;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.Test;
import io.github.bonigarcia.wdm.WebDriverManager;
public class DepChrome  {
@Test
public void testBrowser() {
WebDriver driver;
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver();        
driver.get("https://google.com");
String title = driver.getTitle();
System.out.println(title);      
driver.quit();      
}
}

请检查您的 chrome 驱动程序路径,错误是说您的路径上没有 chrome 驱动程序

@Test
public void testLogin() throws InterruptedException {
System.setProperty("webdriver.chrome.driver","chromepath);
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get(url);

相关内容

  • 没有找到相关文章

最新更新