This query is simply one other type of one which comes up fairly typically: “How can I get previous a CAPTCHA or 2FA utilizing automation instruments?”
First, you possibly can’t! This might be a violation of CAPTCHA and 2FA! If you will get previous it utilizing Selenium or different like instruments, so can any nefarious actor for illegitimate causes!
The best choice so that you can do is to disable CAPTCHA or 2FA in your Dev and Check environments. This provides you management over your testing. Keep in mind that not each take a look at must be automated, and that is a type of use instances!
Now, let’s take a look at the Selenium documentation on this matter! They’ve web page stuffed with discouraged practices which embrace CAPTCHAs, 2FAs, and logins to web-based e mail/social media websites
I like to recommend studying these hyperlinks. whereas this comes from Selenium, it applies to any related UI take a look at instruments like Cypress, Playwright, and many others!
To sum them up:
CAPTCHAs
CAPTCHA, brief for Utterly Automated Public Turing take a look at to inform
Computer systems and People Aside, is explicitly designed to forestall
automation, so don’t attempt! There are two major methods to get
round CAPTCHA checks:
- Disable CAPTCHAs in your take a look at surroundings
- Add a hook to permit checks to bypass the CAPTCHA
2FA
Automating this seamlessly and constantly is a giant problem in
Selenium. There are some methods to automate this course of. However that may
be one other layer on prime of our Selenium checks and never as safe. So,
you need to keep away from automating 2FA.There are a number of choices to get round 2FA checks:
- Disable 2FA for sure Customers within the take a look at surroundings, with the intention to
use these person credentials within the automation.- Disable 2FA in your take a look at surroundings.
- Disable 2FA if you happen to login from sure IPs. That approach we are able to configure our take a look at machine IPs to keep away from this.
Electronic mail/Social Media
Logging into websites like Gmail and Fb utilizing WebDriver isn’t
advisable. Other than being towards the utilization phrases for these websites
(the place you threat having the account shut down), it’s sluggish and
unreliable.The perfect apply is to make use of the APIs that e mail suppliers supply, or
within the case of Fb the developer instruments service which exposes an
API for creating take a look at accounts, buddies, and so forth. Though utilizing
an API would possibly seem to be a bit of additional laborious work, you can be paid again
in velocity, reliability, and stability. The API can also be unlikely to
change, whereas webpages and HTML locators change typically and require
you to replace your take a look at framework.
Based mostly in your query, you will want to make use of the API from an e mail supplier to get entry to an e mail message.