This is the 13th day of my participation in the August More Text Challenge. For details, see:August is more challenging

Selenium is a tool for Testing Web applications. Selenium tests run directly in the browser, just as real users do. It supports the overwhelming majority of browsers on the market. The main features of this tool include testing browser compatibility – testing your application to see if it works well on different browsers and operating systems. Test system functionality – Create regression tests to verify software functionality and user requirements. Supports automatic recording of actions and automatic generation of test scripts in different languages such as.NET, Java, and Perl.

Have you read the introduction to Selenium and think it’s awesome? Even if we’re not in the business of automating tests, learning this software can help us a lot in our lives.

Let’s take a look at the most commonly used search engine, Baidu. Direct F12 into the view code

Find the input box from the complete HTML code. The input box id is WD. We can then use Selenium to find this element by id.

Select * from Selenium import webdriver; Chrome(r' your own local path ') # Call the Webdriver object's get method to make the browser open the specified url Driver.get ('https://www.baidu.com') # Select element by id, Element = driver.find_element_by_id('kw') # Enter a string into the input box element. Element. Send_keys (' How to learn selenium \n')Copy the code

What do you think is going to happen here? The program automatically opened the browser, entered “How to Learn Selenium” in the input box, and finally hit Enter.

This is the most basic and simple example. If you are interested in learning Selenium, you can follow the public account: poetic code, leave a message to me, and I will teach you to study systematically.