1

会議に4つの異なるロールとしてログインするために、私が書いたロールごとに

System.setProperty("webdriver.firefox.profile", "default");
FirefoxDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(120, TimeUnit.SECONDS);
driver.get("link to the conference");

どうすれば Firefox ウィンドウを切り替えることができますか? Windows のタイトルは同じです。ありがとう

4

2 に答える 2

1
public TasksWindow OpenInWindow() {
    WebDriverWait wait = new WebDriverWait(Driver.driver, TimeSpan.FromSeconds(10));
    wait.IgnoreExceptionTypes(typeof(AssertionException));
    String windowName = wait.Until<String>((d) => {
        this.windowSwitcher.Click();

        if (d.WindowHandles.Count != 2) // this means you are waiting till the number of windows equals 2 {
            return null;
        }

        return d.WindowHandles[1]; // this means you are changing to the second window (from [0] to [1])
    });

    return new TasksWindow(windowName);
}

これはc#で動作します

于 2012-08-23T23:47:19.160 に答える
1

必要に応じて変更できる場合は、このコードを使用してウィンドウ間を移動できます

//All the window handles will be returned and u can use window handle to switch between the windows

Set<String> windows = getWebDriver().getWindowHandles();

    Iterator<String> window = windows.iterator();


    while( window.hasNext() ) {

        getWebDriver().switchTo().window( window.next() );

    }
于 2012-08-24T12:33:42.633 に答える