当前位置:网站首页>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 …….

边栏推荐
- Recurrent+Transformer 视频恢复领域的‘德艺双馨’
- Breadth first search depth first search dynamic programming leetcode topic: delivering information
- What is bonded warehouse and what is the difference between them
- 2022 Tibet latest special worker (construction elevator) simulation test question bank and answers
- 在玻璃上构建电路
- VsCode - 保存文件自动格式化将单引号 ‘ 变成双引号 “ 的问题
- Flutter 使用本地图片
- C language bit operation - learning 26
- Started with trust and loyal to profession | datapipeline received a thank you letter from Shandong city commercial bank Alliance
- Scope and category of C language variables - learning 20
猜你喜欢

Characteristics of JS logical operators

2022 Tibet's latest eight members (security officer) simulated test question bank and answers
![[case] building a universal data lake for Fuguo fund based on star ring technology data cloud platform TDC](/img/e0/0326d01fc78ed2f96a475e28e74d1c.jpg)
[case] building a universal data lake for Fuguo fund based on star ring technology data cloud platform TDC

The latest report of Xinsi technology shows that 97% of applications have vulnerabilities

Wechat applet Chinese English conversion

What does the Red Cross of win10 folder status indicate

Devops landing practice drip and pit stepping records - (1)

ROS2之OpenCV基础代码对比foxy~galactic~humble

深度学习100例 | 第41天:语音识别 - PyTorch实现

组态王如何利用无线Host-Link通信模块远程采集PLC数据?
随机推荐
What is bonded warehouse and what is the difference between them
How to make scripts executable anywhere
Lambda快速入门
leetcodeSQL:614. Secondary followers
System.CommandLine选项Option
ironSource  New functions are released, and developers can adjust advertising strategies in real time in the same session
APP项目怎么测?如何搭建测试体系
Hertzbeat v1.0 beta. 4 release, easy-to-use and friendly monitoring alarm system
Ms-hgat: information diffusion prediction based on memory enhanced sequence hypergraph attention network
The latest report of Xinsi technology shows that 97% of applications have vulnerabilities
Bgfx multithreaded rendering
Openmmlab:ai CV framework
基于.NetCore开发博客项目 StarBlog - (11) 实现访问统计
KV storage separation principle and performance evaluation of nebula graph
Flutter 使用本地图片
2022 Tibet latest special worker (construction elevator) simulation test question bank and answers
详解异步任务:函数计算的任务触发去重
A day when the script boy won't be killed
王希廷博士:从知识图谱和自然语言生成的角度认识可解释推荐
Redis advanced - correspondence between object and code base