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
CodePudding user response:
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: