L
L
Lalka-Game-Studio2019-02-05 22:24:45
Python
Lalka-Game-Studio, 2019-02-05 22:24:45

selenium python. How to work with an already open browser?

I work on linux using the firefox browser.
When you run the code, a new browser is always opened. I need the code to find an already open browser and work with it. Googling, I found out that you need to set the value of the executable_path variable, but this does not help. It still opens a new browser.
Maybe I entered the path incorrectly. But the driver is right there.

from selenium import webdriver

driver = webdriver.Firefox(executable_path='/usr/local/bin/geckodriver')
driver.get('http://www.google.com')

elem = driver.find_element_by_name('q')
elem.send_keys('Hello WebDriver!')
elem.submit()

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dimonchik, 2019-02-06
@dimonchik2013

I'm sorry, but what did you google?
There is still no such feature in Selenium, but you can find options
once or
twice
+ finish a little

T
taktik, 2019-02-07
@taktik

Officially, selenium does not support connecting to a running browser instance, although this can be done via crutches.
Most likely your task can be solved by standard features. Describe what you want to do, maybe they will suggest another way to solve it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question