SUBSCRIBE HERE TO GET POST UPDATES VIA EMAIL :

Delivered by FeedBurner

Working And Handling Multiple Windows In Selenium IDE

Working with the multiple windows in selenium IDE is not hard. Many selenium IDE users asking me for this question so let me try to explain it. You need to handle multiple windows many time of software applications regression testing using selenium IDE or any other tools. As you all knows, selenium IDE is not too much
powerful tool compared to others software testing tools like Webdriver, we have to handle few things manually in selenium IDE. Bellow given case is not fully recorded but updated few commands manually after recording. Let we look at the example.

New Test
CommandTargetValue
openhttp://www.bing.com
storeTitlei
openWindowhttps://www.google.com
pause5000
selectWindowGoogle
clickAndWaitcss=#gb_2 > span.gbts
storeTitlej
selectWindow${i}
clickAndWaitcss=#scpt1 > a
storeTitlei
selectWindow${j}
closej
selectWindow${i}
close


Handling Multiple Windows Test case explanation :
  • Selenium IDE will open 'bing' home page.
  • "storeTitle" will store bing home page title in variable 'i' to reuse it latter.
  • "openWindow" will open Google home page in new window and next pause command will pause selenium IDE for 5 secs.
  • Now we want to do some actions on newly opened window but we can not do any thing directly in new window. First of all we have to select new window. Next "selectWindow" command will select new window of Google home page.
  • Next command will click on Google's image link.
  • Now suppose i want to do some actions on parent 'bing' home page window. Before selecting parent window, "storeTitle" command will store latest title of page in variable 'j' so It will help selenium IDE to find this child window again when you want to perform some action on it.
  • Next commands will select parent 'bing' window and click on image link. (You can do more actions here.)
  • "selectWindow" command will select child window and next close command will close popup window.
  • Last 2 commands will do same thing on parent window.
Keep one thing in mind during navigating between multiple windows of software application - Before leaving current selected window, Always store latest window title of your current selected window and then select other windows. You can try above case with some other sites.

27 comments:

  1. I wonder what is the exact Difference between "open" and "openWindows"
    It takes a while for my page to load. Should I therefour use "openWindow" instead of "open" ? Perhaps there is a better way to wait as using "waitForPageToLoad" ?

    Kind regards,
    Enno Weerts

    ReplyDelete
    Replies
    1. Open command will open URL in current open window while openWindow command will open new window and then open URL in new window.

      Delete
    2. I am new selenium IDE I wrote the above script as it is, but when I run this script it gives error at " OpenWindow" command. please can anybody can help me?
      This is Error

      [warn] Opening window '_blank', which is not a real window name. Randomizing target to be: selenium_blank3295
      [error] Unexpected Exception: TypeError: result is null.

      Delete
    3. @Hafiz Anas,I also having cases like you :(((

      Delete
    4. First you have to use Open Command to open current URL and save the title of current URL by using getTitle in any variable so that next time when you want to come back from new window to this window. This variable you can use as a referrence. Now If use openWindow command to open new URL and perform actions by using selectWindow

      Delete
  2. Very Good explanation. Thanks! for your efforts.

    ReplyDelete
  3. I am facing some problem with webpage dialog. As i am unable to open it and for webpage dialog id/name/title also not available. Could plz help me to solve this problem.

    ReplyDelete
  4. Could plz help me to solve this error - it will come when openWindow https://www.google.com command execute, [error] Unexpected Exception: TypeError: result is null. fileName -> chrome://selenium-ide/content/recorder.js, lineNumber -> 74, columnNumber -> 0

    ReplyDelete
    Replies
    1. Check for browser popup is allowed or not. If not allowed then allow it first any retry test.

      Delete
  5. After Executing openWindow=https://www.google.com , it show [warn] Opening window '_blank', which is not a real window name. Randomizing target to be: selenium_blank49198
    [error] Unexpected Exception: TypeError: result is null.

    ReplyDelete
    Replies
    1. Please check the Base URL... Keep the Base URL as https://www.google.com
      Else, set the Target as "/".
      and Value as https://www.google.com.

      Delete
    2. If I keep Target as "/" when working with single window, '[warn] Opening window '_blank', which is not a real window name. Randomizing target to be: selenium_blank49198' does not appear.
      But while working with multiple windows, if I keep Target as "/" for second window, it always open base URL else, if keep Target as "https://www.google.com" it gives this warning.
      How to handle '[warn] Opening window '_blank', which is not a real window name...' while working with multiple windows?

      Delete
    3. Hi Gital, I also faced that error and my solution is: open Options > Contents > Pop-ups > uncheck Block pop-up windows box. Hope this help.

      Delete
  6. Whether E-Mail subscription is chargeable???

    ReplyDelete
    Replies
    1. Everything Including email subscription Is free on this blog

      Delete
    2. I got below error ....

      [info] Executing: |openWindow | https://www.google.com | |
      [warn] Opening window '_blank', which is not a real window name. Randomizing target to be: selenium_blank62911
      [error] Unexpected Exception: TypeError: result is null.

      Delete
  7. Hi there,

    One query, In the third last command we are closing "i". and then again we are selecting "i".

    Please confirm how we do that as once we are closing "i" and again selecting it.

    Is store title changes the content dynamically.

    Please correct me if I'm missing anything here!

    Thanks,
    Ashu

    ReplyDelete
    Replies
    1. That was type error. Written i at place of j. Now It Is corrected. Thanks.

      Delete
  8. This comment has been removed by the author.

    ReplyDelete
  9. [error] Element css=#gb_g > span.gbts not found

    ReplyDelete
    Replies
    1. Hi, replaces "link=Imágenes" by "css=#gb_g > span.gbts" and working properly

      excellent post!!

      Delete
  10. Hi,

    When i was trying the above commands, i encountered a problem in 8th command i.e "selectWindow ${i}". The error message displayed in the selenium log is "[error] Could not find window with title Bing". How can i overcome this error?

    ReplyDelete
  11. Hi! :)

    Our current set up is when a link is ticked, the link opens on a new tab, instead of window. Does Selenium IDE have a command for automating this action? Thank you. :)

    ReplyDelete
  12. I am new Selenium IDE I wrote the above script as it is but it gives error when it reaches on " openwindow" command. please can anybody help me out?
    Error Message

    [warn] Opening window '_blank', which is not a real window name. Randomizing target to be: selenium_blank3295
    [error] Unexpected Exception: TypeError: result is null.

    ReplyDelete
    Replies
    1. open Options > Contents > Pop-ups > uncheck Block pop-up windows box. Hope this help.

      Delete
  13. Hi, I am getting the below error when the above script is run:
    [error] Unexpected Exception: TypeError: result is null.
    Can you advice where i am stuck?

    ReplyDelete