1

I'm interesting in running my Selenium test scripts and using HTML Unit as my browser/driver. Is it possible to use HTML with Python? I tried using

driver = webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.HTMLUNITWITHJS)
driver.get("google.com")

but I get the following response:

Traceback (most recent call last):
  File ".\testtesttest.py", line 7, in <module>
    driver.get("google.com")
  File "C:\Users\slawi\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 326, in get
    self.execute(Command.GET, {'url': url})
  File "C:\Users\slawi\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 314, in execute
    self.error_handler.check_response(response)
  File "C:\Users\slawi\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: java.net.MalformedURLException: no protocol: google.com
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:13:22.693Z'
System info: host: 'DESKTOP-16VCI25', ip: '192.168.139.1', os.name: 'Windows 10', os.arch: 'x86', os.version: '10.0', java.version: '1.8.0_101'
Driver info: driver.version: HtmlUnitDriver
Stacktrace:
    at org.openqa.selenium.htmlunit.HtmlUnitDriver.get (HtmlUnitDriver.java:667)
    at org.openqa.selenium.remote.server.handler.ChangeUrl.call (ChangeUrl.java:40)
    at org.openqa.selenium.remote.server.handler.ChangeUrl.call (ChangeUrl.java:25)
    at org.openqa.selenium.remote.server.handler.WebDriverHandler.handle (WebDriverHandler.java:41)
    at org.openqa.selenium.remote.server.rest.ResultConfig.handle (ResultConfig.java:113)
    at org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest (JsonHttpCommandHandler.java:186)
    at org.openqa.selenium.remote.server.InMemorySession.execute (InMemorySession.java:82)
    at org.openqa.selenium.remote.server.WebDriverServlet.lambda$handle$3 (WebDriverServlet.java:250)
    at java.util.concurrent.Executors$RunnableAdapter.call (None:-1)
    at java.util.concurrent.FutureTask.run (None:-1)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (None:-1)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (None:-1)
    at java.lang.Thread.run (None:-1)

Thanks!

1 Answer 1

1

With the current stacktrace, I think the problem is with the URL protocol that you are using. Use -

driver.get("https://www.google.com")
Sign up to request clarification or add additional context in comments.

1 Comment

Good catch, error trace log selenium.common.exceptions.WebDriverException: Message: java.net.MalformedURLException: no protocol: google.com confirms it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.