In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you the example analysis of Selenium automation browser testing in Python, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's learn about it!
Selenium of Python (Automated browser Test) 1. Install seleniumpip install selenium-I https://pypi.tuna.tsinghua.edu.cn/simple2. Download the corresponding version of the browser driver
Http://npm.taobao.org/mirrors/chromedriver/
This is mine.
Put the unzipped driver in your python.exe directory.
3. Test code, open a web page, and get the title of the web page from selenium.webdriver import Chromeif _ _ name__ = ='_ _ main__': web = Chrome () web.get ("https://baidu.com") print (web.title))
4. A small sample from selenium.webdriver import Chromeif _ _ name__ = ='_ main__': web = Chrome () url = 'https://ac.nowcoder.com/acm/home' web.get (url) # get the a tag el = web.find_element_by_xpath (' / html/body/div/div [3] / div [1] / div/a') to click on ) # Click el.click () # "/ html/body/div/div [3] / div [1] / div [2] / div [1] / h5DB a" # crawl the desired content lists = web.find_elements_by_xpath ("/ html/body/div/div [3] / div [1] / div [2]) / div [@ class='platform-item js-item'] / div ["" 2] / div [1] / h5i.text ") print (len (lists)) for i in lists: print (i.text)
5. Automatic input and jump
From selenium.webdriver import Chromefrom selenium.webdriver.common.keys import Keysimport timeif _ _ name__ ='_ main__': web = Chrome () url = 'https://ac.nowcoder.com/acm/home' web.get (url) el = web.find_element_by_xpath (' / html/body/div/div [3] / div [1] / div/a') el.click () Time.sleep (1) input_el = web.find_element_by_xpath ('/ html/body/div/div [3] / div [1] / form/input [1]') input_el.send_keys ('Niuke' Keys.ENTER) # do something and above are all the contents of the article "sample Analysis of Selenium Automation browser testing in Python" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.