私はセレンが初めてです。
これが私がしたことです:cmdプロンプトでスタンドアロンのセレンサーバーを起動しました。
webDriverWay() と seleniumWay() の両方で、以下のコードを実行しました。以下のようなエラーが発生します。どちらの場合も、私は得る
私のテストコード:
static String baseUrl= "http:\\google.com" ;
public static void main(String[] args) throws MalformedURLException {
//webDriverWay();
seleniumWay();
}
private static void webDriverWay() throws MalformedURLException {
URL url = new URL("http://127.0.0.1:4444/wd/hub"); //Could be your remote VM where you to run your tests
DesiredCapabilities capabilities;
capabilities = DesiredCapabilities.firefox();
//You can test multiple type of browser
//capabilities = DesiredCapabilities.internetExplorer();
WebDriver driver = new RemoteWebDriver(url, capabilities);
//Open the web site
driver.get(baseUrl);
//Type Search Term
(driver.findElement(By.name("q"))).sendKeys("Test Search Query");
//Click submit button
(driver.findElement(By.name("btnG"))).click();
}
static void seleniumWay()
{
Selenium sel = new DefaultSelenium("localhost", 4444, "*firefox", baseUrl);
CommandExecutor executor = new SeleneseCommandExecutor(sel);
DesiredCapabilities dc = new DesiredCapabilities();
WebDriver browser = new RemoteWebDriver(executor, dc);
browser.get(baseUrl);
WebElement input = browser.findElement(By.name("q"));
input.sendKeys("Selenium");
}
コンソールの例外:
Exception in thread "main" org.openqa.selenium.WebDriverException: Could not start Selenium session: org.openqa.grid.common.exception.GridException: Error forwarding the new session Empty pool of VM for setup {browserName=*safari}
Command duration or timeout: 61 milliseconds
Build info: version: '2.26.0', revision: '18040', time: '2012-11-02 09:44:45'
System info: os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2', java.version: '1.7.0_09'
Driver info: driver.version: RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:531)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:215)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
何か不足している場合はお知らせください。