Tuesday 15 May 2012

selenium - Robot Framework verify a new browser tab was opened -


For some web links on our page, there are external links that instruct the user to say Facebook and Twitter. Use the link HMTL tag target = "_ blank" to open a new browser tab on our Twitter page.

I want to verify 1. New browser tab is open, 2. Focus on it and 3. Validate the page elements in the new browser tab. Part # 3 will be quite easy, once I focus on it Work # 1 and # 2 However, I can not understand, nor can I find anyone talking about this.

Use of Selenium Library (WebDriver)

does not support selenium tabs ( From June 2013, Selenium 2.33.0) and always opens a new window instead if you have a new tab open in your exam, you will be happy.

He said, if it opens a new window correctly, then use it. Choose

  window. Url = https: //twitter.com/expectedPage   

In my WebDriver (2.33.0) code, hopefully it will help a little bit of the problems that you describe Where are they where my robot knowledge starts to fall. @Test Public Zero targetblockink test () {// Load website and make sure only one window opened driver.get (file ( "TargetBlankLinkTest.html")); AssertEquals (1, driver.getWindowHandles (). Size ()); // click link and insist that a new window has been opened by driver.findElement (By.linkText ("Follow us on Twitter!")). Click (); Set up & lt; String & gt; Windowhands = driver.getwondhoundle (); Repeat the emphasis (2, windowhandlasize); // Switch to the new window and whatever you want // (Java does not have the functionality of the switch window, which can be selected by the URL. // I can write it, but instead using this trick (String handle: windowhands) {If (handle! = Driver.getWindowHandle ()) {driver.switchTo () Window (handle); }} AssertThat (driver.getCurrentUrl), contains the string ("twitter.com")); }

No comments:

Post a Comment