Problem with Pop-up Windows using Selenium

馋奶兔 提交于 2019-12-08 17:27:34

When the popup appears you will need to move the context of the script over to the window.

You can do this by using the selectWindow | window_ID_from_the_link and then do the clicking.

If that doesn't work you may need to use the openWindow command to create the popup and then start testing against that.

Use getConfirmation/getassert/getprompt according to the type of the pop up you use .....By default they will be clicked with ok option by the server and you have to consume the message from the pop up for the other selenium commands to work correctly............. The above suggestion is given from my experience in working with selenium RC used with perl..........

Perhaps you can try the FireFox Plugin. You can click through your application and record your steps. After recording the steps you can easily save it as some sort of file or unittest.

I'm not sure about the command you should use for the popups, maybe the firefox plugin will help in this manner (it will create your commands).

If you created the popup with a div tag, U can use following code to stop the selenium server until the popup opens.

int second = 0;
while(!selenium.IsElementPresent(mylink))
{
if(second >= 5) 
    break;
Thread.Sleep(1000);
second++;
}

After a popup opens, Now you can click on any link inside the popup.You have to use the below code.

selenium.click("id=popup_link"); (popup_link is the id of the link present on the popup)

Good Luck.

Not sure if this is what you are looking for, but if you want to click on something specific that Selenium is not able to handle - like browser pop-ups or other pop-ups, you can use Sikuli Script. Sikuli does an image comparison and clicks on the same - this is very powerful.

Here is the link: http://www.sikuli.org/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!