2016-08-05 6 views
1

eclipse ide에서 스크립트를 생성 한 후 Selenium webdriver 버전을 3.0 베타로 업데이트했습니다. 스크립트를 실행 한 후 Firefox가 열리지 만 URL로 리디렉션되지 않습니다.Firefox 48은 Selenium web driver 3.0을 사용하여 스크립트의 URL을 열지 않습니다.

이 셀레늄 IDE에 의해 생성 된 간단한 코드가

import java.util.regex.Pattern; 
import java.util.concurrent.TimeUnit; 
import org.testng.annotations.*; 
import static org.testng.Assert.*; 
import org.openqa.selenium.*; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.openqa.selenium.support.ui.Select; 

public class Selenium { 
    private WebDriver driver; 
    private String baseUrl; 
    private boolean acceptNextAlert = true; 
    private StringBuffer verificationErrors = new StringBuffer(); 

    @BeforeClass(alwaysRun = true) 
    public void setUp() throws Exception { 
    driver = new FirefoxDriver(); 
    baseUrl = "https://www.google.co.in/"; 
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); 
    } 

    @Test 
    public void testF() throws Exception { 
    driver.get(baseUrl + "/?gws_rd=ssl"); 
    driver.findElement(By.id("lst-ib")).clear(); 
    driver.findElement(By.id("lst-ib")).sendKeys("hi"); 
    driver.findElement(By.id("lst-ib")).clear(); 
    driver.findElement(By.id("lst-ib")).sendKeys("hifi"); 
    } 

    @AfterClass(alwaysRun = true) 
    public void tearDown() throws Exception { 
    driver.quit(); 
    String verificationErrorString = verificationErrors.toString(); 
    if (!"".equals(verificationErrorString)) { 
     fail(verificationErrorString); 
    } 
    } 

    private boolean isElementPresent(By by) { 
    try { 
     driver.findElement(by); 
     return true; 
    } catch (NoSuchElementException e) { 
     return false; 
    } 
    } 

    private boolean isAlertPresent() { 
    try { 
     driver.switchTo().alert(); 
     return true; 
    } catch (NoAlertPresentException e) { 
     return false; 
    } 
    } 

    private String closeAlertAndGetItsText() { 
    try { 
     Alert alert = driver.switchTo().alert(); 
     String alertText = alert.getText(); 
     if (acceptNextAlert) { 
     alert.accept(); 
     } else { 
     alert.dismiss(); 
     } 
     return alertText; 
    } finally { 
     acceptNextAlert = true; 
    } 
    } 
} 
+0

오류에 대한 추가 정보를 제공해 주시겠습니까? gecko 드라이버를 구성 했습니까 (https://stackoverflow.com/questions/37785686/how-to-use-the-gecko-executable-with-selenium 참조)? –

답변

0

그것은 그냥 다른 브라우저 벤더의 셀레늄에 사용할 수있는 다른 드라이버처럼 때문에 성능 문제입니다, Mozilla가 실행됩니다 실행 호출 geckodriver를 출시했습니다 브라우저 옆에. 수출 IDE 테스트를 실행하려면

System.setProperty("webdriver.gecko.driver","path/to downloaded/geckodriver.exe"); 
DesiredCapabilities capabilities = DesiredCapabilities.firefox(); 
capabilities.setCapability("marionette", true); 
WebDriver driver = new FirefoxDriver(capabilities); 

//Now do your further stuff with Firefox driver 
0

을 확인하십시오

당신은 다음과 파이어 폭스 드라이버를 사용하여 테스트 케이스를 실행하는 최신 실행 geckodriver를 다운로드하고 시스템 속성으로 컴퓨터에서이 다운로드 경로를 설정해야 leg-rc 패키지는 클래스 경로에 있습니다.

이는 Selenium 3 변경 로그에 언급되어 있습니다. change log을 참조하십시오.