|
初学者,配置好了一切,网上找了一些demo
代码如下:
- package Selenium_Java;
- import java.io.File;
- 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.firefox.FirefoxDriver;
- import org.openqa.selenium.ie.InternetExplorerDriver;
- public class test111 {
- public static void main(String[] args) {
- //System.setProperty("webdriver.firefox.bin", "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe");
- WebDriver driver = new FirefoxDriver();//创建火狐
- driver.get("http://www.baidu.com");//打开百度
- driver.manage().window().maximize();//最大化
- WebElement element = driver.findElement(By.id("kw"));
- element.sendKeys("HelloWorld");//输入值china
- driver.findElement(By.id("su")).click();
- System.out.println("asdasd");
- }
- }
复制代码 报错如下:
- Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
- at com.google.common.base.Preconditions.checkState(Preconditions.java:738)
- at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:111)
- at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:38)
- at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:112)
- at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:302)
- at org.openqa.selenium.firefox.FirefoxDriver.toExecutor(FirefoxDriver.java:233)
- at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:125)
- at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:121)
- at Selenium_Java.test111.main(test111.java:22)
复制代码 报错那行是:WebDriver driver = new FirefoxDriver();//创建火狐
我看别人demo都是有上面那一段就打开了火狐浏览器
下面报错看不懂。。。求大神支援下。很不懂
|
|