Unable to run selenium with python using unittest -
using below configuration :
macos sierra 10.12.4, python version 2.7, selenium version 3.5
i'm trying write script in pycharm selenium webdriver , unittest modules. goal go site find element(button) , click on button. tried using firefox driver , chrome driver. tried run without ide no luck. been searching on can't work.
here code:
import unittest selenium import webdriver selenium.webdriver.common.keys import keys class homeworkteam(unittest.testcase): def setup(self): self.driver = webdriver.chrome(executable_path=r'/users/<user>/homework/chromedriver') def test_team_search(self): driver = self.driver driver.get("http://www.python.org/index.html") teamelem = driver.find_element_by_id("submit") teamelem.send_keys(keys.enter) assert "no results found" not in driver.page_source def teardown(self): self.driver.quit() if __name__ == '__main__': unittest.main()
when run this output browsers not launched.
ran 0 tests in 0.000s
ok
process finished exit code 0
i assume ran using below
python -m unittest
if file test myunit
need use below run
$ python -m unittest -v myunit test_team_search (myunit.homeworkteam) ... ok ---------------------------------------------------------------------- ran 1 test in 6.455s ok
ps: refer https://docs.python.org/devguide/runtests.html more details
Comments
Post a Comment