How to handle Pop Up Messages

4,539 views
Skip to first unread message

Amita Singh

unread,
Mar 17, 2012, 2:17:17 PM3/17/12
to robotframework-users
Hi All,

In my Automation project , I need to handle POP up Messages during negative scenarios - Form Validation Alert Message .  Like , When I am entering in text field more than supported characters , a pop up message comes up asking to correct the value , am not sure how to handle this . It's coming more when I am trying to implement negative scenarios during Automation our GUI .Is there any keyword in RF which can handle this ?

Kindly provide your expert opinion with example.

Thanks a lot for the help.

Regards,
Amita

antonio III cabreira

unread,
Mar 19, 2012, 5:53:20 AM3/19/12
to sake...@gmail.com, robotframework-users
Amita,

Try to get the XPath's of the pop-ups you wish to verify. Then verify that the xpath is in that page by using the keyword Page Should Contain Element. Hope that works for you

Thanks! 

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To post to this group, send email to robotframe...@googlegroups.com.
To unsubscribe from this group, send email to robotframework-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.

Amita Singh

unread,
Mar 19, 2012, 4:15:26 PM3/19/12
to antonio III cabreira, robotframework-users
Hi Antonio.

Thanks so much for the reply . Please excuse me for not mentioning it before, problem is I am not able to get the xpath of the pop-up. I think it's coming in such a way that the Selenium is not able to recognize it's xpath.

I have attached screenshot for your reference.

Could you please provide your opinion ?

Thanks for the help.
Amita
popup.jpg

sandeep s

unread,
Mar 20, 2012, 1:24:55 AM3/20/12
to sake...@gmail.com, antonio III cabreira, robotframework-users
Had a similar pop up with our app as well and wasnt that successful, as it calls a flash/flex based pop..Did you tried to record the same with selenium ide..? If ide does the identification then you can possibly do something...
what we did was to use Autoit to hit the OK and continue, even i tried integrating sikuli with our framework and was successful..by the way i am not using robot ..its a customized one for our needs..but bottom line its selenium's way of identifying notng to do with the framework..

Good day

Sandi

antonio III cabreira

unread,
Mar 20, 2012, 3:50:26 AM3/20/12
to sandeep s, sake...@gmail.com, robotframework-users
I haven't had any experience interacting with flash/flex pop-ups. In my case, the Selenium IDE recognizes the popups. I am using Firebug, an addon of Firefox, in creating xpaths. Maybe that could help.

Amita Singh

unread,
Mar 20, 2012, 12:54:46 PM3/20/12
to antonio III cabreira, sandeep s, robotframework-users
Hi,

In our application , we are not able to record the pop up from Selenium IDE as well. Could you please what should I do next . As Sandi mentioned that he tried with the Autoit to hit the OK and continue , is it possible to provide some more details and useful link for the same.

Will be very thankful in resolving this issue.

Thanks again for the reply

Amita

Amita Singh

unread,
Mar 20, 2012, 1:02:16 PM3/20/12
to antonio III cabreira, sandeep s, robotframework-users
Missed to mention , am using Robot Framework for our Automation.

sandeep s

unread,
Mar 20, 2012, 1:51:44 PM3/20/12
to Amita Singh, antonio III cabreira, robotframework-users
Did you try/figure out what the pop is[flex/flash] ...you can inquire with the dev who have built it..If no info..then sikuli will be a great option for this..rather calling autoit...which i think...
If its a flex or flash compiling the selenium-flex api to your app and then calling the selenium keywords may also solve the issue..

thanks
sandi

Amita Singh

unread,
Mar 20, 2012, 4:02:11 PM3/20/12
to sandeep s, antonio III cabreira, robotframework-users
Hi Sandi,

It's a JAVA script pop up message . Could you please provide your help with example ?

Thanks & Regards,
Saket Singh

David

unread,
Mar 21, 2012, 2:09:25 AM3/21/12
to robotframework-users
Funny no one seems to have mentioned this in the thread, or I
overlooked it:

You first need to determine the type of popup it is (aside from
whether it is a Flex/Flash/Silverlight/Java applet popup). For non-
plugin web popups, there's only 2 types:

* browser based popup. This is typically invoked by javascript, but
the popup's UI is controlled and defined by your browser and OS. All
you can really do is check if popup exists and "click" yes/no/ok/
cancel. This popup can be detected and controlled by Selenium, I
assume even the IDE. But believe Firebug and other addons can't detect
the popup.

