2012-01-19 3 views
0

이 사이트의 코드 (http://darrellgrainger.blogspot.com/2011/02/using-selenium-20-with-webdriver-and.html)를 사용하여 Selenium을 실행합니다. 사파리 5. 코드의 테스트는 다음과 같이 진행됩니다 Selenium을 사용하여 Safari를 테스트하면 GridException이 발생합니다.

Selenium sel = new DefaultSelenium("localhost", 4444, "*safari", baseURL); 
CommandExecutor executor = new SeleneseCommandExecutor(sel); 
DesiredCapabilities dc = new DesiredCapabilities(); 
WebDriver browser = new RemoteWebDriver(executor, dc); 

browser.get("http://www.google.com"); 
WebElement input = browser.findElement(By.name("q")); 
input.sendKeys("Selenium"); 

그래서 나는 로컬 호스트 시스템에서 셀레늄 서버 독립형 버전을 시작하고 난 셀레늄 허브에 테스트 노드를 (또한 로컬 호스트)에 등록합니다. 그런 다음 테스트를 시작합니다. org.openqa.selenium.WebDriverException : 셀레늄 세션을 시작할 수 없습니다. org % 2Eopenqa % 2Egrid % 2Ecommon % 2Eexception % 2EGridException % 3A + Error + forwarding + new + session + The + server + returned + an + 오류 + % 3A +

어떤 오류가 발생했는지 알 수 없습니다. 콘솔에 서버 출력이 없습니다. 누구 아이디어가 있습니까? 나는 Selenium의 최신 버전 (2.17.0)을 사용했다.

편집 : 방금 사파리 대신 "파이어 폭스"를 시도하고 동일한 예외를 출력합니다. 그래서 실제로 그것은 사파리의 잘못이 아닙니다. 어쩌면 그리드를 통해 셀렌 1 코드를 실행하는 데 문제가 있습니까?

답변

0

이 시도 :

DesiredCapabilities capabilities = new DesiredCapabilities(); 
capabilities.setBrowserName("safari"); 
capabilities.setJavascriptEnabled(true); 
CommandExecutor executor = new SeleneseCommandExecutor(new URL("http://localhost:5555/"), new URL("http://www.google.com/"), capabilities); 
WebDriver driver = new RemoteWebDriver(executor, capabilities); 
driver.get("http://google.com"); 

이 DefaultSelenium 객체를 생성하지 마십시오. 위 코드는 Safari 브라우저에서 잘 작동합니다.

+0

이렇게하면 org.openqa.selenium.WebDriverException : 셀렌 세션을 시작할 수 없습니다. org % 2Eopenqa % 2Egrid % 2Ecommon % 2Eexception % 2EGridException % 3A + Error + forwarding + new + session + can not + + % 3A + % 7BrowserName % 3D % 2Asafari % 7D 어떻게 테스트 컴퓨터를 허브에 등록합니까? "-browser browserName = safari"를 사용했습니다. – tester

+0

Grid 노드를 만들 때 브라우저 이름을 지정하지 마십시오. –

관련 문제