当前位置:网站首页>Verification code is the natural enemy of automation? Let's see how Ali P7 solved it
Verification code is the natural enemy of automation? Let's see how Ali P7 solved it
2022-06-12 00:43:00 【Little brother said test】

01、 Verification Code
1、 What is a captcha :
A randomly generated message ( Numbers 、 Letter 、 Chinese characters 、 picture 、 problem in arithmetic ) In order to prevent malicious request behavior , Increase the security of the application
Registration or login is also required in the automation process , So you need to deal with validation

2、 Verification code processing method :
Remove the captcha
Operated by the developer , Used in the test environment
This is the easiest way , For developers , Just comment out the relevant code of the verification code , If it's in a test environment , This saves testers a lot of trouble , If the automation script is to run in a formal environment , This brings certain risks to the system .
Set universal verification code
Operated by the developer , Generally, it is only used in the test environment
Verification code identification technology
Because of the technical difficulty , Recognition rate is difficult to achieve 100%, Records are generally not recommended COOKIE Pass record cookie To skip the login operation
Sure adopt add_cookie() Method Write the user name and password to the browser cookie, When you visit the website again, the server reads the browser directly Cookie Sign in
02、Cookie
1、Cookie principle
Cookie By Web Server generated , And a small text file saved in the user's browser , It can contain user related information
Cookie data format : Key value pairs make up (python Dictionary in )
Cookie produce :
The client requests the server , If the server needs to record the user status , Just give the client browser a Cookie data
Cookie Use :
When the browser requests the site again , The browser combines the requested data with Cookie Submit the data to the server together , Server check Cookie, To identify user status

2、Selenium operation cookie
driver.get_cookie(name) Gets the name of the cookie Information , Back is a dictionary
driver.get_cookies() What you get is all cookie Information about , It returns a list
driver.add_cookie(dict_cookie) Add... To the browser driver cookie,dict_cookie It's a dictionary
Take Baidu for example
BDUSS Is the only identity certificate after login Baidu (*.baidu.com), Get BDUSS It's like taking control of the account , Post Bar 、 know 、 Encyclopedias 、 library 、 Space 、 Baidu cloud and other major products of Baidu .
Sign in baidu, Grab after successful login (BDUSS)
Use add_cookie() Method , add to () Key and value
Call the refresh method driver.refresh()
How to get BDUSS Value ?( Grab the bag to realize )
adopt fiddler Tools After bag grabbing , obtain BDUSS

If the bag grabbing tool is inconvenient , Sure Search through the browser cookie Information
Click on chrome Browser settings
Enter... In the settings search cookie
View all cookie And website data
Search Baidu domain name :baidu.com
obtain BDUSS

Code implementation


After refresh , Result display

Learning resource sharing
Finally, thank everyone who reads my article carefully , Watching the rise and attention of fans all the way , Reciprocity is always necessary , Although it's not very valuable , If you can use it, you can take it

These materials , For doing 【 software test 】 For our friends, it should be the most comprehensive and complete war preparation warehouse , This warehouse also accompanied me through the most difficult journey , I hope it can help you ! Everything should be done as soon as possible , Especially in the technology industry , We must improve our technical skills . I hope that's helpful …….

边栏推荐
- Lambda终结操作forEach
- Mysql database: introduction to database 𞓜 addition, deletion, modification and query
- Lambda创建流
- What are the advantages of Tiktok applet
- repeat_ L2-009 red envelope grabbing_ sort
- leetcodeSQL:614. Secondary followers
- C language pointer and array - learning 23
- Ms-hgat: information diffusion prediction based on memory enhanced sequence hypergraph attention network
- C language string and pointer - learning 25
- 【SignalR全套系列】之在.Net6中实现SignalR分组通信
猜你喜欢

Nat. Comm. | supercomputing +ai: providing navigation for natural product biosynthesis route planning

苹果手机wps文件如何发送到qq邮箱

How to strengthen the prevention and control of major safety risks for chemical and dangerous goods enterprises in flood season

How to send Apple phone WPS files to QQ mailbox

How to uninstall pscs6 in win10 system

R language spline curve piecewise linear regression model piecewise regression estimation of individual stock beta value analysis of yield data

2022 Tibet latest special worker (construction elevator) simulation test question bank and answers

Recurrent+Transformer 视频恢复领域的‘德艺双馨’

Detailed explanation of merge sorting

Is the o2o platform worth doing in 2022
随机推荐
OpenMMLab:AI CV框架
設計消息隊列存儲消息數據的 MySQL 錶格
Jiaming's day13 of C learning -- structure and structure pointer
Jeecgboot 3.1.0 release, enterprise low code platform based on code generator
How to optimize plantuml flow diagram (sequence diagram)
Tencent programmer roast: 1kW real estate +1kw stock +300w cash, ready to retire at the age of 35
2022 edition of global and Chinese hexamethylene chloride industry dynamic research and investment prospect forecast report
The "hard words" about interface testing
Experiment 6 constructor + copy construction
C language pointer - learning 22
Why are the values of ordereddict not equal- Why are the values of an OrderedDict not equal?
DevOps落地实践点滴和踩坑记录-(1)
UVM: transaction level modeling (TLM) 1.0 communication standard
基于.NetCore开发博客项目 StarBlog - (11) 实现访问统计
Alibaba cloud intelligent coding plug-in provides a more cosy development experience
Lambda quick start
Lambda终结操作forEach
win10文件夹状态红叉表示的是什么
Flutter uses local pictures
Breadth first search depth first search dynamic programming leetcode topic: delivering information