* AJAX popup - not really a popup, but a hidden web element that is
not shown until popup condition is true. I've seen this type of popup
at my workplace. If you're not smart, you may think it's a browser
popup when it's not. The normal popup handling Selenium commands won't
work against this type of popup because it's a web element. You handle
it same way as any other web element, clicking at it, etc. You just
need to find its locator via Firebug and other addons like any other
web element. One giveaway of this type of popup is that it doesn't
look like the normal browser popups, has its own style, etc.

I suspect your popup is a normal browser popup. In which case, the
SeleniumLibrary keywords:

* Alert Should Be Present
* Get Alert Message (use this only if you need the text in popup)

should be able to handle them.

In terms of pure Selenium RC commands, you'd be using isAlertPresent,
isConfirmationPresent, or isPromptPresent, depending on the type of
browser popup (yes/no, ok/cancel, or just ok). Most likely yours would
be an alert, not a confirmation or prompt.

On Mar 20, 1:02 pm, Amita Singh <sakes...@gmail.com> wrote:
> Hi Sandi,
>
> It's a JAVA script pop up message . Could you please provide your help with
> example ?
>
> Thanks & Regards,
> Saket Singh
>
>
>
>
>
>
>
> On Tue, Mar 20, 2012 at 12:51 PM, sandeep s <sandis...@gmail.com> wrote:
> > Did you try/figure out what the pop is[flex/flash] ...you can inquire with
> > the dev who have built it..If no info..then sikuli will be a great option
> > for this..rather calling autoit...which i think...
> > If its a flex or flash compiling the selenium-flex api to your app and
> > then calling the selenium keywords may also solve the issue..
>
> > thanks
> > sandi
> > automationsolution.blog.com
>
> > On Tue, Mar 20, 2012 at 10:32 PM, Amita Singh <sakes...@gmail.com> wrote:
>
> >> Missed to mention , am using Robot Framework for our Automation.
>
> >> On Tue, Mar 20, 2012 at 11:54 AM, Amita Singh <sakes...@gmail.com> wrote:
>
> >>> Hi,
>
> >>> In our application , we are not able to record the pop up from Selenium
> >>> IDE as well. Could you please what should I do next . As Sandi mentioned
> >>> that he tried with the Autoit to hit the OK and continue , is it possible
> >>> to provide some more details and useful link for the same.
>
> >>> Will be very thankful in resolving this issue.
>
> >>> Thanks again for the reply
>
> >>> Amita
>
> >>> On Tue, Mar 20, 2012 at 2:50 AM, antonio III cabreira <
> >>> antonio.cabreira...@gmail.com> wrote:
>
> >>>> I haven't had any experience interacting with flash/flex pop-ups. In my
> >>>> case, the Selenium IDE recognizes the popups. I am using Firebug, an addon
> >>>> of Firefox, in creating xpaths. Maybe that could help.
>
> >>>> On Tue, Mar 20, 2012 at 1:24 PM, sandeep s <sandis...@gmail.com> wrote:
>
> >>>>> Had a similar pop up with our app as well and wasnt that successful,
> >>>>> as it calls a flash/flex based pop..Did you tried to record the same with
> >>>>> selenium ide..? If ide does the identification then you can possibly do
> >>>>> something...
> >>>>> what we did was to use Autoit to hit the OK and continue, even i tried
> >>>>> integrating sikuli with our framework and was successful..by the way i am
> >>>>> not using robot ..its a customized one for our needs..but bottom line its
> >>>>> selenium's way of identifying notng to do with the framework..
>
> >>>>> Good day
>
> >>>>> Sandi
>
> >>>>> On Tue, Mar 20, 2012 at 1:45 AM, Amita Singh <sakes...@gmail.com>wrote:
>
> >>>>>> Hi Antonio.
>
> >>>>>> Thanks so much for the reply . Please excuse me for not mentioning it
> >>>>>> before, problem is I am not able to get the xpath of the pop-up. I think
> >>>>>> it's coming in such a way that the Selenium is not able to recognize it's
> >>>>>> xpath.
>
> >>>>>> I have attached screenshot for your reference.
>
> >>>>>> Could you please provide your opinion ?
>
> >>>>>> Thanks for the help.
> >>>>>> Amita
>
> >>>>>> On Mon, Mar 19, 2012 at 4:53 AM, antonio III cabreira <
> >>>>>> antonio.cabreira...@gmail.com> wrote:
>
> >>>>>>> Amita,
>
> >>>>>>> Try to get the XPath's of the pop-ups you wish to verify. Then
> >>>>>>> verify that the xpath is in that page by using the keyword Page Should
> >>>>>>> Contain Element. Hope that works for you
>
> >>>>>>> Thanks!
>

