First step : install python Interpreter
The second step : install pycharm compiler .
The third step : install selenium library
Step four : Download the browser driver
Step five : open pycharm Write the first automation demo Verify if there is a problem with the environment
Fast + Simply build the environment . If there are questions , Welcome to join the group to discuss and leave a message .
First step : install python InterpreterOfficial website address :https://www.python.org/
Automated testing is best downloaded 3.7 Of .
After downloading, open this file , And then install it like a fool .
After installed ,win+r Open the command line window , Input python. If the following figure is displayed , It means the installation is successful .
The second step : install pycharm compiler .Just install it like a fool .
http://www.jetbrains.com/pycharm/download/#section=windows.
The third step : install selenium librarypip install selenium
Step four : Download the browser driver I usually use chrome It's more representative .
Chrome:
https://sites.google.com/a/chromium.org/chromedriver/downloads( Need to climb over the wall )
Firefox:
https://github.com/mozilla/geckodriver/releases.
After the download , Place the drive in the python The folder scripts In the root directory .
Step five : open pycharm Write the first automation demo Verify if there is a problem with the environmentfirst demo
from selenium import webdriverimport timeimport unittestclass LoginPage(object): driver=webdriver.Firefox() driver.get("https://passport.hupu.com/pc/login?project=nba&from=pc") time.sleep(5) def test_login(self): self.driver.find_element_by_xpath("//*[@id='J_username']").click() self.driver.find_element_by_xpath("//*[@id='J_username']").clear() self.driver.find_element_by_xpath("//*[@id='J_username']").send_keys("18777777777") self.driver.find_element_by_xpath("//*[@id='J_pwd']").click() self.driver.find_element_by_xpath("//*[@id='J_pwd']").clear() self.driver.find_element_by_xpath("//*[@id='J_pwd']").send_keys("111111111") self.driver.find_element_by_xpath("//*[@id='SM_BTN_1']/div[1]/div[4]").click() time.sleep(6) def test_threads(self): self.driver.get("https://bbs.hupu.com/hcbig") time.sleep(6) self.driver.find_element_by_id("g_n").click() time.sleep(6) self.driver.find_element_by_id("atc_title").click() self.driver.find_element_by_id("atc_title").clear() self.driver.find_element_by_id("atc_title").send_keys(" Text post from orange ") self.driver.find_element_by_xpath("//body").click() self.driver.find_element_by_xpath("//body").send_keys(" Oranges use automated tests to send text messages ") self.driver.find_element_by_id("submitview").click()login=LoginPage()login.login()time.sleep(4)login.fatie_4524()
As long as you can start the browser successfully , And you can see that the mouse operates automatically , It means there is no problem with the environment .
This is about hand-in-hand building python+selenium Automation environment ( Image & Text ) This is the end of the article , More about python selenium For the content of automatic environment construction, please search the previous articles of SDN or continue to browse the following related articles. I hope you will support SDN more in the future !