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
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Segfam
  • 23
  • 3
  • `Process finished with exit code 0` typically means there should not be any error. What is the error btw do you see ? – cruisepandey Nov 19 '21 at 09:02

1 Answers1

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:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 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 – Segfam Nov 19 '21 at 10:23
  • To address the error [_`TypeError: 'module' object is not callable`_](https://stackoverflow.com/questions/69955750/how-to-address-typeerror-module-object-is-not-callable-error-using-selenium-a/69955953#69955953) See the note in the answer [_`PS: Note the change of chrome to Chrome`_](https://stackoverflow.com/questions/69954694/how-to-address-module-object-not-callable-in-python-selenium/69954997#69954997) – undetected Selenium Nov 19 '21 at 10:34