Гугл подсказал, что HtmlUnitDriver работает быстрее чем ChromeDriver. Даже быстрее чем PhantomJS
Начал пробовать.
Сперва запустил сам Java server:
java -jar selenium-server-standalone-2.53.0.jar
Ну и сам код:
from selenium import webdriver
b = webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.HTMLUNITWITHJS)
или:
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
b = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=DesiredCapabilities.HTMLUNITWITHJS)
Не работает
Даже при запуске сервера Java в консоли предупреждения:
09:01:45.629 INFO - Launching a standalone Selenium Server
09:01:45.704 INFO - Java: Oracle Corporation 25.25-b02
09:01:45.704 INFO - OS: Windows 7 6.1 x86
09:01:45.717 INFO - v2.53.0, with Core v2.53.0. Built from revision 35ae25b
09:01:45.788 INFO - Driver class not found: com.opera.core.systems.OperaDriver
09:01:45.788 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
09:01:45.797 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped: registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform VISTA
09:01:45.798 INFO - Driver class not found: org.openqa.selenium.htmlunit.HtmlUnitDriver
09:01:45.798 INFO - Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered
09:01:45.907 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
09:01:45.908 INFO - Selenium Server is up and running
Питон вернул:
Traceback (most recent call last):
File "unit.py", line 2, in <module>
b = webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.HTMLUNITWITHJS)
File "d:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 87, in __init__
self.start_session(desired_capabilities, browser_profile)
File "d:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 136, in start_session 'desiredCapabilities': desired_capabilities,
File "d:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 196, in execute
self.error_handler.check_response(response)
File "d:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 181, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: The best matching driver provider org.openqa.selenium.ie.InternetExplorerDriver can't create a new driver instance for Capabilities [{browserName=htmlunit, javascriptEnabled=true, version=firefox, platform=ANY}]
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'WWW-EUROMED', ip: '192.168.3.239', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_25'
Driver info: driver.version: unknownStacktrace:
at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance (DefaultDriverFactory.java:62)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call (DefaultSession.java:222)
at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call (DefaultSession.java:1)
at java.util.concurrent.FutureTask.run (None:-1)
at org.openqa.selenium.remote.server.DefaultSession$1.run (DefaultSession.java:176)
at java.util.concurrent.ThreadPoolExecutor.runWorker (None:-1)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (None:-1)
at java.lang.Thread.run (None:-1)
Что я упустил?