如何使用selenium切换窗口并验证选项卡

时间:2017-08-25 12:58:02

标签: java selenium selenium-webdriver

在我的旅行联盟网站上,我每次都打开4个标签。我写了一个测试用例,我切换窗口并做了一些操作。但我找到的方法可以验证我预期的所有窗口都是打开的,条件是对另一个明智的我感到满意,我将返回测试用例。

这是我的代码,我切换窗口并在布尔条件下执行操作,但我没有得到所有标签完全打开的方式

for (String windows : wd.getWindowHandles()) {

    wd.switchTo().window(windows);

    Reporter.log(wd.getCurrentUrl());
    if (wd.getCurrentUrl().startsWith("https://www.airbnb.com")) {

        Reporter.log("Great Airbnb Leave Behind is Opening :" + wd.getCurrentUrl());
        Reporter.log("Airbnb &sharedid=3&iratid=9627& Passed on Parameter :"
                + wd.getCurrentUrl().contains("&sharedid=3&iratid=9627&"));
    }
    if (wd.getCurrentUrl().startsWith("http://local.summerrentals2017.com")) {

        Reporter.log("Main Site Listing Page :" + wd.getCurrentUrl());
    }
    if (wd.getCurrentUrl().startsWith("http://a.cdn.intentmedia.net/a1/exit_unit.html")) {

        Reporter.log("Intent media Is opend here is Opening :" + wd.getCurrentUrl());

    }
}

假设http://local.summerrentals2017.com& http://a.cdn.intentmedia.net/a1/exit_unit.html如果这两个网站打开我可以做一些操作。但我想确保所有两个标签打开..

1 个答案:

答案 0 :(得分:0)

不确定这是不是你的意思,但是......开始时设置某种旗帜怎么样?

32-bit Service-UUID: 0x0000D1DC
相关问题