Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > accessing the element of a span

Reply
Thread Tools

accessing the element of a span

 
 
Mike Hin
Guest
Posts: n/a
 
      11-06-2009
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/.

 
Reply With Quote
 
 
 
 
Jesús Gabriel y Galán
Guest
Posts: n/a
 
      11-06-2009
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.

 
Reply With Quote
 
 
 
 
Mike Hin
Guest
Posts: n/a
 
      11-06-2009
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/.

 
Reply With Quote
 
7stud --
Guest
Posts: n/a
 
      11-06-2009
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/.

 
Reply With Quote
 
Mike Hin
Guest
Posts: n/a
 
      11-07-2009
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/.

 
Reply With Quote
 
7stud --
Guest
Posts: n/a
 
      11-08-2009
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/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't code a css class that makes a span element the same size as a button element Cal Who ASP .Net 5 04-26-2010 05:35 PM
I'm looking for html cleaner. Example : convert <h1><span><font>my title</font></span></h1> => <h1>my title</h1>… Stéphane Klein Python 2 03-30-2010 12:35 AM
Re: I'm looking for html cleaner. Example : convert <h1><span><font>my title</font></span></h1> => <h1>my title</h1>… Stefan Behnel Python 0 03-29-2010 08:14 PM
Can span include span? Fulio Open HTML 5 06-26-2009 10:24 PM
DataGrid (body only) contained in <span>...</span> tags Dan Bishop ASP .Net Datagrid Control 2 06-07-2004 04:00 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57