i trying automate application consist of nested iframes. first approach watir-webdriver taking way long fill each field , i've enter many. example of element in page class below:
in_iframe(:id => 'something') |frame| in_iframe({:id => 'something'}, frame) |frame| in_iframe({:id => 'something'}, frame) |frame| in_iframe({:id => 'something'}, frame) |frame| in_iframe({:id => 'something'}, frame) |frame| text_field(:first_name, :id => 'something', :frame => frame) end end end end end
after trying out watir-webdriver, decided go ahead selenium-webdriver getting staleelementreferenceerror repeatedly. kept begin rescue retry block avoid keeps throwing error.
all elements stored in page class , using populate_page_with method of page class enter values.
my_step.rb
when /^i (?:select|fill in) "(.*)" (.+) (?:text field|drop down)$/ |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') |frame| in_iframe({:id => 'something'},frame) |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 enter same drop down selenium functions , 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 call step enter same drop down again throws staleelementreferenceerror error. not sure causing this. also, please let me know if can follow other approach speed execution because watir-webdriver took around 10 minutes fill 2 screen 20% of target.
default content believe got root page, need navigate bath through parent frame beginning.
consider different recursive method.
Comments
Post a Comment