尝试使用Selenium运行简单脚本时出现java错误
我对Selenium还不熟悉,只是想用它打开一个浏览器,但这让我很难受。每当我尝试运行以下代码时,它都会给我以下错误:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token "void", @ expected
Syntax error on token "]", :: expected after this token
Syntax error, insert "enum Identifier" to complete EnumHeader
Syntax error, insert "}" to complete EnumBody
at TestClass1.main(TestClass1.java:7)
我试了很多东西,但什么也找不到
public class TestClass1{
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public static void main(String[] args) {
// TODO Auto-generated method stub
//System.setProperty("webdriver.firefox.bin", "c:\\path\\to\\firefox.exe");
WebDriver driver = new FirefoxDriver();
driver.get("www.google.com");
driver.quit();
}}
}
# 1 楼答案
将导入内容放在类外,并尝试在url中使用http://