I am writing a python script that logs into edge using msedge-selenium-tools. When I run the script, a modal appears, and I can't seem to get any css selectors to use in Selenium. Here is my current code
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from msedge.selenium_tools import EdgeOptions, Edge
from time import sleep
import requests
from pprint import pprint
import random
import os
options = EdgeOptions()
options.use_chromium = True
def wait_for(sec=2):
sleep(sec)
driver = Edge(executable_path="./edgedriver_win64/msedgedriver.exe", options=options)
try:
driver.get('https://login.live.com/')
wait_for(5)
email_input = driver.find_element_by_id("i0116")
email_input.clear()
email_input.send_keys(os.environ['email'])
email_input.send_keys(Keys.ENTER)
wait_for(10)
password_input = driver.find_element_by_id("i0118")
password_input.clear()
password_input.send_keys(os.environ['pass'])
password_input.send_keys(Keys.ENTER)
except Exception as e:
print(e)
wait_for(3)
I attached an image of the modal I receive.
Any assistance would be greatly appreciated. When the webdriver launches the Edge browser and displays the modal, I tried right-click > inspect, or ctrl + shift + i to get into the front-end to inspect but could not perform these actions.
Actually you can avoid from this notification by adding options.add_argument('inprivate')
also according your code you import useless library , any way I edit your code
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.edge.options import Options
from time import sleep
import os
options = Options()
options.use_chromium = True
options.add_argument('inprivate')
def wait_for(sec=2):
sleep(sec)
driver =webdriver.Edge( options=options)
try:
driver.get('https://login.live.com/')
wait_for(5)
email_input = driver.find_element_by_id("i0116")
email_input.clear()
email_input.send_keys(os.environ['email'])
email_input.send_keys(Keys.ENTER)
wait_for(10)
password_input = driver.find_element_by_id("i0118")
password_input.clear()
password_input.send_keys(os.environ['pass'])
password_input.send_keys(Keys.ENTER)
except Exception as e:
print(e)
wait_for(3)