2014-09-23 7 views
-1

저는 Selenium을 처음 사용하고 브라우저를 열려고하는데 어려움을 겪습니다. 아래 코드를 실행하려고 할 때마다이 오류가 표시됩니다.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(); 
    }} 

} 
+0

을 왜 클래스 본문 내부에 당신의 수입은? – hexafraction

+0

당신이 많은 것을 시도했다고 말했을 때 - 당신이 겪었던 오류를봤을 때 무엇을 발견 했습니까? – anotherdave

+0

헤이 헥사 플라 즘은 나에게 도움이 된 당신의 도움에 감사드립니다. –

답변

1

놓습니다 클래스 외부에서 수입 및 HTTP를 사용해보십시오 : // URL에 -

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(); 
    } 
} 
관련 문제