Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

10 minutes to play Python+Selenium automated testing, quick start channel!

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Recently, I have browsed the resumes of many students. Most of them have automated tests and basically have selenium. But few people really understand selenium. One is that selenium provides a lot of components that make it easy for people to use, and then many people don't have it. Second, the update of selenium is accompanied by the merger of tools, and many people do not use selenium RC or webdriver at all in HD.

According to the recent interview, summarize the questions that many students did not understand when practicing selenium, and teach you how to play selenium quickly by the way!

What are test engineers talking about now?

1. Has python met recently?

2. Selenium Automation, how is the progress of your team?

3. How are you applying the automation framework?

4. There will be bottlenecks in manual career development all the time. Testing really wants to go to test development and automate.

5. We recruit automation engineers from 10K, but so far we have not recruited a suitable candidate, so hurry up to learn automation, raise salary or change jobs.

The Planning Road of Automation engineer

How to play Selenium Automation?

At present, there are many automation tools on the market, and selenium is only one of the outstanding representatives. In recent years, with the open source wind, the stability of selenium, version update and so on, it has become more and more popular in the market. Of course, the role of Python can not be ignored here!

If you are a rookie and want to learn automation, python+selenium is highly recommended.

Don't be scary at the mention of code (a common fault of many test engineers). In fact, python and selenium are just paper tigers. You should have the courage to face them and challenge them. Otherwise, if you don't have technical competitiveness, who will give you a raise?

! , python easy to use, simple syntax, a large number of third-party module support-selenium support for bUnip s is very good, currently all major browsers support it. Of course I still like FireFox.

Learning the selenium,IDE section is not the main point, the focus is on the webdriver API section.

2. Don't devote most of your energy to IDE.

Front-end knowledge should be properly stored: html, css, js, etc., but do not make yourself a front-end engineer, of course, that is also very beneficial to you.

What is Selenium?

I believe that students engaged in automated testing or those who have experienced Python crawler will know what Selenium is.

Selenium is a Web automated testing software, as the Selenium official website said: Selenium is mainly for testing purposes and automation of Web applications, but of course not limited to this, some boring Web-based management tasks can also be automated using Selenium. Yeah, like reptiles.

Web crawler should be the most well-known application scenario of Selenium in addition to Web automated testing. It can effectively obtain the data on the page when facing some dynamic web pages generated by JS. It can be said to be a must-have product for Python web crawlers.

Python+selenium environment building

1. Python environment installation

Download and install Python

Set the environment variable: run cmd as an administrator and enter the following command: path=%path%;C:\ Python27

Run python: type python on the command line to run python

2. Installation of PIP

Pip is similar to yum in RedHat, so it is very convenient to install the Python package. (click on the picture to download)

After downloading, extract it, use the command line to enter the extracted directory, and run the command: python setup.py install

Add environment variables: enter path=%path%;C:\ Python27\ Scripts on the command line

See if the installation is successful: enter pip-v

3. Install selenium for python

Enter pip install selenium on the command line (click on the picture to download)

Verify that the installation is successful: type python in cmd to enter the python environment, and then enter from selenium import webdriver. If you do not report an error, it means that the selenium installation is successful.

4. Installation and use of PyCharm

In the Python development process, a more popular, very excellent IDE tool-PyCharm, here on its introduction, it is equivalent to the Java development of Eclipse software. (click on the picture to download)

Create a project

5. Open and close the browser through script

To open a browser with selenium. First of all, you need to download a driver plug-in (different browsers correspond to different driver plug-ins). Here, take chrome as an example. After downloading, put the plug-in in the Python installation directory.

In this way, a complete testing framework and Demo have been built. Have you learned it?

Using selenium to do automated testing FAQ

1. How to determine whether an element exists in selenium?

A: isElementPresent

2. Can the element of hidden or display = none in selenium be located?

A: it cannot be located

3. Is it necessary to connect to the database for data verification when automated testing?

Answer: UI automation is not needed, interface testing will need

4. Can webdriver be used for interface testing?

A: it is difficult to do interface testing. It is not recommended.

5. How to locate the dynamically loaded elements on the page?

Answer: trigger the event of dynamically loading the element until the dynamic element appears and locate

6. How to locate elements with dynamically changing attributes?

Answer: xpath or css is located by peer, parent, or child.

7. After clicking the link, will selenium automatically wait for the page to be loaded?

A: I will wait for the page to finish loading.

8. Where do automated test cases come from?

A: extracted from manual use cases, you can refer to the execution strategy of automation use cases

9. What do you think is the biggest defect of automated testing?

Answer: unstable, reliable, difficult to maintain, the cost is not proportional to the benefit

10. What is hierarchical testing?

A: UI testing, integration / interface testing, and unit testing can all be counted as hierarchical tests.

Summary:

With the increasing popularity of test development, the code ability of testers is also improving. In the study of selenium, it is more necessary to master the api of webdriver and explore more features of selenium.

There is no impassable mountain of fire, there is no technical problem that cannot be broken, as long as you dare and work hard, you will win in the end.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report