0

Is selenium only for testing?

I created a script to log in to canvas, a website that my uni uses for class material however, it seems that it only logs in on the browser generated by the driver, and I will still have to manually log in on the actual browser.

Is there a way for me to make it so that I won't have to log in on the actual browser after running my script?

from selenium import webdriver
from selenium.webdriver.common.keys import Keys 
from selenium.webdriver.common.by import By
import time

PATH = r"C:the path \msedgedriver.exe"
driver = webdriver.Edge(PATH)
driver.get("the website")
driver.maximize_window()

#sign in page
user = driver.find_element(By.ID,"username")
user.send_keys("username")
pw = driver.find_element(By.ID,"password")
pw.send_keys("password")
pw.send_keys(Keys.RETURN)

driver.implicitly_wait(3)

#authentification
driver.switch_to.frame(driver.find_element(By.XPATH,"//iframe[@id='duo_iframe']"))
remember_me = driver.find_element(By.XPATH, "//input[@type='checkbox']")
remember_me.click()
duo = driver.find_element(By.XPATH, '//button[text()="Send Me a Push "]')
duo.click()
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
leman
  • 1
  • You don't need to use `selenium` for this. You could use `requests` and `beautifulsoup` to achieve the same. So it depends on what you are trying to achieve... if you are using selenium (for example, to click specific buttons) then you could use it in `headless` mode. – D.L Mar 14 '22 at 09:27

1 Answers1

0

As per Selenium's Homepage

Selenium automates browsers. That's it! What you do with that power is entirely up to you.

Primarily it is for automating web applications for testing purposes, but is certainly not limited to just that.

Boring web-based administration tasks can (and should) also be automated as well.

No, you won't be able to reconnect to the already opened Browsing Context.

Even if you are able to extract the ChromeDriver and ChromeSession attributes e.g. Session ID, Cookies, UserAgent and other session attributes from the already initiated ChromeDriver and Chrome Browsing Session still you won't be able to change the set of attributes of the ChromeDriver.

A cleaner way would be to span a new set of ChromeDriver and Chrome Browser instance with the desired set of configurations.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352