7

私はwebdriverの初心者で、助けが必要です。

WindowsXPでFFv7.0.1を搭載したSelenium2.2.0を使用しています

IEでJavaスクリプトを正常に記録および再生できましたが、FFで同じスクリプトを実行しようとすると、次のエラーメッセージが表示されます。

45000ミリ秒後にポート7055でホスト127.0.0.1に接続できません

Firefoxのバージョンを3.6にダウングレードすると、スクリプトは正常に機能するが、ダウングレードには熱心ではないということをたくさんの場所で読んだことがあります。誰かが私が間違っていることを教えてもらえますか?

package hisScripts;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;


public class WebdriverTest_1 {
private WebDriver driver;
private String baseUrl;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
    driver = new FirefoxDriver();
    //driver=new InternetExplorerDriver();
    baseUrl = "https://**********/";
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}

@Test
public void testUntitled() throws Exception {
    driver.get(baseUrl + "/");
    driver.findElement(By.xpath("//a[contains(text(),'my profile')]")).click();
    driver.findElement(By.xpath("//a[contains(text(),'about the service')]")).click();
    driver.findElement(By.xpath("//a[contains(text(),'contact us')]")).click();
    driver.findElement(By.xpath("//a[contains(text(),'help')]")).click();
    driver.findElement(By.xpath("//a[contains(text(),'home')]")).click();
    driver.findElement(By.xpath("//a[contains(text(),'logout')]")).click();

}

@After
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;
    }
}

}

4

2 に答える 2

8

使用しているセレンバージョンは非常に古いものです。Firefox10はv2.2ではサポートされていないと思います。最新は2.20です。

こちらの変更ログをご覧ください。ここでのメモから、Firefox 10のネイティブイベントはv2.19.0以降でサポートされていました。つまり、Firefox10をサポートするには2.19以降が必要になります。

于 2012-04-04T21:33:43.750 に答える
-1

この問題は、FirefoxバージョンとSeleniumjarファイルバージョンの互換性が原因です。問題を解決できる最新のSeleniumjarファイルを使用してください。

于 2016-03-04T17:16:36.573 に答える