The following worked for me with a form with the target = "_ blank" attribute, which sends a POST request to a new window:
// Open the action in a new empty window selenium.getEval("this.page().findElement(\"//form[@id='myForm']\").target='my_window'"); selenium.getEval("selenium.browserbot.getCurrentWindow().open('', 'my_window')"); //The contents load in the previously opened window selenium.click("//form[@id='myForm']//input[@value='Submit']"); Thread.sleep(2000); //Focus in the new window selenium.selectWindow("my_window"); selenium.windowFocus(); /* .. Do something - ie: assertTrue(.........); */ //Close the window and back to the main one selenium.close(); selenium.selectWindow(null); selenium.windowFocus();
The html code will look like:
<form id="myForm" action="/myAction.do" target="_blank"> <input type="text" name="myText" value="some text"/> <input type="submit" value="Save"/> </form>
Gotxi source share