follow me icons

Wednesday, August 22, 2012

Ignore browser untrusted security certificate

To ignore the browser untrusted security certificate so that the cucumber test can be run in the test environment you can modify the env.rb to ignore the warning:
require 'selenium/webdriver'

Capybara.register_driver :selenium do |app|
   profile = Selenium::WebDriver::Firefox::Profile.new
   profile.assume_untrusted_certificate_issuer = false
   Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile)
end

Tuesday, August 14, 2012

file upload using capybara

To put the file name into the file upload dialog box with Capybara we can use the following Selenium webdriver method. We can use the Ruby code Dir.pwd to get the current working directory path.
page.driver.browser.find_element(:id, "fileUploadId").send_keys 
(Dir.pwd + "file upload path")

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