Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Documenting the selenium-stealth integration with UC Mode #2404

Open
Assignees
Labels
@mdmintz

Description

Documenting the selenium-stealth integration with UC Mode

(Info: selenium-stealth lets you mask your web browser's fingerprint and WebGL information.)

Prerequisites: selenium-stealth must be installed separately: pip install selenium-stealth

Here's an example of the selenium-stealth integration with the Driver() manager and UC Mode:

from seleniumbase import Driver
from selenium_stealth import stealth
driver = Driver(uc=True)
stealth(
 driver,
 languages=["en-US", "en"],
 vendor="Google Inc.",
 platform="Win32",
 webgl_vendor="Intel Inc.",
 renderer="Intel Iris OpenGL Engine",
 fix_hairline=True,
)
driver.get("https://browserleaks.com/webrtc")
driver.sleep(10)
driver.quit()

selenium-stealth also integrates with SeleniumBase BaseCase formats:

Use Syntax Format 2 to override the setUp() method so that selenium-stealth settings are used:

from seleniumbase import BaseCase
from selenium_stealth import stealth
class BaseTestCase(BaseCase):
 def setUp(self):
 super().setUp()
 stealth(self.driver,
 languages=["en-US", "en"],
 vendor="Google Inc.",
 platform="Win32",
 webgl_vendor="Intel Inc.",
 renderer="Intel Iris OpenGL Engine",
 fix_hairline=True,
 )

Then have your test classes inherit BaseTestCase instead of BaseCase.
(See SeleniumBase/help_docs/syntax_formats.md#sb_sf_02 for details.)

To activate UC Mode in BaseCase formats, use --uc as a pytest command-line option:

pytest --uc

For general information about selenium-stealth, see:


For general information about UC Mode, see #2213

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /