Forum: Ruby watir question

5dfc843f9ecf6fb64b52a35bdce43910?d=identicon&s=25 Raja gopalan (arc)
on 2014-07-28 08:56
hi, please have a look at the below tag

<td title="* Legal Type" class="Label"id="idLabelTD" thelabel="* Legal
Type" styleId="111id" fieldIdentifier="TypeVO@id">

I can able to print the id of td from the above tag, but I couldn't able
to print the styleId from the above tag, how would I do that?

b.tds.each do |t|
   put t.id        #this works fine
end


b.tds.each do |t|
   put t.styleId  #this is not working for me
end

Is there any way I could print the styleId from the above tag?
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2014-07-28 20:50
As with any custom attribute:

t.attribute_value("styleId")
5dfc843f9ecf6fb64b52a35bdce43910?d=identicon&s=25 Raja gopalan (arc)
on 2014-07-29 12:03
hi Joel Pearson

It's great,working fine. I got the value of styleId attribute.
5dfc843f9ecf6fb64b52a35bdce43910?d=identicon&s=25 Raja gopalan (arc)
on 2014-07-29 12:06
hi Joel,

Do you know which class owns this methods 'attribute_value'?
5dfc843f9ecf6fb64b52a35bdce43910?d=identicon&s=25 Raja gopalan (arc)
on 2014-07-29 12:16
hi jeol,

<input name="Form@firstName" tabIndex="308" class="TextInput"
id="Form@firstName" style="text-align: left; width: 224px;"
onfocus="onFocusFieldHandler(this)" type="text" helpTextInfo=""
origValue=""/>

For the above html code,I have written the below code,

puts
$browser.text_field(:id,'IDITForm@firstName').attribute_value('name')
puts
$browser.text_field(:id,'IDITForm@firstName').attribute_value('tabIndex')
puts
$browser.text_field(:id,'IDITForm@firstName').attribute_value('class')
puts $browser.text_field(:id,'IDITForm@firstName').attribute_value('id')
puts
$browser.text_field(:id,'IDITForm@firstName').attribute_value('style')
puts
$browser.text_field(:id,'IDITForm@firstName').attribute_value('onfocus')
puts
$browser.text_field(:id,'IDITForm@firstName').attribute_value('type')
----------------------
The result is,
IDITForm@firstName
308
nil
IDITForm@firstName
#<WIN32OLE:0xf5d3ea0>
#<WIN32OLE:0xf5d37f8>
text
--------------------------
My question is, why it prints nil for 'class' attribute, style and
onfocus it's prints object name?
14b5582046b4e7b24ab69b7886a35868?d=identicon&s=25 Joel Pearson (virtuoso)
on 2014-07-29 21:05
You can always check the documentation:
http://rdoc.info/gems/watir-webdriver/Watir/Elemen...

Your HTML doesn't match your selector. That's not the same element.
5dfc843f9ecf6fb64b52a35bdce43910?d=identicon&s=25 Raja gopalan (arc)
on 2014-07-30 06:07
hi Thank you,very useful.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.