Problem with Pop-up Windows using Selenium

前提是你 提交于 2020-01-14 04:16:05

问题


I'm new to the testing world, so my question might seem a lil' bit too naive and stupid. At risk of looking/sounding stupid, my question is this:

I've been trying to test the contents in a pop-up window on my company's web app. I've figured out how to detect the pop-up window for now, but i can't get selenium to 'click' on the link inside of that pop-up window. there are multiple pop-ups in this web app so it's really difficult for a newbie like to create a test case.

I tried the click, clickAndWait, mouseDown and mouseKey as an option but it is still not working. can somebody guide me through this?

TIA, Angela


回答1:


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.




回答2:


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..........




回答3:


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).




回答4:


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.




回答5:


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/



来源:https://stackoverflow.com/questions/1886509/problem-with-pop-up-windows-using-selenium

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