Umesh
Umesh

Reputation: 125

How to close browser popup in robot framework?

After login in Chrome browser, I am getting a save password popup from the browser. I want to handle that popup and want to close that using Robot Framework Browse popup window Thanks

Upvotes: 0

Views: 6289

Answers (3)

A. Kootstra
A. Kootstra

Reputation: 6961

This question has been asked and answered before with a pure Python context. This answer continues on this SO post for a working Robot Example.

The popup you see is generated by Chrome itself. It's not an HTML alert. For this reason none of the Selenium2Library keywords will have any effect on it. Nor wil settings cookies or javascript.

enter image description here

These settings can be manually set using the chrome://settings link. Go to advanced settings and then scroll down to Passwords and Forms. Untick the second item and this will prevent the popup.

enter image description here

To do the same automatically in Robot Framework the WebDriver needs to be started with additional preferences:

 Chrome With Preferences
    ${chrome_options} =     Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver

    ${prefs}    Create Dictionary   credentials_enable_service=${false}  

    Call Method    ${chrome_options}    add_experimental_option    prefs    ${prefs}
    Call Method    ${chrome_options}    add_argument    --disable-infobars 

    Create WebDriver    Chrome    chrome_options=${chrome_options}

    Go To    https://secure.url.com

This key things here are credentials_enable_service=${false} where it is important to use ${false} and not false, as the latter is interpreted as a string and then added to Chrome as "false" instead of the correct value false.

The second item is that preferences are not added as arguments but through assigning a dictionary to the prefs property of the ChromeOptions() object like so: add_experimental_option prefs ${prefs}

Upvotes: 1

Tanmay Agrawal
Tanmay Agrawal

Reputation: 42

Three Ways To do do it.

1) Many a times, Once pop-up appear on screen and Disappear a cookie is set which you can view in developer console-> application. If you set this cookie with value using Add Cookie keyword. Pop- up wont appear.

2) if first doesn't work, then open developer tools and monitor the local store from developer tools -> application and close the pop-up. U will notice some variable with a value is stored in local storage. You can set that value using your script and u wont see the pop-up while executing variable.

3) If first and second doesn't work, the pop-up is most likely linked to a javascript variable. set java script variable using Execute Javascript Keyword and your problem must be solved.

Talk with your dev team, to see which way will work for you.

Upvotes: 0

Lubos Jerabek
Lubos Jerabek

Reputation: 833

I do not think this is real to be honest (as it's property of the browser.) Are you having issues with that? The only thing you can dismiss is javascript alert and probably the best way to handle this is:

${alert} =    Get Alert Message    dismiss=${dismiss}

I have this in my test teardown with Run Keyword and Ignore Error, it makes me able to fetch optional js alert content and debug (also dismisses it do the rest of the suite can be executed.)

Upvotes: 0

Related Questions