How to handle elements in Frames and Tables

84 views
Skip to first unread message

Gmafz7

unread,
Feb 24, 2011, 4:54:37 PM2/24/11
to TestWise
I'm having some issues accesing some links who are inside a Frame and
Tables.
I've been trying to pull it by myself but with no success.
This is the code I have so far

I included this beforehand:
require 'nokogiri'

//
#Here I Log In, etc
enter_text("some", "pass")
enter_text("password", "hnsc")
click_button_with_image("/images/ci/formbtns/login_off.gif")
//

This is where I try to click the link, I tried using something called
xFirePath in Firefox, using this example:
http://www.layeredthoughts.com/automation/how-to-write-your-first-ruby-web-bot-in-watir-scraping-weather-com

Then I found this document, where in the beginning of Page 2, it
indicates that there are some issues between Watir and Frames.
(Although I'm using right now the RWebSpec code generated by Testwise
Recorder)

//
# can't yet handle followFrame
page_html = Nokogiri::HTML.parse(browser.html)

# Using xFirePath in Firefox I obtain the following xPath, where I
supposedly extract the text
#First the HTML

<a target="_top" href=" /webapps/portal/frameset.jsp?
tab_id=_2_1&amp;url=%2fwebapps%2fblackboard%2fexecute%2flauncher%3ftype
%3dCourse%26id%3d_490590_1%26url%3d">LIU1.TSHE.PRBL.SP.2010FD34B.1</a>

If I just use click_link("LIU1.TSHE.PRBL.SP.2010FD34B.1")

#Now I use xpath to extract the text written above, hoping to make
click link work
texto = page_html.xpath("/html/body/table/tbody/tr/td[3]/table/
tbody/tr[2]/td[1]/table/tbody/tr/td/table[2]/tbody/tr/td/table/tbody/
tr/td/table[1]/tbody/tr[2]/th/font/a").inner_text


Now I try to ways to click the link

Watir:
browser.link(:url, html/body/table[1]/tbody/tr/td[1]/table/tbody/
tr[1]/td[2]/a/img).click

RWebSpec:
click_link(texto)


Sorry if this post is a mess, I was in a hurry. I'll try to explain
myself better promptly

P.S. I have another idea, since this link I'm trying to access, is
only one from many within that frame.
Is there a way to, like, use the DOM to create a list that I can use
readily.
I don't know much maybe I'm speaking gibberish, but I'm trying to
learn all of this, the best I can.

Zhimin

unread,
Feb 25, 2011, 12:41:06 AM2/25/11
to TestWise
The access frames in Watir, use the syntax below

frame(:id, "Frame1).link(:text, "some link").click

You can have a look at examples in TestWise's reference projects
(under samples\reference).

P.S. TestWise Recorder is not frame aware.

Zhimin

On Feb 25, 7:54 am, Gmafz7 <gralon...@gmail.com> wrote:
> I'm having some issues accesing some links who are inside a Frame and
> Tables.
> I've been trying to pull it by myself but with no success.
> This is the code I have so far
>
> I included this beforehand:
> require 'nokogiri'
>
>    //
>    #Here I Log In, etc
>    enter_text("some", "pass")
>    enter_text("password", "hnsc")
>    click_button_with_image("/images/ci/formbtns/login_off.gif")
>    //
>
> This is where I try to click the link, I tried using something called
> xFirePath in Firefox, using this example:http://www.layeredthoughts.com/automation/how-to-write-your-first-rub...

Eric Thomson

unread,
Mar 6, 2015, 4:39:59 PM3/6/15
to test...@googlegroups.com, gral...@gmail.com
What is the syntax to access frames in Selenium-WebDriver using RWebSpec?
I need to test using Firefox but the application (PeopleSoft) uses frames.
I tried using the goto_url("path/page") but I just get the

Zhimin

unread,
Mar 6, 2015, 6:02:00 PM3/6/15
to test...@googlegroups.com, gral...@gmail.com
In RWebSpec, use browser.driver to access the selenium driver. Here is an example: 

  before(:all) do    
    open_browser(:base_url => $TESTWISE_PROJECT_BASE_URL.gsub("index.html", "frames.html"), :browser => :firefox)
  end

  it "New Test Case" do
    debug browser.class
    browser.driver.switch_to.frame("topNav") # name
    browser.driver.find_element(:link_text, "Menu 2 in top frame").click
  end
Reply all
Reply to author
Forward
0 new messages