I am automating some tasks at work, and I need to use Selenium to get data that is updated on an internal website.
I can open the website and view this data in Edge Browser from my account without any kind of authentication,
However, when opening the same website with EdgeDriver, I get prompted for MFA every time I run the code
I cannot automate MFA since I have to use my phone,
Is it possible to use the same credentials with EdgeDriver as with Edge Browser? Or to just use the Edge Browser directly in selenium instead?
Thanks,
Python code below:
from selenium import webdriver
from time import sleep
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.edge.options import Options
from selenium.webdriver.support.wait import WebDriverWait
import schedule
import time
from random import randint
def job():
while True:
print("started health checkin")
# Instantiate the webdriver with the executable location of MS Edge
browser = webdriver.Edge(r"C:\msedgedriver.exe")
# Simply just open a new Edge browser and go to lambdatest.com
sleep(2)
#browser.maximize_window()
sleep(2)
browser.get('https://xxxxxxxxxxxxxxxxxxxxxxxxx')
try:
sleep(3)
myElem_2 = WebDriverWait(browser, 10).until(EC.presence_of_element_located((By.XPATH, '/html/body/div[3]/div[3]/div/ng-component/pbi-menu/button[3]')))
# Entering the email address
sleep(3)
myElem_2.click()
except TimeoutException:
print("No element found")
sleep(5)
browser.close()
def day_job():
sleep(randint(10,1000))
job()
job()
print("starting daily timer")
schedule.every().day.at("08:00").do(day_job)
while True:
schedule.run_pending()
time.sleep(60) # wait one minute