Execute Selenium Scripts on an Already Opened Browser Using Python

Mukesh otwani · 63K views · 2021 · 10:42

Open on YouTube

Testing, debugging & developer toolsPython, Ruby & scripting languagesWeb developmenttutorial

Why Stack Overflow recommends it

Stack Overflow users link it when explaining how to run Selenium scripts against an already open Chrome session, for example to reuse a logged-in session or skip OTP prompts.

Recommended by 1 people across 1 different months, 2021 to 2022.

What it is

A roughly 10-minute tutorial by Mukesh Otwani showing how to attach Selenium with Python to a Chrome browser that is already open, using the DevTools remote debugging port and the debuggerAddress experimental option. It covers launching Chrome with a debugging port and driving that session from a script.

What people said

Recommends Noss1v · 2022-02 · Stack Overflow · on “what does "add_experimental_option("debuggerAddress", "localhost:8989")" actually do when added to Options() on Python? Selenium related”

(Basic answer, im newbie with this) Using: opt = Options() opt.add_experimental_option("debuggerAddress", "localhost:8989") You can execute selenium scripts on already opened browser. See this video and you easily understand: [this video] While using the second option, the script open a new browser and run the commands.

Cites sizo_abe · 2021-05 · Stack Overflow · on “How to read otp sent on Mobile number while login into Power BI.(Have to avoid multifactor authenticator)”

In order to bypass OTP thing, you have to save cookies in folder(any folder). from selenium import webdriver import time from selenium.webdriver.chrome.options import Options opt = Options() opt.add_experimental_option("debuggerAddress","localhost:9222") driver = webdriver.Chrome(executable_path ='C:\\Users\\selenium\\chromedriver.exe',\ options = opt) driver.get(" [LINK] ru=https%3A%2F%2Fapp.powerbi.com%2F%3FnoSignUpCheck%3D1") Reference : [this video]

Cites DiscoveringCreation · 2021-12 · Stack Overflow · on “selenium.common.exceptions.WebDriverException: Message: unknown error: cannot connect to chrome at localhost:8733 \\\\ What's going on?”

I've been trying to follow this python tutorial here: [this video] It's about executing python selenium scripts on an already opened browser. So far, I have this code: (I was at the 7:12 mark of the video if that helps) from selenium import webdriver from selenium.webdriver.chrome.options import Options opt=Options() opt.add_experimental_option("debuggerAddress","localhost:8733") driver=webdriver.Chrome(executable_path=r"C:\Users\User\Documents\driver for seleniu\chromedriver.exe",chrome_options=opt) driver.get(" [LINK] ") The code didn't work and I got two deprecation warnings, so I changed my code to this: from selenium import webdriver from selenium.webdriver.chrome.service import Service from