Amita Singh

unread,
Mar 21, 2012, 12:31:33 PM3/21/12
to mang...@gmail.com, robotframework-users
Hi David,

Thank you so much for the reply and help . To answer few of the questions , yes , it's a browser based pop up ( JAVA Script ) and as you said Firebug and other addons are not able to detect the popup.

I have used * Alert Should Be Present * Get Alert Message keywords in my script and its seems yo me that it's not doing like it should be and time out : Please find below the log snippet :

KEYWORD: SeleniumLibrary.Click Button css=input[type="submit"]
Documentation: Clicks a button identified by `locator`.
Start / End / Elapsed: 20120321 11:18:11.910 / 20120321 11:19:42.622 / 00:01:30.712
11:19:42.568 INFO Clicking button 'css=input[type="submit"]'.
11:19:42.568 DEBUG Parsed locator 'css=input[type="submit"]' to search expression 'css=input[type="submit"]'

11:19:42.621 FAIL Timed out after 90000.0ms
11:19:42.621 DEBUG Traceback (most recent call last): File "<string>", line 2, in click_button File "C:\Python27\lib\site-packages\SeleniumLibrary\runonfailure.py", line 40, in _run_on_failure_wrapper return method(*args, **kwargs) File "C:\Python27\lib\site-packages\SeleniumLibrary\click.py", line 82, in click_button self._click(self._parse_locator(locator, 'input'), dont_wait) File "C:\Python27\lib\site-packages\SeleniumLibrary\click.py", line 107, in _click dont_wait) File "C:\Python27\lib\site-packages\SeleniumLibrary\click.py", line 122, in _click_or_click_at self.wait_until_page_loaded() File "<string>", line 2, in wait_until_page_loaded File "C:\Python27\lib\site-packages\SeleniumLibrary\runonfailure.py", line 40, in _run_on_failure_wrapper return method(*args, **kwargs) File "C:\Python27\lib\site-packages\SeleniumLibrary\browser.py", line 191, in wait_until_page_loaded self._selenium.wait_for_page_to_load(timeout * 1000) File "C:\Python27\lib\site-packages\SeleniumLibrary\selenium.py", line 1751, in wait_for_page_to_load self.do_command("waitForPageToLoad", [timeout,]) File "C:\Python27\lib\site-packages\SeleniumLibrary\selenium.py", line 217, in do_command raise Exception, data


And here is the last line before the popup  of code snippet : ( After Clicking on submit button I am getting the pop up message )

    Click Button    css=input[type="submit"] 
    Alert Should Be Present
    Get Alert Message 
 
I am using Firefox version - 5.0

Please do provide your kind assistance and help David also do let me know if I am missed to provide any information form my end.

Thanks a lot for the help again

Amita Singh

unread,
Mar 21, 2012, 4:17:57 PM3/21/12
to mang...@gmail.com, robotframework-users
Hi David,

It's working fine with what you suggested.There was a missing thing in my code where after clicking on the button I was suppose to provide dont_wait keyword.

So now with the below script I am able to see the message as an alert from the pop-up.

Click Button    css=input[type="submit"]   Dont_Wait=2
Alert Should Be Present   Cow
Get Alert Message

But I have one doubt , If I am using only "Get Alert Message" ( commenting out  "Alert Should Be Present   Cow " ) . Then I am not able to see the alert message . Could you please provide your expert opinion?

Thank you so much for the help.

With Regards,
Message has been deleted
Message has been deleted
Message has been deleted

Kevin O.

unread,
Feb 8, 2013, 10:29:47 AM2/8/13
to robotframe...@googlegroups.com, mang...@gmail.com
We can't help if you don't provide more info. Best would be to attach the test log (or at least a screen capture of it). Not likely relevant here but always good to know ver of Selenium you are using and the version of the browser you're testing.
AFAIK Alert Should Be Present does not wait for a popup, it must already be present, so if there is a delay it can fail to recognize it because its not there yet.
Message has been deleted

Kevin O.

