Open mdmintz opened 9 months ago
class WebDriver:
def __init__(self):
ua = UserAgent()
# Create an instance of the undetected ChromeDriver in headless mode
options = uc.ChromeOptions()
# ua.google
options.add_argument(f'--user-agent={ua.google}')
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')
prefs = {}
prefs["credentials_enable_service"] = False
prefs["profile.password_manager_enabled"] = False
options.add_experimental_option("prefs", prefs)
self.driver = Driver(uc=True, incognito=True, options=options)
# self.driver = uc.Chrome(options=options)
First of all, I congratulate you on your project, it's crazy, but I would like to ask you how I would go about adding options. How i can do something like that?
@boludoz, thank you. Most of those are already being set automatically as needed for UC Mode.
You can change the agent with agent=AGENT
(but if you change the one that SeleniumBase already sets automatically, then you could be detected). There's also chromium_arg="--some-arg,--another-arg=VALUE"
for more args, comma-separated. Be sure not to set something twice that is already being set, as that could get you detected.
That assumes you are using the Driver
format: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_uc_mode.py
You have done a great job, I really congratulate you!
@boludoz, thank you. Most of those are already being set automatically as needed for UC Mode.
You can change the agent with
agent=AGENT
(but if you change the one that SeleniumBase already sets automatically, then you could be detected). There's alsochromium_arg="--some-arg,--another-arg=VALUE"
for more args, comma-separated. Be sure not to set something twice that is already being set, as that could get you detected.That assumes you are using the
Driver
format: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_uc_mode.py
First and foremost, I express my gratitude for developing such an excellent framework.
I am currently encountering a small issue. I wish to utilize the Socks5 option in SeleniumBase, similar to how I would in normal uc mode. However, I am unable to find an argument option for this. Could you kindly provide a boilerplate code snippet, considering that I have a 'proxylist.txt' file and need to randomly select a proxy for each test run without manually specifying them one by one in pytest?
I've been using the following code snippet for regular mode:
options.add_argument(f"--proxy-server=socks5://{proxy_address}:{proxy_port}")
I would appreciate any guidance or assistance you can offer. Thank you.
@bbajwa346 https://github.com/seleniumbase/SeleniumBase/blob/31020e4ae9644596460e9606312f94bc420aff51/seleniumbase/plugins/driver_manager.py#L74 For socks5, use “socks5://“ in your “proxy” arg.
@bbajwa346
For socks5, use “socks5://“ in your “proxy” arg.
Thank You So Much, Resolved instantly !!!
@bbajwa346
For socks5, use “socks5://“ in your “proxy” arg.
Dear mdmintz,
one more very minor issue
from seleniumbase import Driver
driver = Driver()
driver.open("https://seleniumbase.io/coffee/")
driver.open_new_window()
# switch to new tab
driver.switch_to_window(1)
driver.open("https://google.com/")
`
I get this error
driver.open_new_window() ^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'WebDriver' object has no attribute 'open_new_window'
unable to open new tab or switch between them
@bbajwa346 open_new_window()
is not a driver-specific method. (At least not yet.) The driver already has its own methods for doing those things.
Open a new tab and switch to it:
driver.switch_to.new_window("tab")
Open a new tab and stay on the current tab:
driver.execute_script("window.open('');")
The standard SeleniumBase syntax formats have a lot more methods than what the driver has.
Documenting
driver
-specific methods added by SeleniumBaseBecause there are Syntax Formats that use the
driver
API directly, these methods have been added directly into the documentation in the method_summary.md file: https://github.com/seleniumbase/SeleniumBase/commit/88fcf7ea50911b83d7da72346b454bb4da8adde8Here are example tests that use those direct
driver
methods: