Evading Selenium Detection: The Ultimate Guide

What guide do you want to see next


  • Total voters
    108
I recently moved from Selenium to Playwright and all i can say is that i will never look back. (Way) better documentation, no need to wait for elements (as it does that already under the hood), more readable code in general and more stable. You should definitely try that out!
I moved to PlayWright foe few days till now. Everything is good. I'm learning PlayWright Python.
Do you use PlayWright with Python or Java?

I have a question that what is the best plugin for PlayWright Steath that hide from bot detection?
I'm planning using it with antidetect browser
 
Do you use PlayWright with Python or Java?
I'm using playwright for python.

I have a question that what is the best plugin for PlayWright Steath that hide from bot detection?
I'm planning using it with antidetect browser
I never used an antidetect browser with it. Just chromium. I do tweak a bit though (change window-size, user-agent spoofing, etc.).
 
I have a question that what is the best plugin for PlayWright Steath that hide from bot detection?
I'm planning using it with antidetect browser

Update: i achieved very good stealth with the following:

Python:
class Browser:
    def __init__(self, user_agent=None, proxy_url=None, headless=False, timeout=15):
        self.playwright = sync_playwright().start()

        self.browser = self.playwright.firefox.launch(
            headless=headless,
            proxy={"server": proxy_url} if proxy_url else None,
        )

        self.ctx = self.browser.new_context(
            user_agent=user_agent, viewport={"width": 1920, "height": 1080}
        )

        self.ctx.add_init_script(
            "Object.defineProperty(navigator, 'webdriver', {get: () => undefined})"
        )

        # WebRTC leak prevention
        self.ctx.add_init_script(
        """
        if (window.RTCPeerConnection) {
            const originalRTCPeerConnection = window.RTCPeerConnection;
            window.RTCPeerConnection = function(config) {
                if (config && config.iceServers) {
                    config.iceServers = []; // Remove all iceServers to prevent IP leakage
                }
                return new originalRTCPeerConnection(config);
            };
            window.RTCPeerConnection.prototype = originalRTCPeerConnection.prototype;
        }

        window.RTCSessionDescription = undefined;
        window.RTCIceCandidate = undefined;
        """
        )

        self.page = self.ctx.new_page()
        self.page.set_default_navigation_timeout(timeout * 1000)
 
I'm intergrated PlayWright with Kameleo, the antidectect browser.
The browser have many option for fingerprint, do you think that enough?
depends on the exact case. if we talk about like a pretty good WAF and anti-bot system, then it’s not enough, since even your network stack leaves a lot of fingerprints (TCP etc). also it depends on how you actually automate your browser, how you move your mouse etc (I used to implement curve-like pathways for mouse cursor etc). it’s always a cat and mouse game and there is no silver bullet, you should dive deep into how such systems work to use your bot in the long run
 
Wow someone put in the work, thanks for this share! Was hoping this wouldn't be a real project but definitely seems to be, but very grateful for all the time you just saved!
 

1. Modifying WebDriver Properties - Simple and well known


  • Disabling the navigator.webdriver Flag: This involves injecting JavaScript code to overwrite or mask the navigator.webdriver property.
  • https://stackoverflow.com/questions/60409219/how-do-you-disable-navigator-webdriver-in-chromedriver#60409220
  • https://thewebdev.info/2022/04/03/how-to-modify-navigator-webdriver-flag-to-prevent-selenium-detection-with-python-selenium/

I know you've mentioned that it's simple and well-known but be careful about this one! its possible to determine through analysis of Javascript object properties whether something has been overridden or spoofed via Object.DefineProperty by calling the prototypes 'toString' or iterating through the objects properties or keys

For example Object.getownpropertydescriptor(navigator) should return an empty array in normal browsers. When this is called in the console, any property that's been spoofed or lied about would appear in this array making it trivial to see that your browser is up to no good - you'd need to override the toString and actual prototype as well
 
I know you've mentioned that it's simple and well-known but be careful about this one! its possible to determine through analysis of Javascript object properties whether something has been overridden or spoofed via Object.DefineProperty by calling the prototypes 'toString' or iterating through the objects properties or keys

For example Object.getownpropertydescriptor(navigator) should return an empty array in normal browsers. When this is called in the console, any property that's been spoofed or lied about would appear in this array making it trivial to see that your browser is up to no good - you'd need to override the toString and actual prototype as well
Even the prototype method isn't enough IIRC - - Navigator properties are now triangulated between the reported values and webworkers + serviceworkers, so the real values can easily be leaked. I haven't come across any open-source solution to this.
 
Last edited:
I want:

Evading Detection: The Ultimate selenium Guide.​


Not

Evading Selenium Detection: The Ultimate Guide, if I want that I best work at Google and get in house training with a degree provided i have one to do that.​


Makes you lose credibility on what selenium is, but English may not be your first language so I'll be considerate.
 
I want:

Evading Detection: The Ultimate selenium Guide.​


Not

Evading Selenium Detection: The Ultimate Guide, if I want that I best work at Google and get in house training with a degree provided i have one to do that.​


Makes you lose credibility on what selenium is, but English may not be your first language so I'll be considerate.
I'm a little confused here by what you are talking about, as both titles pretty much convey the same message and are semantically identical.

Is that the only thing you've picked out? :D

I know exactly what Selenium is hence why I made this guide.

As to whether my English in this post is fluent or up to the standards of a native, anyone who is actually adept in English can make that judgment for themselves.
 
I'm a little confused here by what you are talking about, as both titles pretty much convey the same message and are semantically identical.

Is that the only thing you've picked out? :D

I know exactly what Selenium is hence why I made this guide.

As to whether my English in this post is fluent or up to the standards of a native, anyone who is actually adept in English can make that judgment for themselves.
Well then, I guess that sums up that then, you've explained enough.
 
I'm a little confused here by what you are talking about, as both titles pretty much convey the same message and are semantically identical.

Is that the only thing you've picked out? :D

I know exactly what Selenium is hence why I made this guide.

As to whether my English in this post is fluent or up to the standards of a native, anyone who is actually adept in English can make that judgment for themselves.
I think this guy must be the most pedantic user of BHW. I think he means that Evading Selenium Detection sounds like Selenium is the one detecting something, you describe how to use selenium to go undetected.
Anyway I see one user elaborating an extensive and detailed list of how to avoid detection and another user just talking shit about the wording of the title without adding any useful info...
It´s pretty clear to me who is the expert.
 
thank you for share, any suggestion for facebook botting (post/etc) how to make undetect when using c# n selenium, because i try to create auto post, after few post my acc get banned, been try using undetect chromium n random time loop but still get banned after 10++ repeat work
 
Back
Top