2017-08-25 5 views
0

私の旅行のアフィリエイトサイトでは、毎回4つのタブを開きます。私はウィンドウを切り替えていくつかの操作を行うテストケースを作成します。私の予想されるすべてのウィンドウが開いていて、条件が満たされていると私はもう一度賢明なテストケースを返します。セレンを使用してウィンドウを切り替える方法と確認するタブ

これは、すべてのタブが開いて、この2つのサイトは私が行うことができれば完璧

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を想定開いていることをブール条件はしかし、私はどのような方法が届かない場合、私は、ウィンドウを切り替えて操作を行うに私のコードですしかし、私は2つのタブがすべて開かれていることを確認したい。

答えて

0

これはあなたが意味するものなのかどうかは分かりませんが、冒頭に何らかのフラグを設定するのはどうですか?

int counter = 0; 
Set<String> handles = wd.getWindowHandles(); 
for (String windows : handles) { 

    wd.switchTo().window(windows); 

    Reporter.log(wd.getCurrentUrl()); 
    if (wd.getCurrentUrl().startsWith("https://www.airbnb.com")) { 
     counter++; 
     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")) { 
     counter++; 
     Reporter.log("Main Site Listing Page :" + wd.getCurrentUrl()); 
    } 
    if (wd.getCurrentUrl().startsWith("http://a.cdn.intentmedia.net/a1/exit_unit.html")) { 
     counter++; 
     Reporter.log("Intent media Is opend here is Opening :" + wd.getCurrentUrl()); 

    } 
} 
[...] 
if (counter == handles.size()) { 
    //do something 
} 
+0

すべてのリンクが開いていることを確認したい – zsbappa

+0

「すべて」とはどういう意味ですか?そこには3つの「IF」があります。番号は静的ですか? – Pijotrek

+0

はいすべてのリンクは静的です – zsbappa

関連する問題