0

I have created the following Python - when I execute it I receive an error. The apparent errant line is in italics

from selenium import webdriver
import unittest
import sys

class ExampleTestCase(unittest.TestCase):

    def setUp(self):
        * Errant line below
        self.__driver = webdriver.Remote(desired_capabilities={
            "browserName": "firefox",
            "platform": "Windows",*
        })
        print("Got this far")

    def test_example(self):

        self.__driver.get("http://www.google.com")
        self.__assertEqual(self.driver.title, "Google")

    def tearDown(self):
        self.__driver.quit()

if __name__ == "__main__":
unittest.main()

The error is

ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Can anyone suggest what the problem might be? I am using Python 3.4 and

1 Answer 1

1

Your code is trying to invoke a remote instance of Selenium, which is fine only if there is a remote server able to respond to your request. If you do not specify an address (which you don't) then it is going to try connecting on the local machine. If what want to do is only start Firefox on your local machine, then you can do this:

from selenium import webdriver
import unittest
import sys

class ExampleTestCase(unittest.TestCase):

    def setUp(self):
        self.__driver = webdriver.Firefox()
        print("Got this far")

    def test_example(self):

        self.__driver.get("http://www.google.com")
        self.assertEqual(self.__driver.title, "Google")

    def tearDown(self):
        self.__driver.quit()

if __name__ == "__main__":
    unittest.main()

The code above runs fine.

Sign up to request clarification or add additional context in comments.

1 Comment

Making Louis' change has indeed fixed the proble.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.