I am trying to automate an application with consist of nested iframes. My First approach was with watir-webdriver but it is taking way too long to fill each field and I've enter many. An example of an element in my page class is below:
in_iframe(:id => 'something') do |frame|
in_iframe({:id => 'something'}, frame) do |frame|
in_iframe({:id => 'something'}, frame) do |frame|
in_iframe({:id => 'something'}, frame) do |frame|
in_iframe({:id => 'something'}, frame) do |frame|
text_field(:first_name, :id => 'something', :frame => frame)
end
end
end
end
end
After trying out with watir-webdriver, I decided to go ahead with selenium-webdriver but i am getting StaleElementReferenceError repeatedly. I even kept a begin rescue retry block to avoid this but it keeps throwing the error.
All the elements are stored in page class and i am using populate_page_with method of page class to enter values.
my_step.rb
When /^I (?:select|fill in) "(.*)" for (.+) (?:text field|drop down)$/ do |value, page_element|
wait = Selenium::WebDriver::Wait.new(:timeout => 30)
wait.until { @current_page.send(page_element.gsub(" ","_").downcase + "_element").exists? }
@current_page.enter_element_value(page_element, value)
end
my_page.rb
class MyPage
include PageObject
in_iframe(:id => 'something') do |frame|
in_iframe({:id => 'something'},frame) do |frame|
text_field(:my_element, :id => 'something', :frame => frame)
end
end
end
enter_element_value function
def enter_element_value(field, value)
populate_page_with "#{field.downcase.gsub(' ','_')}".to_sym => value
end
I tried to enter the same drop down with selenium functions and i was able to
sleep 5
@browser.switch_to.frame('GFXLoanSelectorFrame')
@browser.find_element(:id => 'lsProcCombo').find_elements(:tag_name => 'option')[1].click
@browser.switch_to.default_content
And if I call my step to enter the same drop down again it throws the StaleElementReferenceError error. I am not sure what exactly is causing this. Also, Please let me know if I can follow any other approach to speed up the execution because with watir-webdriver it took around 10 minutes to fill only 2 screen which is like 20% of my target.