Reputation: 175
is there any way to check when runninng selenium webdriver from python or puppeteer from javascript if the website that i'm visiting is detecting that i'm running a bot? are there any websites that tell you if you would fail a bot test? (ex.: cloudflare or captcha)
thanks
Upvotes: 3
Views: 3581
Reputation: 41
I'm one of the authors mentioned in the responses above. Bot detection evolves frequently so I wrote an updated article to explain how (headless) Chrome (even when modified) instrumented with Selenium can be detected as of June 2024. I also created a test page so that you can verify if your bot is detected.
Testing the presence of the HeadlessChrome
substring in the user agent and verifying the value of navigator.webdriver
is still helpful against bots that don't modify too much their fingerprint.
Otherwise, there is a new detection techniques that aims to detect CDP automation (Chrome devtool protocol) used by instrumentation frameworks like Selenium.
The new test looks as follows:
var cdpDetected = false;
var e = new Error();
Object.defineProperty(e, 'stack', {
get() {
cdpDetected = true;
}
});
// This is part of the detection, the console.log shouldn't be removed!
console.log(e);
if (cdpDetected) {
isBot = true;
}
Upvotes: 2
Reputation: 175
thank you for the answer. i managed to find a couple more resources. here is a list of everything i found:
https://nowsecure.nl/ (thanks to user Michael Mintz)
https://bot.sannysoft.com
https://browserleaks.com/
https://bot.incolumitas.com/
https://fingerprintjs.github.io/fingerprintjs/
https://antoinevastel.com/bots/
https://www.google.com/recaptcha/api2/demo
https://recaptcha-demo.appspot.com/
out of all the websites i found browserleaks and incolumnitas to be the most comprehensive. i'll leave the question open, feel free anyone to add some more if you know.
Upvotes: 4
Reputation: 15536
Here's the bot test for Cloudflare: https://nowsecure.nl (If Selenium/automation is detected, it will keep loading the page forever. If you bypassed detection, you'll see blinking lights that you passed.)
There's a Python library that lets you get past that bot blocker: undetected-chromedriver
That tool has been integrated into SeleniumBase so that you can bypass bot detection as a pytest command-line option (--uc
) for your Selenium Python tests:
pytest --uc
.
Upvotes: 2