Im building a program to log me in to my website click through a few options and fill out a form. My problem comes when the program is done running and closes the window. I can stop this temporarily with the time.sleep option. but when trying to use the detach true option it doesnt work. So im looking for a way to run my program, open a webpage, sign me in then navigate where i want to go and fill out a form.
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.edge.options import Options
edge_options = Options()
edge_options.add_experimental_option("detach", True)
driver = webdriver.Edge()
driver.get("https://oceanspray-amc.ivanticloud.com/Account/SelectRole? returnUrl=%3FNoDefaultProvider%3DTrue&NoDefaultProvider=True/")
driver.maximize_window()
time.sleep(2)
links = driver.find_element(By.XPATH, "/html/body/div[3]/div/form/div[4]/div/a").click();
time.sleep(2)
links = driver.find_element(By.XPATH, "/html/body/div[3]/div/form/div[3]").click();
links = driver.find_element(By.XPATH, "/html/body/div[3]/div/form/div[4]/div/button").click();
It doesn't work for you, because you haven't passed edge_options
inside driver instance.
edge_options
is just an object and webdriver.Edge
doesn't know anything about it until you wouldn't pass it as an argument.
edge_options = Options()
edge_options.add_experimental_option("detach", True)
driver = webdriver.Edge(edge_options)