[Tutor] How can I run this test script using selenium while making connection and running the code I am facing issue Please see my code below

George Fischhof george at fischhof.hu
Wed Jan 18 07:35:39 EST 2017


2017-01-18 11:18 GMT+01:00 Sarika Shrivastava <sarika1989.08 at gmail.com>:

> import unittest
> from selenium import webdriver
> from selenium.webdriver.common.keys import Keys
> import time
>
> class PythonOrgSearch(unittest.TestCase):
>
>     def setUp(self):
>         self.driver =
> webdriver.Chrome('C:\Users\uidk9685\Downloads\chromedriver.exe')
>         # print self.driver
>         time.sleep(0.5)
>
>     def test_search_in_python_org(self):
>         driver = self.driver
>
>         # driver.get("http://www.python.org")
>         # self.assertIn("Python", driver.title)
>         # elem = driver.find_element_by_name("q")
>         # elem.send_keys("pycon")
>         # elem.send_keys(Keys.RETURN)
>         # assert "No results found." not in driver.page_source
>
>
>     def tearDown(self):
>         pass
>         # self.driver.close()
>
> if __name__ == "__main__":
>     unittest.main()
>
>
>
>
> [image: Inline image 2]
> --
> Best regards,
>
> Sarika Shrivastava
> Associate Engineer
>
> Continental Automotive Components (India) Pvt. Ltd.,
> 8th Floor, Gold Hill Supreme Software Park,
> Plot No. 21, 22, 27 & 28, Shanthipura Road,
> Electronics City, Phase II, Hosur Road,
> Bangalore-560 100
>
> Tel: +919741457409
> Mobile: +919741457409
> E-Mail: sarika.shrivastava at continental-corporation.com
> Web: www.continental-corporation.com
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


Hi Sarika,

maybe it is better and easyer to use pytest instead of unittest.
pytest automaticallt finds the tests in files named test_*.py or *_test.py,
and will run functions with the similar names.


You can find pytest documentation on the following link:
http://docs.pytest.org/en/latest/

and pytest can be installed by pip:
pip install pytest

BR,
George


More information about the Tutor mailing list