Skip to content

Conversation

SoCalLongboard
Copy link
Contributor

I've added support for the HTMLUnit remote driver to support headless execution against a selenium-server. Feel free to incorporate if you like. We're currently using this addition in-house at my workplace.

To initiate a session, I employ this keyword:

Open Browser    [initial page url]    remote_url=[the selenium-server url]    browser=htmlunit

Also included is support for the HTMLUnit driver with Javascript support.

@j1z0
Copy link
Contributor

j1z0 commented Jul 1, 2012

@SoCalLongboard

Cool thanks for the patch, I'll merge it in. Question for you. Would your team want a Start Server keyword that actually starts the HTMLUnit server or do you handle that some other way?

j1z0

j1z0 added a commit that referenced this pull request Jul 1, 2012
Add HTMLUnit remote driver support
@j1z0 j1z0 merged commit 11992b2 into robotframework:master Jul 1, 2012
@SoCalLongboard
Copy link
Contributor Author

Thanks!

We actually run selenium-server indefinitely on a dedicated test machine so we wouldn't have an immediate need for such a feature. I do feel that it could be quite useful down the road though as we increase our test/runner volume.

Cheers!

@adwu73
Copy link
Contributor

adwu73 commented Jul 8, 2012

I have already tested this patch on my machine as well, it works great for my simple test. My question for @SoCalLongbroad is that for your project how stable is the html unit? do you notice some js related issue? any tips to prevent them?

Any thing is that I got some exception when I try to run this over selenium grid 2, it seems that I have to start the node with some specific settings, I will feedback when I have more result.

@SoCalLongboard
Copy link
Contributor Author

For our own purposes, we don't engage the JavaScript support but that support was presented as available in the original driver so I included in the manner the upstream sources recommended. I haven't had the occasion to vet the HTMLUnit support within selenium-server where I've had to engage and JavaScript-specific features. I would expect that, given that the HTMLUnit support is implicit to selenium-server, said support could fluctuate across selenium-server releases.

For our own testing world, we're primarily concerned with the accumulation of cookie information after a series of requests, whether redirects behave normally, and whether user optouts result in the correct influence upon the requests. You can check us out at http://www aggregateknowledge.com/ to get a sense of what our business is/does.

@SoCalLongboard
Copy link
Contributor Author

@SoCalLongboard
Copy link
Contributor Author

Out of curiosity, I did a brief exercise in Ruby/irb using the latest selenium-webdriver gem and a pair of selenium-server instances.

Against a stand-alone selenium-server, I can create the driver without problems:

1.9.3p194 :009 > caps = Selenium::WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => true)
=> #<Selenium::WebDriver::Remote::Capabilities:0x007fd67a2f0d98 @capabilities={:browser_name=>"htmlunit", :version=>"", :platform=>:any, :javascript_enabled=>true, :css_selectors_enabled=>false, :takes_screenshot=>false, :native_events=>false, :rotatable=>false, :firefox_profile=>nil, :proxy=>nil}
1.9.3p194 :011 > driver = Selenium::WebDriver.for(:remote, :url => "http://somehost:4444/wd/hub", :desired_capabilities => caps)
=> #<Selenium::WebDriver::Driver:0x..fd83578d45f17ce74 browser=:htmlunit>

If the target selenium-server happens to be running in 'hub' mode, attempts to instantiate the driver in the manner shown above yields an error:

Selenium::WebDriver::Error::UnknownError: Error forwarding the new session cannot find : {platform=ANY, javascriptEnabled=true, cssSelectorsEnabled=false, browserName=htmlunit, nativeEvents=false, rotatable=false, takesScreenshot=false, version=} (org.openqa.grid.common.exception.GridException)
from [remote server] org.openqa.grid.web.servlet.handler.RequestHandler(RequestHandler.java):111:in process' from [remote server] org.openqa.grid.web.servlet.DriverServlet(DriverServlet.java):84:inprocess'
from [remote server] org.openqa.grid.web.servlet.DriverServlet(DriverServlet.java):68:in doPost' from [remote server] javax.servlet.http.HttpServlet(HttpServlet.java):727:inservice'
from [remote server] javax.servlet.http.HttpServlet(HttpServlet.java):820:in service' from [remote server] org.seleniumhq.jetty7.servlet.ServletHolder(ServletHolder.java):565:inhandle'
from [remote server] org.seleniumhq.jetty7.servlet.ServletHandler(ServletHandler.java):479:in doHandle' from [remote server] org.seleniumhq.jetty7.server.session.SessionHandler(SessionHandler.java):225:indoHandle'
from [remote server] org.seleniumhq.jetty7.server.handler.ContextHandler(ContextHandler.java):1031:in doHandle' from [remote server] org.seleniumhq.jetty7.servlet.ServletHandler(ServletHandler.java):406:indoScope'
from [remote server] org.seleniumhq.jetty7.server.session.SessionHandler(SessionHandler.java):186:in doScope' from [remote server] org.seleniumhq.jetty7.server.handler.ContextHandler(ContextHandler.java):965:indoScope'
from [remote server] org.seleniumhq.jetty7.server.handler.ScopedHandler(ScopedHandler.java):117:in handle' from [remote server] org.seleniumhq.jetty7.server.handler.HandlerWrapper(HandlerWrapper.java):111:inhandle'
from [remote server] org.seleniumhq.jetty7.server.Server(Server.java):349:in handle' from [remote server] org.seleniumhq.jetty7.server.AbstractHttpConnection(AbstractHttpConnection.java):452:inhandleRequest'
... 8 levels...
from [remote server] org.seleniumhq.jetty7.util.thread.QueuedThreadPool$3(QueuedThreadPool.java):534:in run' from [remote server] java.lang.Thread(Thread.java):636:inrun'
from /Users/miken/.rvm/gems/ruby-1.9.3-p194@webdriver/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/response.rb:52:in assert_ok' from /Users/miken/.rvm/gems/ruby-1.9.3-p194@webdriver/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/response.rb:15:ininitialize'
from /Users/miken/.rvm/gems/ruby-1.9.3-p194@webdriver/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/http/common.rb:59:in new' from /Users/miken/.rvm/gems/ruby-1.9.3-p194@webdriver/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/http/common.rb:59:increate_response'
from /Users/miken/.rvm/gems/ruby-1.9.3-p194@webdriver/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/http/default.rb:59:in request' from /Users/miken/.rvm/gems/ruby-1.9.3-p194@webdriver/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/http/common.rb:40:incall'
from /Users/miken/.rvm/gems/ruby-1.9.3-p194@webdriver/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/bridge.rb:598:in raw_execute' from /Users/miken/.rvm/gems/ruby-1.9.3-p194@webdriver/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/bridge.rb:92:increate_session'
from /Users/miken/.rvm/gems/ruby-1.9.3-p194@webdriver/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/remote/bridge.rb:68:in initialize' from /Users/miken/.rvm/gems/ruby-1.9.3-p194@webdriver/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/common/driver.rb:33:innew'
from /Users/miken/.rvm/gems/ruby-1.9.3-p194@webdriver/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/common/driver.rb:33:in for' from /Users/miken/.rvm/gems/ruby-1.9.3-p194@webdriver/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver.rb:65:infor'
from (irb):44
from /Users/miken/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `

'

...and the driver does not instantiate.

My assumption here is that the hang-up is on the selenium-server side of the equation. It may just be a limitation of the HTMLUnit support of the driver to only work against standalone selenium-server and not in the grid2 (hub/nodes) context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants