accessing the element of a span

Discussion in 'Ruby' started by Mike Hin, Nov 6, 2009.

  1. Mike Hin

    Mike Hin Guest

    I'm trying to test against the class name of a span. I'm iterating
    through all spans and basically want to say, "If ie.spans[x]'s value for
    class = "SSSBUTTON_CONFIRMLINK" then return the inner text of the span"

    print ie.spans[x] returns the following

    type:
    id:
    name:
    value:
    disabled: false
    class: SSSBUTTON_CONFIRMLINK
    text: Start a New Search

    Anyone know how to accomplish this? I haven't been able to figure out
    the command to return the class name of a span. I know ie.spans[x].text
    will return the inner text but I don't know the code for any of the
    other attributes. i tried using :class also to no avail.

    Thanks for any help,
    Mike
    --
    Posted via http://www.ruby-forum.com/.
    Mike Hin, Nov 6, 2009
    #1
    1. Advertising

  2. On Fri, Nov 6, 2009 at 11:43 AM, Mike Hin <> wrote:
    > I'm trying to test against the class name of a span. I'm iterating
    > through all spans and basically want to say, "If ie.spans[x]'s value for
    > class =3D "SSSBUTTON_CONFIRMLINK" then return the inner text of the span"
    >
    > print ie.spans[x] returns the following
    >
    > type:
    > id:
    > name:
    > value:
    > disabled: =A0 =A0 false
    > class: =A0 =A0 =A0 =A0SSSBUTTON_CONFIRMLINK
    > text: =A0 =A0 =A0 =A0 Start a New Search
    >
    > Anyone know how to accomplish this? I haven't been able to figure out
    > the command to return the class name of a span. I know ie.spans[x].text
    > will return the inner text but I don't know the code for any of the
    > other attributes. i tried using :class also to no avail.


    What is "ie"? You don't specify which libraries you are using. Unless
    you give a little bit more detail it's difficult to help.

    Jesus.
    Jesús Gabriel y Galán, Nov 6, 2009
    #2
    1. Advertising

  3. Mike Hin

    Mike Hin Guest

    Oh wow, thats what I get for posting at 3am. I am using Watir and ie is
    the browser being driven. sorry.

    Jesús Gabriel y Galán wrote:
    > On Fri, Nov 6, 2009 at 11:43 AM, Mike Hin <>
    > wrote:
    >> disabled: � � false
    >> class: � � � �SSSBUTTON_CONFIRMLINK
    >> text: � � � � Start a New Search
    >>
    >> Anyone know how to accomplish this? I haven't been able to figure out
    >> the command to return the class name of a span. I know ie.spans[x].text
    >> will return the inner text but I don't know the code for any of the
    >> other attributes. i tried using :class also to no avail.

    >
    > What is "ie"? You don't specify which libraries you are using. Unless
    > you give a little bit more detail it's difficult to help.
    >
    > Jesus.


    --
    Posted via http://www.ruby-forum.com/.
    Mike Hin, Nov 6, 2009
    #3
  4. Mike Hin

    7stud -- Guest

    Mike Hin wrote:
    > I'm trying to test against the class name of a span. I'm iterating
    > through all spans and basically want to say, "If ie.spans[x]'s value for
    > class = "SSSBUTTON_CONFIRMLINK" then return the inner text of the span"
    >
    > print ie.spans[x] returns the following
    >
    > type:
    > id:
    > name:
    > value:
    > disabled: false
    > class: SSSBUTTON_CONFIRMLINK
    > text: Start a New Search
    >
    > Anyone know how to accomplish this? I haven't been able to figure out
    > the command to return the class name of a span. I know ie.spans[x].text
    > will return the inner text but I don't know the code for any of the
    > other attributes. i tried using :class also to no avail.
    >
    > Thanks for any help,
    > Mike


    Try something like this(untested):

    ie.spans.each do |span|
    if span.class == "SSSBUTTON_CONFIRMLINK"
    span.text
    end
    end


    --
    Posted via http://www.ruby-forum.com/.
    7stud --, Nov 6, 2009
    #4
  5. Mike Hin

    Mike Hin Guest

    That was the first thing I tried, span.class simply returns Watir::Span
    showing that the object in span is of the Watir::Span class.
    --
    Posted via http://www.ruby-forum.com/.
    Mike Hin, Nov 7, 2009
    #5
  6. Mike Hin

    7stud -- Guest

    Mike lastname wrote:
    > That was the first thing I tried, span.class simply returns Watir::Span
    > showing that the object in span is of the Watir::Span class.


    With such poor documentation, I wonder why anyone would use Watir over
    Hpricot or Nokogiri. In any case, here are two more things you can try:

    span.class_name
    span.attribute_value("class")



    --
    Posted via http://www.ruby-forum.com/.
    7stud --, Nov 8, 2009
    #6
    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. Fulio Open

    Can span include span?

    Fulio Open, Jun 26, 2009, in forum: HTML
    Replies:
    5
    Views:
    529
    dorayme
    Jun 26, 2009
  2. Stéphane Klein
    Replies:
    2
    Views:
    1,726
    John Nagle
    Mar 30, 2010
  3. Stefan Behnel
    Replies:
    0
    Views:
    470
    Stefan Behnel
    Mar 29, 2010
  4. Dan Bishop

    DataGrid (body only) contained in <span>...</span> tags

    Dan Bishop, Jun 7, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    254
    Kilic Beg
    Jun 7, 2004
  5. Wang, Jay
    Replies:
    5
    Views:
    448
    Wang, Jay
    May 25, 2004
Loading...

Share This Page