unread,
Feb 12, 2013, 4:59:29 PM2/12/13
to robotframe...@googlegroups.com, mang...@gmail.com
Thanks for posting the logs. Unfortunately they weren't much use :(
I saw "-- Webpage Dialog" in your screenshot and thought that might be the problem.
The problem seems to be how Selenium is handling alerts that belong to modal dialogs in IE.
Selenium seems to think the alert belongs to the parent not the child (child is the one who opened it)?
I could not find an issue against Se for this, but there are so many open ones!
You may be able to workaround the issue by selecting the parent of modal dialog webpage (can't use locator see note below), handling the alert, then selecting the dialog window again if necessary if you detect the browser to be IE.

Here is what I did to reproduce the issue:
Create main.html and modal.html and place in root of local webserver folder.
contents of main.html:
<html><head><title>modal opener</title></head><body><button onclick="window.showModalDialog('modal.html')" id="btnModal">Open Modal</button></body></html>
contents of modal.html:
<html><head></head><body onload="document.title = 'modal windows are ugly'"><button id="btnAlert" type="button" onclick="alert('who do I belong to?')">Click Me!</button></body></html>

Ran this test:

    Open Browser    http://localhost/main.html    ie
    Comment    Click Button    id=btnModal    # works in IE but in FF, Se never returns until dialog is closed :(
    Execute Javascript    setTimeout(function(){window.showModalDialog('modal.html')},200);    # workaround to make script function in both FF & IE
    Sleep    1s
    Select Window    title=modal windows are ugly
    Click Button    id=btnAlert
    Comment    Select Window    # fails in IE unless you uncomment this
    ${msg}=    Get Alert Message
    Select Window    title=modal windows are ugly    # have to select the modal dialog again to interact with it if you selected another window
    Capture Page Screenshot

This test fails, but will pass if you change it to Firefox -- I woud say this is a bug in IEDriverServer not Selenium2Library or the Selenium core.

Note that if you change the onload of main.html to window.open instead of window.showModalDialog, Se does not have a problem "seeing" the alert.
Also important to note that if you add a locator to the Select Window that is commented out, the script will fail on that line. This is because S2L tries to fetch the existing windows via JS and encounters a WebDriverException: Message: u'Modal dialog present' .

This is yet another reason developers should avoid showModalDialog and use jQuery dialogs instead. 

Environment: Se 2.21.3, S2L 1.1, RF 2.76, Py 2.7.3 (32-bit), IE8, FF10, Windows 7 (64-bit)

Good Luck,
Kevin

David Luu

unread,
Apr 7, 2016, 7:57:02 PM4/7/16
to Sergio Alejandro Lopez Ruiz, robotframework-users
Have you read this blog post? http://ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/

One should consider the last part of the post title, but if you must proceed anyways, adapt the technique of that post for RF, which means using the RF HTTP request libraries to download the file, or code that part yourself in Python, etc. for RF as custom library.

On Thu, Apr 7, 2016 at 2:54 PM, Sergio Alejandro Lopez Ruiz <sergio...@gmail.com> wrote:
Hi All!

I read the questions and the answers and I'd like to know if someone can help me with my problem.

The principal problem that I have is download a file from a emergent window using the keywords that robotframework provides me, because this keywords only works with the GUI and the browser, the windows to download or upload a document are property of the OS that you are using, and I can't take control of them.

I tried to find a solution for this and found a library for the framework (AutoIt) that allows me control the windows of the OS, but for one reason that I don't have clear yet I can't manipulate the buttons in the download window only in the upload window.

After that I tried to configure the browser that I used for the tests (firefox) to accept all the downloads of specific type of document and don't have to manipulate the download window, but the command "open browser" with a profile as a parameter doesn't work, the command opens the browser but no with the modification to accept the downloads.

This is basically my principal problem, had you ever been in a similar situation or work with something similar? Is there anything that you can provide me to go on with this blocker?


Sergio Alejandro Lopez Ruiz

unread,
Apr 8, 2016, 1:03:30 AM4/8/16
to robotframework-users, mang...@gmail.com

Tatu Aalto

unread,
Apr 8, 2016, 1:52:53 AM4/8/16
to sergio...@gmail.com, David Luu, robotframework-users

Ugh

Before doing the download, one should really consider is it really necessary. If one is only going to download the file and not perform any checks on the downloaded file, perhaps it's not worth of effort to download the file in first place.

If one really needs to download the file, at least I have to do such thing, most of the time, the actual download is not interesting. For me it doesn't matter how the file is downloaded, only the file content matters. I don't download the file by using the browser, because it is very annoying for all the reason you did explain. Instead I use cURL to download the file for me and then I perform checking for the content in the file. If I would live in the *nix world, I would use wget.

Lately I have been thinking to move that cURL logic to a library keyword and use requests[1] to download the file. This is because setting all the header, session ID and so on is really hard to debug when something doesn't work. Other than, cURL works really well and the debugging problem is a small problem.

With cURL or wget you can perform the download manually first and when you get it working you can move that logic to keyword.

-Tatu

[1] http://docs.python-requests.org/en/master/

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages