I got problem with Selenium on my website.
Scenario: 1. Selenium login to site 2. Selenium press on button 3. Window with confirmation appears (example: http://i.piccy.info/i5/17/00/1760017/popup.jpg) 4. But after this, Selenium just hangs. "Selenium Remote Control" also hangs and I can't even activate it. In Selenium RC logs I got: "Command request: click[ChooseClient, on session ...]" If I manualy select any option in popup, everything continue to work correct.
As I see, problem in click. For some reason click not over after popup appears.
Selenium code:
selenium.click("link=Home");
selenium.waitForPageToLoad("30000");
selenium.click("btnCReportAdd");
selenium.waitForPageToLoad("30000");
selenium.chooseOkOnNextConfirmation();
selenium.click("chooseClient");
assertEquals( seleni开发者_Python百科um.getConfirmation(), "WARNING - any changes made will not be saved." );
selenium.isConfirmationPresent());
selenium.waitForPopUp("popup", "30000");
And this is button code:
GB.common.navigationwarning.init("WARNING - any changes made will not be saved.");First of all you should not use a message box (alerts) in a Web Environment. Why don’t you replace it with a modal pop-up (Html Version) ? You can find lots of example if you google it(also Jquery got an Plug-in for that)
Selenium and any web drivers can interact very well with modal pop-up (you can use the CSS or class attribute to understand if a pop up is visible or not) but they can’t interact with alerts message box
I just ran into this problem myself using Selenium 2.41, FF 28.
Adding this line before clicking the element to bring up the popup fixed it for me:
((JavascriptExecutor)driver).executeScript("window.showModalDialog = function( sURL,vArguments, sFeatures) { window.open(sURL, 'modal', sFeatures); }");
source
精彩评论