For some reason, after entering a site like gmail, htmlunit does not work. It cannot find html elements.
Below is a very simple ruby script that shows the problem, note that it is assumed that the webdriver server is running on the same computer on which it is running:
require 'rubygems'
require 'watir-webdriver'
require 'rspec/expectations'
capabilities = Selenium::WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => true)
browser = Watir::Browser.new(:remote, :url => "http://127.0.0.1:4444/wd/hub", :desired_capabilities => capabilities)
browser.goto "http://gmail.com"
browser.text_field(:id,'Email').set 'roberttestingstuff041'
browser.text_field(:id,'Passwd').set 'k4238chsj55983w'
browser.button(:id,'signIn').click
sleep 5.0
frame = browser.frame(:id,'canvas_frame')
frame.link(:text, 'Sign out').exist?.should == true
frame.link(:text, 'Sign out').visible?.should == true
frame.div(:id, 'guser').exist?.should == true
frame.div(:text,'Compose mail').exist?.should == true
Please note: if I create a browser object using firefox or IE, this simple test works.
It seems to be stuck on redirects that occur during the login process. The site I'm really trying to check follows a very similar pattern, so I installed this simplified example using gmail, which seems to show the same problem.
- ? , Celerity, HTMLUnit, , - ?
, webdriver, , :
12:31:16.321 INFO - WebDriver remote server: INFO: Executing: [find element: By.xpath: .
] at URL: /session/1297704604365/element)
12:31:17.996 WARN - WebDriver remote server: WARN:
org.openqa.selenium.NoSuchElementException: Unable to locate a node using .
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_21'
Driver info: driver.version: EventFiringWebDriver
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElementByXPath(HtmlUnitDriver.java:699)
at org.openqa.selenium.By$6.findElement(By.java:205)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$4.call(HtmlUnitDriver.java:1133)