Currently in the group test new students often do not know how to learn their own coding knowledge and test scenarios actually combined, here take 1 practical examples, analysis of the process.
- Get 1 Test requirements that need to be coded, how to do it
Testing requirements: The company's website is a lot of product images are invalid links, check the search out, for further processing.
First, think: What do you want to do next?
- Idea: Search out all image links-----> Access these links to view response-------> HTTP Code non 200 for invalid links
- What language: The current popular language Java,python, can do, finally choose Python, processing similar crawler work, Python is relatively simple and convenient, and a lot of libraries.
- Do not know the Python library: View the Classic library HTTPS://GITHUB.COM/JOBBOLE/AWESOME-PYTHON-CN, find processing HTTP requests, or direct Baidu/google search python URL
Second, how to find all the pictures in the site link
- Open the company's Web site, right----to view the site source code, will come out a lot of HTML code; We're just going to link the images inside.
- Code: Output The source code of the website to buffer, and then proceed with it.
- View the picture link inside: You can observe the main form of the picture link: style= "width:100%" src= "/http Zcy-item.img-cn-hangzhou.aliyuncs.com//2017062111022565214060.png ">
- Search by Regular expression: ""
- Code
Import re# Regular expression module imagelist = Re.findall (R "" "Output: [' http://zcy-item.img-cn-hangzhou.aliyuncs.com//2017060816344209047406.png ', '/HTTP Zcy-item.img-cn-hangzhou.aliyuncs.com//2017111717221734892422.gif ' ... ]
Not to be continued
Share Tutorial: Search for images in the site and check for invalid images.