当前位置:网站首页>Verification code is the natural enemy of automation? Ali developed a solution
Verification code is the natural enemy of automation? Ali developed a solution
2022-06-11 15:41:00 【Two black】
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 .
Picture setting universal verification code
Operated by the developer , Generally, it is only used in the test environment
Picture verification code recognition 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
Can pass add_cookie() Method to 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
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 After tool grabbing , obtain BDUSS

If the bag grabbing tool is inconvenient , You can 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 those who want to engage in 【 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 ! You can get it for free by joining our communication group below , I hope that's helpful …….
边栏推荐
- Qcustomplot 1.0.1 learning (3) - plotting quadratic functions
- [creation mode] prototype mode
- In June, 2019, cat teacher's report on monitoring
- 05 _ In simple terms index (Part 2)
- Recyclerview usage record
- Intercept string (function)
- 19. 二叉搜索樹的插入删除修剪
- 知网被立案调查;字节跳动成立抖音集团,或在港上市;钉钉被曝裁员30%;北京人均存款超20万元 |Q资讯
- Hard core analysis lazy single case
- Analysis of the execution process of opengauss simple query SQL
猜你喜欢
[mysql_12] MySQL data types

硬核分析懒汉式单例

【创建型模式】单例模式

leetcode 120. Triangle minimum path sum

每日一博 - 微服务权限一二事

04 _ In simple terms index (I)

06 _ Global lock and table lock: Why are there so many obstacles to adding a field to a table?

PHP Apache built-in stress testing tool AB (APACHE bench)

码农必备SQL调优(下)

19. 二叉搜索树的插入删除修剪
随机推荐
The most egregious error set of tone codes
实时特征计算平台架构方法论和实践
How to batch insert 100000 pieces of data
Tangzhengrong: CTO is the intersection of business thinking and technical thinking
openGauss简单查询SQL的执行流程解析
07 _ 行锁功过:怎么减少行锁对性能的影响?
容易让单片机程序跑飞的原因
Flower shop window (linear DP)
Summary of redis basic knowledge
Failed to create pod sandbox: rpc error: code = Unknown desc = [failed to set up sandbox container..
[0006] titre, mots clés et description de la page
uniapp开发微信小程序,从构建到上线
Hebei huangjinzhai scenic spot adds "AED automatic defibrillator" to ensure the life safety of tourists!
Implementation of placing the scroll bar on the top of the uniapp
调代码最离谱错误合集
将配置导出到FTP或TFTP服务器
05 _ In simple terms index (Part 2)
Is it possible to use multiple indexes together in a query?
MySQL user authority summary [user authorization required]
The reason why it is easy to let the single chip computer program fly
