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

Option to reduce 'bloat' to reduce usage for higher thread number #2393

AlexPaiva started this conversation in Ideas
Discussion options

A simple option that when enabled removes a lot of bloat from chrome where the goal is to reach a higher thread number where every less mb of consumption counts. Just getting it out there if it's doable, have seen a few people asking for reducing memory and cpu usage on high threads.

You must be logged in to vote

Replies: 5 comments 17 replies

Comment options

Are you referring to pytest multithreading internals or Chrome internals? pytest is a separate repo, and Chrome can be configured via various Selenium options available. Not everything about Chrome can be configured though.

You must be logged in to vote
2 replies
Comment options

Both, and my question was aswell where can I find the options for that?

Comment options

pytest has its own repo: https://github.com/pytest-dev/pytest (lots of command-line options).
It also has several plugins, such as pytest-xdist (which provides the multithreading options):
https://github.com/pytest-dev/pytest-xdist

For a list of Chromium command-line options, see: https://peter.sh/experiments/chromium-command-line-switches/
SeleniumBase already uses many of them, and has its own args for enabling the ones that aren't enabled by default.
Use SeleniumBase's chromium_arg to pass a list of comma-separated Chromium args if there's no direct arg for it.

Comment options

pytest has its own repo: https://github.com/pytest-dev/pytest (lots of command-line options). It also has several plugins, such as pytest-xdist (which provides the multithreading options): https://github.com/pytest-dev/pytest-xdist

For a list of Chromium command-line options, see: https://peter.sh/experiments/chromium-command-line-switches/ SeleniumBase already uses many of them, and has its own args for enabling the ones that aren't enabled by default. Use SeleniumBase's chromium_arg to pass a list of comma-separated Chromium args if there's no direct arg for it.

Where can I find the list of the sb list of args?

You must be logged in to vote
3 replies
Comment options

The SeleniumBase pytest args are listed here: SeleniumBase/help_docs/customizing_test_runs.md

Comment options

I meant for the raw driver

Comment options

Comment options

Got it, thanks! When I am using a pytest xdist do I select multi_proxy on the raw driver?

You must be logged in to vote
6 replies
Comment options

More info on using multiple proxies: #1832 (comment)

Comment options

Got it, thanks!

Quick question, for raw driver how do I change window height/width? I assume 'd_width=None, # Set device width
d_height=None, # Set device height
d_p_r=None, # Set device pixel ratio' are different and relating to different things? if so, what exactly?

Comment options

Those are for mobile device metrics. (Something different, only for mobile mode.)

You want this: driver.set_window_size(width, height)

(It is set after the browser is launched.)

Comment options

Ah ok I see, where can I find the list of the '.sets' available for raw driver such as that one?

Comment options

If it's already included with raw selenium (eg. driver.set_window_size(width, height)), then it won't be listed in the SeleniumBase Docs. (It's probably already somewhere in the Selenium Docs.)

But there is a section for driver methods that were added in SeleniumBase: #2200 (comment)

Comment options

In regards to the thread I meant if there was a way to actually remove things that weight the browser down or change the binary itself or something related but I assume that's creating a new browser?

You must be logged in to vote
3 replies
Comment options

I'm not sure what you mean by this. Chrome is what it is. There are options available so that you can customize Chrome. SeleniumBase provides command-line options and method args for making those customizations, as listed in the comments above.

Comment options

I meant modify the Chromium source code itself then rebuild to be used with selenium base or is this just making it detectable and maybe a monkeypatch is better or?

Comment options

"modify the Chromium source code"

I don't know anything about that. UC Mode modifies chromedriver (not Chrome / Chromium).
Most Chromium browsers are just modified versions of Chrome anyway (eg. Brave or Opera).

Comment options

"modify the Chromium source code"

I don't know anything about that. UC Mode modifies chromedriver (not Chrome / Chromium). Most Chromium browsers are just modified versions of Chrome anyway (eg. Brave or Opera).

Yes that's what I meant, so one could technically modify the chromedriver directly and perform direct changes on it?

You must be logged in to vote
3 replies
Comment options

That's what undetected/patcher.py does.

Comment options

Noted, just a quick question, how do you know here where to and what to patch if you have the time to do a quick walkthrough?

def patch_exe(self):
 """Patches the ChromeDriver binary"""
 def gen_js_whitespaces(match):
 return b"\n" * len(match.group())
 def gen_call_function_js_cache_name(match):
 rep_len = len(match.group()) - 3
 ran_len = random.randint(6, rep_len)
 bb = b"'" + bytes(str().join(random.choices(
 population=string.ascii_letters, k=ran_len
 )), 'ascii') + b"';" + (b"\n" * (rep_len - ran_len))
 return bb
 with io.open(self.executable_path, "r+b") as fh:
 file_bin = fh.read()
 file_bin = re.sub(
 b"window\\.cdc_[a-zA-Z0-9]{22}_"
 b"(Array|Promise|Symbol|Object|Proxy|JSON)"
 b" = window\\.(Array|Promise|Symbol|Object|Proxy|JSON);",
 gen_js_whitespaces,
 file_bin,
 )
 file_bin = re.sub(
 b"window\\.cdc_[a-zA-Z0-9]{22}_"
 b"(Array|Promise|Symbol|Object|Proxy|JSON) \\|\\|",
 gen_js_whitespaces,
 file_bin,
 )
 file_bin = re.sub(
 b"'\\$cdc_[a-zA-Z0-9]{22}_';",
 gen_call_function_js_cache_name,
 file_bin,
 )
 fh.seek(0)
 fh.write(file_bin)
 return True
Comment options

You should ask the maintainer of undetected-chromedriver.
It came from undetected_chromedriver/patcher.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet

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