[Wtr-general] Can I access caption attribute of a checkbox?

Angrez Singh angrez at gmail.com
Fri Jun 16 01:12:59 EDT 2006


Hi,

Which watir version are you using? Latest version has a method called
'attribute_value' that you can try that to get the value of 'caption'
attribute. So you try the following:

ie.checkboxes[1].attribute_value("caption")

Regards,
Angrez

On 6/15/06, Amitha Shetty <amithashettyb at yahoo.co.in> wrote:
>
> Hi,
>   Sorry thats the javascipt which I had given.
> Checkboxes on this page are generated by a third party tool which uses the
> following javascripts:
> <script type="text/javascript" src="./js/Bs_Misc.lib.js"></script>
> <script type="text/javascript" src="./js/Bs_Array.class.js"></script>
> <script type="text/javascript" src="./js/Bs_Tree.class.js"></script>
> <script type="text/javascript"
> src="./js/Bs_TreeElement.class.js"></script>
> <script type="text/javascript" src="./js/Bs_Checkbox.class.js"></script>
>
>  Is there way to access the html generated this way?I want to get the
> display name of the checkbox which is present as caption in the view source
> page as
> "a[0]['children'][0]['children'][0]['children'][0]['caption']='CHILD_A2;"
> I want the text "CHILD_A2"
>
> View Source of the page looks like this:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <head>
> <title>CHECK</title>
> <script type="text/javascript" src="./js/Bs_Misc.lib.js"></script>
> <script type="text/javascript" src="./js/Bs_Array.class.js"></script>
> <script type="text/javascript" src="./js/Bs_Tree.class.js"></script>
> <script type="text/javascript"
> src="./js/Bs_TreeElement.class.js"></script>
> <script type="text/javascript" src="./js/Bs_Checkbox.class.js"></script>
> <script type="text/javascript">
> function init() {
>   myTree = new Bs_Tree();
>   myTree.imageDir = './images/';
>   myTree.useCheckboxSystem      = true;
>   myTree.useAutoSequence = false;
>   myTree.checkboxSystemWalkTree = 3;
>   myTree.initByArray(a);
>   myTree.drawInto('treeDiv1');
> }
> </script>
>
>  <script type = "text/javascript">
>
>
> var a = new Array;
> a[0] = new Array;
> a[0]['id'] = '99999'
> a[0]['checkboxName'] ='CNAME_14'
> a[0]['caption'] = 'Check Here'  (#This is the data I want to retrieve)
> a[0]['isOpen'] = true
> a[0]['children'] = new Array;
> a[0]['children'][0] = new Array;
> a[0]['children'][0]['id']='51';
> a[0]['children'][0]['caption']='CHILD_A';
> a[0]['children'][0]['checkboxName']='VELOZ_51';
> a[0]['children'][0]['children'] = new Array;
> a[0]['children'][0]['children'][0] = new Array;
> a[0]['children'][0]['children'][0]['id']='52';
> a[0]['children'][0]['children'][0]['caption']='CHILD_A1;
> a[0]['children'][0]['children'][0]['checkboxName']='ID_52';
> a[0]['children'][0]['children'][0]['children'] = new Array;
> a[0]['children'][0]['children'][0]['children'][0] = new Array;
> a[0]['children'][0]['children'][0]['children'][0]['id']='54';
> a[0]['children'][0]['children'][0]['children'][0]['caption']='CHILD_A2;
> a[0]['children'][0]['children'][0]['children'][0]['checkboxName']='ID_54';
> </script>
>
>
> <body  onLoad="init();">
> <div style="margin-top:5px;margin-left:5px;" id="treeDiv1"></div>
>   </body>
> </html>
>
>
> Thanks,
> Amitha
>
>
>
>
> *Zeljko Filipin <zeljko.filipin at gmail.com>* wrote:
>
> You have <input type="checkbox" caption="Check Here" />? It is not valid
> html. Check it for yourself at http://validator.w3.org/.
> _______________________________________________
> Wtr-general mailing list
> Wtr-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-general
> Hi,
>    Can I access caption attribute of a checkbox?
>  I want to retrieve the display name of the checkbox and this data is
> present in the caption attribute in the html source. The checkboxes are in
> the form of a tree.
> HTML Source is:
> var a = new Array;
> a[0] = new Array;
> a[0]['id'] = '99999'
> a[0]['checkboxName'] ='CNAME_14'
> a[0]['caption'] = 'Check Here'  (#This is the data I want to retrieve)
>
>
> ie.checkboxes[1].name gives CNAME_14
> but ie.checkboxes[1].caption throws the following exception:
> undefined method `caption' for #<Watir::CheckBox:0x33c6b38>
> (NoMethodError)
>
> I want to get the data in caption attribute i.e 'Check Here'. How do I
> retrieve it?
>
> Thanks,
> Amitha
>
>
> Send instant messages to your online friends http://in.messenger.yahoo.com
>
> Stay connected with your friends even when away from PC. Link:
> http://in.mobile.yahoo.com/new/messenger/
>
> _______________________________________________
> Wtr-general mailing list
> Wtr-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-general
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20060616/2a15befa/attachment.html 


More information about the Wtr-general mailing list