0

I have a dir named PageObjects, there is a file Login.py. It stocks all the locators of elements plus functions that I call in test cases. It looks like this:

class Login:
    # Locators of all elements
    browser = webdriver.Chrome()
#    browser = webdriver.Firefox()
...
    def __init__(self, driver):
        self.driver = driver
        self.url = "https://www.url.com/"
...

My test case code is:

class LoginTest01(unittest.TestCase):

    @classmethod
    def setUpClass(cls):
        cls.driver = Login.browser
        login = Login(cls.driver)
        cls.driver.get(login.url)
        cls.driver.maximize_window()

    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()

    def test_login_01(self):
        login = Login(self.driver)
        login.close_icon()
        login.click_signin()
...
if __name__ == "__main__":
    unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(
        output="Destination\\ProjectName\\Reports",
        report_name="LoginTest01"))

So if I'm running this in parallel I'm getting more errors: https://gofile.io/?c=B2vhIB

But if I'm not calling the browser from PageObjects -> Login.py but use it directly in test case (setUpClass) everything goes smoothly:

    @classmethod
    def setUpClass(cls):
        cls.driver = webdriver.Chrome()
        login = Login(cls.driver)
        cls.driver.get(login.url)
        cls.driver.maximize_window()

I know that there is a issue in socket connections. How can I bypass this issue? Any ideas?

Thanks.

  • The file with error gives a 404. How do you run the tests in parallel? – Niels van Reijmersdal Oct 16 at 7:00
  • Sorry, the file was probably deleted. I changed the link, you can check it. How do I run tests in patallel? I'm using Windows PowerShell. I'm accessing the dir with the test cases I want to test in parallel and I use pytest command "pytest --workers 1 --tests-per-worker 2". – rodut Oct 16 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.