- Unpack Selenium jar. (User JRE jar.exe utility)
- Open selenium-browserbot.js file.
- Search for function 'IEBrowserBot.prototype.modifyWindowToRecordPopUpDialogs'"
- Add following codes at the begning of this function
if(win.showModalDialog)
{
if (typeof(win.top.g_selRetVar) == 'undefined')
win.top.g_selRetVar = null;
win.top._UTL_SetSelRetVar = function (val){
win.top.g_selRetVar = val;
win.top.status = win.top.g_selRetVar + ' is returned from child';
};
win.showModalDialog = function( sURL, vArguments, sFeatures)
{
if ((typeof(win.top.g_selRetVar) != 'undefined') && (win.top.g_selRetVar!=null))
{
var temp = win.top.g_selRetVar;
win.top.g_selRetVar = null;
return temp;
}
try {
win.top.open (sURL, 'modal', sFeatures);
} catch(e){ win.showModalDialog(sURL, vArguments, sFeatures); }
};
}
if(win.close)
{
win.attachEvent('onbeforeunload', function _selhandler()
{
if(win.opener && win.opener._UTL_SetSelRetVar)
win.opener._UTL_SetSelRetVar(win.returnValue);
});
}
- Pack the jar again. (User JRE jar.exe utility)
Handling Modal windows
Download modified Selenium RC
Hi
ReplyDeleteCan i use with Selenium selenium-server-2.0a4 alpha version.
I am also not finding selenium.jar in selenium-server-2.0a4 alpha version.
Can you know which version i can implement you fix
Thanks
Ravi
Hello,
ReplyDeleteCould you be more specific "Unpack Selenium jar".
I can't find file selenium-browserbot.js inside any jar.
I am using selenium-server-1.0.3 and Java Client Driver.
Thanks
Hadrian Polewczak
Hi,
ReplyDeleteI still have problem with modal window.
In my webpage it is possible to turn off modal window for test purposes, but if I run script to show new window (no modal), I am not able to type text and click find button inside this recently opened window(Element //*[@id=\"quick_pt_text\"] not found).
Is there any possibility to programatically switch to new window, type something inside this window and come back to main window.
selenium.open("http://devel.lp/main.pl");
selenium.runScript("open_find(selected_tab)");
Thread.sleep(5000);
// now I try to type sth inside opened window
selenium.typeKeys("//*[@id=\"quick_pt_text\"]", "sth");
selenium.click("//*[@id=\"find_btn\"]");
Thread.sleep(5000);
assertTrue(true);
PS
Sorry for previous comment, I have already find selenium-browserbot.js
Hadrian Polewczak
Hi,
ReplyDeleteI add the code above in the selenium-browserbot.js in my selenium-server.jar.
However my test isn't working. At the beginning of the test, it is like "suspended". I can't open the url I want...
What's wrong ?
Modified Selenium Server has been added in the post.
ReplyDeleteIt's already not working.
ReplyDeleteI open the jar to see the code and I don't find any added code in the BrowserBot.prototype._modifyWindow method in selenium-browserbot.js file. Is it normal ?
Modification is done in IEBrowserBot.prototype.modifyWindowToRecordPopUpDialogs function.
ReplyDeletePlease verify it again this should work.
Hi Amit,
ReplyDeleteI am a recent user of selenium and I currently have to automate on IE browser for my current project. I have attached your updated jar to my webdriver project but I am not sure how to use this change to interact with a modal window that is currently blocking me from moving forward. Can you provide me with some coding example of how to use your update, I am using java/groovy with webdriver.
Thanks in advance
Hi Amit,
ReplyDeleteI am a recent user of selenium and I currently have to automate on IE browser for my current project. I have attached your updated jar to my webdriver project but I am not sure how to use this change to interact with a modal window that is currently blocking me from moving forward. Can you provide me with some coding example of how to use your update, I am using java/groovy with webdriver.
Thanks in advance
Hi Amit,
ReplyDeleteFirstly, let me thank you for sharing such wealth of information with the world.
I just have one query, will this function work in SeleniumRC 2.20 version
Warm Regards
Prashant
Prashant,
ReplyDeleteWith no or little tweek you can use this code in any SEleniumRC version.
i have changed the JAR as mentioned, but it is not able to get the modal window id, when i used
ReplyDeleteselenium
.getEval("{var windowId; for(var x in selenium.browserbot.openedWindows ) {windowId=x;} }")
pls help.