follow me icons

Monday, July 2, 2012

Webdriver can't click element in IE

The issue that I have is that the capybara/selenium webdriver method of click element does not seem to work in IE.
  find(:css, ".submit").click #does not seem to click the element in IE
This method works fine in other browsers like FF. When I try to just find the element by using the
  find(:css, ".submit")
  it can return this:  #<Capybara::Element tag="input">
Apparently this is because I accidentally change the zoom level in Internet Explorer. To fix this issue simply set the zoom level to be 100%.

Wednesday, June 20, 2012

IE webdriver maximize window

Running cucumber test with webdriver in Internet Explorer browser has alot of issues. One issue that I encounter is that the IE browser window is not opening in a maximized state. Apparently, webdriver needs to have IE browser fully maximize in order for webdriver to be able to locate elements. A workaround that I use is to maximize the IE browser on my first cucumber steps. To change/resize the browser window:
#need to check the browser version is IE via webdriver as other browsers like ff and chrome do not to be maximised
if(page.driver.browser.browser.to_s == "internet_explorer")
  page.driver.browser.manage.window.maximize
end

IE undefined method map for nil class

I get the following error when running webdriver in IE 7 and 8. I am using ruby, Capybara with selenium webdriver version 2.2.24
Undefined method `map` for nil:NilClass (NoMethodError)
or
NoMethodError Exception: undefined method `map` for nil:NilClass
It seems that IE stand alone webdriver could not switch between http to https then to http again correctly and therefore it could not find any of the DOM element. This also cause the error of unable to delete cookie in IE
Selenium::WebDriver::Error:JavascriptError Exception: Unable to delete cookie with name 'cookiename'
The workaround that I have for this Internet explorer webdriver issue is to start the session with https instead of http. This seem to have solve the issue. Alternatively, during the session you can make the test to visit a https page and then visit the current page again.

Capybara refresh back forward a page

To refresh a page in Capybara using selenium webdriver simply call the webdriver method directly
page.driver.browser.navigate.refresh (to, back, forward)

or

you can use the visit 'url' method