Thursday, August 18, 2011

Selenium Window target = "_blank" issue

For example if you have a link like



Upon click mylink , the url loads into a new window ,  to do some operations in newly opened window it is painful to identify the windowName ..etc

And the solution for that is
selenium.open("/test.html");
selenium.getEval("this.page().findElement(\"link=mylink with target _blank\").target='maddys_window'");
selenium..getEval("selenium.browserbot.getCurrentWindow().open('', 'maddys_window')");
selenium.click("link=mylink with target _blank");
Thread.sleep(2000);
selenium.selectWindow("maddys_window");
selenium.windowFocus();
......
......
selenium.close(); //to close maddys_window
selenium.selectWindow("null");  //to get focus to main window
....
...

No comments: