2
votes

I am using Robot IDE for creating robot automation test scripts. For my test when I start audio call then browser is asking for the permission with "Allow" and "Block" buttons. So as it's a web based alert/popup dialog I can't able to access it in my robot script. If I am clicking on "Allow" button manually then it proceeds the test and passes successfully but I need to click it manually.

For Image, please click here

As you can see from the image I want to click on Allow button which is necessary to go ahead in my test.

So can anyone know how can I click on the "Allow" button of the browser confirmation popup via robot test script.

Thanks in advance!

My project structure is

enter image description here

1
Have you tried using the Dismiss alert keyword?Bryan Oakley
@BryanOakley, Yes I have used that keyword but it gives error "There were no alerts" and fails the test caseuser2235971
@A.Kootstra, Do you know how can I use it in Robot framework?user2235971

1 Answers

2
votes

The Chrome settings that drive this functionality can be viewed using the chrome://settings/. These settings are stored in the Chrome Profile. The path to this profile can be found using chrome://version/. In the preferences file a JSON structure of settings can be found.

In the below Robot Framework example the script opens Google and then clicks on the microphone icon to start the voice search. Under normal circumstances this results in a pop-up for microphone access.

The reason the assignment is split into two variables is because the url contains characters (. : //) that are considered separators. This is then overcome by creating that part of the structure manually: Create Dictionary https://www.google.nl:443,*=${SiteOptions}.

This then results in the desireable preference structure:

...
"profile":{
     ...
     "content_settings": {
         ...
         "exceptions": {
            ...
            "media_stream_mic":{
               "https://www.google.nl:443,*":{
                  "last_used":1492245954.955647,
                  "setting":1
               }
            },

Robot Script:

*** Settings ***
Library    Selenium2Library    

*** Test Cases ***

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

    &{SiteOptions}         Create Dictionary    last_used=${1470931206}     setting=${1}
    &{media_stream_mic}    Create Dictionary    https://www.google.nl:443,*=${SiteOptions}
    ${prefs}               Create Dictionary    profile.content_settings.exceptions.media_stream_mic=${media_stream_mic}

    Call Method    ${chrome_options}    add_experimental_option    prefs    ${prefs}

    Create WebDriver    Chrome    chrome_options=${chrome_options}

    Go To    https://google.com

    Click Link    css=#gs_st0 > a    # Click the search microphone icon.

    sleep     5s
    [Teardown]    Close Browser