I am using Python Selenium to open a Firefox browser and go to a URL. The function I am using to do this is...
def openurl_function():
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://www.example.com')
When I run the function it always opens a new instance of FireFox, is there a way to have it to just open using the same browser instance?
Currently if I run the function 10 times then I get 10 FireFox browsers open.
Just keep reusing the same driver
. You are creating a new browser, every time you call
driver = webdriver.Firefox()
Also, because you never quit()
on your driver, you will probably have all the browsers stay open as orphans because you deleted the handle to them when you created a new browser.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With