I'm using selenium-4.1.0 and I'm searching for the lightest webdriver possible (for speed purpose).
I heard about HtmlUnitDriver, but when using python, I need to run a selenium server before trying to use the driver.
I was careful to take the version corresponding to my selenium version (available here), and I followed exactly the steps to make it work; but it didn't.
After running java -jar selenium-server-4.1.0.jar standalone (running on localhost:4444):
I tried:
from selenium import webdriver
driver = webdriver.Remote(
command_executor='http://localhost:4444/wd/hub', # I also tried with 'http://localhost:4444', and without 'command_executor' keyword
desired_capabilities=webdriver.DesiredCapabilities.HTMLUNITWITHJS
)
driver.get('http://www.google.com')
And I got the following error:
DeprecationWarning: desired_capabilities has been deprecated, please pass in an Options object with options kwarg
driver = webdriver.Remote(
So I changed my code to:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.headless = True
wd = webdriver.Remote('http://localhost:4444/wd/hub', options=options)
wd.get('http://www.google.com')
wd.save_screenshot('screenshot.png')
And it worked (I got the screenshot), but then I was no longer using HtmlUnit.
Does anyone know what's wrong and/or what I could do to make it work ?
In the python library the selenium is best to take the screenshot. In this below code the I am keeping URL scrolling also if you need you can do neither leave it.
In this you want to check the chrome version and install the chrome drivers. My chrome version is 96.0.4664.110 download that drivers and install