Situation :
User want to click the field which is placed within 2 IFrames using selenium webdriver.
Field — Friendship
Source code for “Friendship” — <nobr>Friendship</nobr>
Frame ID’s –” nav” and “JobplaceFrame”
Code:
require ‘rubygems’
require ‘selenium-webdriver’
$browser = Selenium::WebDriver.for :ie
$browser.get "http://URL.com”
current_title=$browser.title
if current_title == “TITLE OF THE WEBPAGE”
puts “step 1 passed”
else
puts “step1 failed”
exit
end
$browser.switch_to.frame(‘nav’) #parent Frame
$browser.switch_to.frame(“JobplaceFrame”) #Child frame
options=$browser.find_elements(:tag_name=>”nobr”)
options.each do |nobr_field|
if nobr_field.text == 'Friendship'
nobr_field.click
break
end
end