2

Is there any way to get selenium to listen and react to browser notifications like an email or a whatsapp web notification?

1 Answer 1

1

Yeah sure! I am presenting you an example where i intentionally make google create a fake browser notification (just for a demo). You just check the alert.dismiss() line.

Here we go :

from selenium import webdriver
import time

driver = webdriver.Chrome("<your path to chromedriver>")
driver.get("http://google.com")

# Creating a fake notification. Just ignore this.
driver.execute_script("window.alert('This is an alert');")
time.sleep(2)

# Now here's what you are looking for
alert = driver.switch_to_alert()
alert.dismiss()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.