pip install selenium
或者到https://pypi.python.org/pypi/selenium
下載setup安裝包,以後進入目錄後運行python setup.py install
html
官方文檔地址:http://selenium-python.readthedocs.io/installation.html
python
須要下載相應瀏覽器的驅動,驅動下載地址:http://docs.seleniumhq.org/download/
git
#!/usr/bin/env python # -*- coding: utf-8 -*- import unittest from selenium import webdriver from selenium.webdriver.common.keys import Keys class PythonOrgSearch(unittest.TestCase): def setUp(self): self.driver = webdriver.Firefox() 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): self.driver.close() if __name__ == "__main__": unittest.main()
參考:github
http://www.javashuo.com/article/p-mipgjbyx-mb.html
http://blog.csdn.net/nhudx061/article/details/43601065/
http://selenium-python.readthedocs.io/installation.html
http://www.javashuo.com/article/p-sveyymlj-x.html
http://www.51testing.com/zhuanti/selenium.html
http://blog.csdn.net/blueheart20/article/details/70768930
https://www.cnblogs.com/fnng/archive/2013/05/29/3106515.html
https://github.com/mozilla/geckodriver/releases
https://www.zhihu.com/question/49568096web