Sawitree Cha
Sawitree Cha

Reputation: 199

How to make the browser allow notification disappear while running automate test using Robot Framework

I don't want Allow Notifications pop up appear while I'm running automate script and I try to block it by manual (block it in browser setting). Browser is Firefox.

Test
[Tags]    Regression
Open Excel    ${Data.${ENV_DATA}}
@{getCustInfor}=    Get Sheet Values    CardNo
@{getMsg}=    Get Sheet Values    Messages
Login.Login by username and password    ${USER.${ENV}}    ${PASS.${ENV}}

The pop up always shows after finished login page and it cover some element.

Upvotes: 0

Views: 417

Answers (1)

Sayali Waghmare
Sayali Waghmare

Reputation: 112

Set the preference of firefox dom.webnotifications.enabled to False. This will disappear the notification.

In robot you can do this by, creating a function

def create_profile(self):
    from selenium import webdriver
    fp=webdriver.FirefoxProfile()
    fp.set_preference("dom.webnotifications.enabled",False)
    fp.update_preferences()
    return fp.path

In .robot file add the following code:

${profile}=    create profile   
Open Browser    ${URL}    ${BROWSER}    ff_profile_dir=${profile}

Upvotes: 2

Related Questions