1

I'm having an issue with running python selenium for the first time :

from selenium import webdriver 
from selenium.webdriver.common.keys import Keys 
import unittest

class segfam(unittest.TestCase):
    def setUp(self):
        self.driver=webdriver.chrome("/Users/tomersegal/Downloads/chromedriver")

    def test_blabla(self):
        driver=self.driver
        driver.get("https://www.google.co.il/")
        assert "Google" in driver.title

This is my error :

Ran 0 tests in 0.000s

OK
Launching unittests with arguments python -m unittest discover -s /Users/tomersegal/PycharmProjects/pythonProject1 -t /Users/tomersegal/PycharmProjects/pythonProject1 in /Users/tomersegal/PycharmProjects/pythonProject1


Process finished with exit code 0

Empty suite
1
  • Process finished with exit code 0 typically means there should not be any error. What is the error btw do you see ? Commented Nov 19, 2021 at 9:02

1 Answer 1

0

As you are using unittest framework you have to call it from the __main__ function as:

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

So your effective code block will be:

from selenium import webdriver 
from selenium.webdriver.common.keys import Keys 
import unittest

class segfam(unittest.TestCase):
    def setUp(self):
        self.driver=webdriver.Chrome("/Users/tomersegal/Downloads/chromedriver")

    def test_blabla(self):
        driver=self.driver
        driver.get("https://www.google.co.il/")
        assert "Google" in driver.title

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

PS: Note the change of chrome to Chrome


References

You can find a couple of relevant detailed discussions in:

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

2 Comments

now my error is : Error Traceback (most recent call last): File "/Users/tomersegal/PycharmProjects/pythonProject1/main.py", line 7, in setUp self.driver=webdriver.chrome("/Users/tomersegal/Downloads/chromedriver") TypeError: 'module' object is not callable

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.