1

我正在尝试在 IE 中使用 Web 驱动程序运行我的脚本。它正在启动浏览器但不传递 URL。打开浏览器时,它会给出一条消息“这是 WebDriver 服务器的初始起始页”。我正在使用 IE 9。有人知道这里发生了什么吗?

driver = new driver InternetExplorerDriver();
driver.manage().window().implicitlyWait(30, TimeUnit, SECONDS);
driver.navigate().to("URL")
4

1 回答 1

0

这是我的做法,但我不使用 Selenium RC ......相反,我使用没有 Selenium 服务器的“纯”网络驱动程序:

public static void initializeBrowser( String type ) {
    if ( type.equalsIgnoreCase( "firefox" ) ) {
        driver = new FirefoxDriver();
    } else if ( type.equalsIgnoreCase( "ie" ) ) {
        driver = new InternetExplorerDriver();
    }
    driver.manage().timeouts().implicitlyWait( 10000, TimeUnit.MILLISECONDS );
    driver.manage().window().setPosition(new Point(200, 10));
    driver.manage().window().setSize(new Dimension(1200, 800));
}

我这样称呼它:

@Test
public void testWithPageObject() {      
    driver.get("http://www.google.com");
    GoogleSearchPage gs = new GoogleSearchPage();
    gs.setSearchString( searchString );
    selectInGoogleDropdown( ddMatch );  
    gs.clickSearchButton();
    waitTimer(3, 1000);
    clickElementWithJSE( "gbqlt" ); //click Google logo
    System.out.println("Done with test.");
}

关于此方法,您会注意到的一件事是,您调用转到 URL 的方法与使用 Selenium RC 服务器时不同。请参阅链接(上方)以查看我的整个源代码。

于 2012-12-07T19:20:22.090 回答