How to access a button tag in watir

Discussion in 'Ruby' started by Vani, Oct 26, 2005.

  1. Vani

    Vani Guest

    Hello every one,

    I am facing problem in Xpath query i have written to access a button
    tag
    in watir.

    Following is the code i have written.
    -------------------------------------------------------------------------
    require 'watir'
    include Watir

    ie = IE.new

    ie.goto("http://www.travelocity.com/")
    ie.maximize()

    ie.link:)text,"Flights").click
    ie.radio:)value, "oneway").set

    ie.text_field:)name, "leavingFrom").set("Pune")
    ie.text_field:)name, "goingTo").set("Mumbai")
    ie.text_field:)name, "leavingDate").set('10/27/2005')

    ie.button:)name,"submit").click

    ie.link:)text, "additional fees").click

    sleep 5

    iePopup = IE.attach:)title, /Explanation of Taxes/)
    iePopup.close()

    # I am facing problem on the below line of code

    ie.button:)xpath,"//*[@id='tfGrid']/tr[4]/td[6]/div[1]/button").click

    Can anyone tell me where I am going wrong?
     
    Vani, Oct 26, 2005
    #1
    1. Advertising

  2. Vani

    Jeff Wood Guest

    ------=_Part_3005_30172354.1130309677487
    Content-Type: text/plain; charset=ISO-8859-1
    Content-Transfer-Encoding: quoted-printable
    Content-Disposition: inline

    Hows about giving us the error message you're getting ???
    And, you are actually wanting:
    button in 2nd div within the 7th cell of the 5th row of any tag which has
    an id=3D'tfGrid' attribute ???
    Remember that xpath is not 1 based, like most of WATiR ...
    But, again, having the error message, and maybe a peek at the chunk of
    stuff you're trying to extract , would be quite helpful.
    Other than that, you should only be encountering <tr> tags inside either
    <table> or <tablebody> tags.
    If it's a <table> there are much simpler ways to get to the button ...
    ie.table( :id, "tfGrid" )[4][6].div( :index, 1 ).button( :index, 1 ).click
    no xpath ... don't know if it will work cause I can't even imagine the htm=
    l
    complicated enough to need something this complex ... but,
    please give us more to work with... hope we can help. Look forward to your
    response.
    Kickin' offline for the night ( 23:54-8:00GMT here ) ... will take a look
    tomorrow.
    j.


    On 10/25/05, Vani <> wrote:
    >
    > Hello every one,
    >
    > I am facing problem in Xpath query i have written to access a button
    > tag
    > in watir.
    >
    > Following is the code i have written.
    > -------------------------------------------------------------------------
    > require 'watir'
    > include Watir
    >
    > ie =3D IE.new
    >
    > ie.goto("http://www.travelocity.com/")
    > ie.maximize()
    >
    > ie.link:)text,"Flights").click
    > ie.radio:)value, "oneway").set
    >
    > ie.text_field:)name, "leavingFrom").set("Pune")
    > ie.text_field:)name, "goingTo").set("Mumbai")
    > ie.text_field:)name, "leavingDate").set('10/27/2005')
    >
    > ie.button:)name,"submit").click
    >
    > ie.link:)text, "additional fees").click
    >
    > sleep 5
    >
    > iePopup =3D IE.attach:)title, /Explanation of Taxes/)
    > iePopup.close()
    >
    > # I am facing problem on the below line of code
    >
    > ie.button:)xpath,"//*[@id=3D'tfGrid']/tr[4]/td[6]/div[1]/button").click
    >
    > Can anyone tell me where I am going wrong?
    >
    >
    >



    --
    "http://ruby-lang.org -- do you ruby?"

    Jeff Wood

    ------=_Part_3005_30172354.1130309677487--
     
    Jeff Wood, Oct 26, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shruds
    Replies:
    1
    Views:
    829
    John C. Bollinger
    Jan 27, 2006
  2. Anukul Singhal
    Replies:
    1
    Views:
    168
    Charley Baker
    May 15, 2008
  3. Raveendran Perumalsamy

    Embed tag with watir

    Raveendran Perumalsamy, Jul 18, 2009, in forum: Ruby
    Replies:
    0
    Views:
    161
    Raveendran Perumalsamy
    Jul 18, 2009
  4. Alex Lin
    Replies:
    1
    Views:
    351
    Eugen Ciur
    May 6, 2011
  5. visu
    Replies:
    4
    Views:
    301
Loading...

Share This Page