[Answered ]-Selenium Firefox webdriver throws URLError

2👍

You shouldn’t have to use start_session for that.
On the first line, you are creating a new instance of a local firefox browser. start_session is a method for the remote webdriver.
All you need is:

driver = webdriver.Firefox() #opens new Firefox browser locally
driver.quit() #kills the session
driver = webdriver.Firefox() #opens new Firefox browser locally

Since you are repeating code here, you should have something like this inside your test class

class Test(unittest.Testcase):
    def setUp(self):
        self.driver = webdriver.Firefox()
    def tearDown(self):
        self.driver.quit()
    def test_something(self):
        #do some magic test here
    def test_something_else(self):
        #do some other stuff

That way the browser will launch at the beginning of each test and close at the end of each test.

👤Rafael

Leave a comment