Java 尝试使用Selenium运行简单脚本时出错

Java 尝试使用Selenium运行简单脚本时出错,java,selenium,selenium-webdriver,Java,Selenium,Selenium Webdriver,我对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, i

我对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();
    }}

}

将导入放在类之外,并尝试在url中使用http://-

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class TestClass1{

  public static void main(String[] args) {

    WebDriver driver = new FirefoxDriver();
    driver.get("http://www.google.com");
    driver.quit();
  }
}

为什么你的导入在你的班级里?当你说你尝试了很多东西-当你在谷歌上搜索你得到的错误时,你发现了什么?嘿,非常感谢你的帮助,它对我起了作用。