Re: [wtr-general] Re: How do I find the id for element which has a label ?
I think probably I did not ask correctly. The labels for the fields are generated dynamically. I do not know which id it will have. So how do I find a field id or sst a field whose label is created dynamically ? Thank you, On Wed, Aug 24, 2011 at 11:50 PM, Alister Scott alister.sc...@gmail.comwrote: You can't set a label, you need to use the input (known in watir as text_field) @ie.text_field(:id = 'adjustment_invoices_ attributes_6_amount').set '16' -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
Re: [wtr-general] Re: How do I find the id for element which has a label ?
On Thu, Aug 25, 2011 at 4:09 PM, yadula chodankar ychodan...@gmail.com wrote: I think probably I did not ask correctly. The labels for the fields are generated dynamically. I do not know which id it will have. So how do I find a field id or sst a field whose label is created dynamically ? How do you recognize it when you are testing manually? Željko -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
Re: [wtr-general] Re: How do I find the id for element which has a label ?
I see text Inv 20100829 amount on the screen and box next to it for me to assign the amount. I have been trying to use various methods to find this element and I think finally found a way as I am typing this e-mail. I am not finished yet. but it looks as follows. I wrote a method to identify element by label. One I am satisfied with final product I will send you the method again. def check_elemnet_by_lable(text1) for i in 1..50 if @ie.text_field(:index, i).exists? p @ie.label(:index, i).text #p @ie.text_field(:index, i).text x = @ie.label(:index, i).text p x if @ie.label(:index,i).text.include? #{text1} p found it # do whatever needs to be done. end else break end end end On Thu, Aug 25, 2011 at 10:20 AM, Željko Filipin zeljko.fili...@wa-research.ch wrote: On Thu, Aug 25, 2011 at 4:09 PM, yadula chodankar ychodan...@gmail.com wrote: I think probably I did not ask correctly. The labels for the fields are generated dynamically. I do not know which id it will have. So how do I find a field id or sst a field whose label is created dynamically ? How do you recognize it when you are testing manually? Željko -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
[wtr-general] Re: How do I find the id for element which has a label ?
from your code snip it appears you know what the label text is so myId = ie.label(:text,'the text string').attribute_value('for') # Should return the assoicated id tag to the input ie.text_field(:id,myId).set('blah blah'0 See: http://www.w3schools.com/tags/tag_label.asp for label tags On Aug 25, 9:43 am, yadula chodankar ychodan...@gmail.com wrote: I see text Inv 20100829 amount on the screen and box next to it for me to assign the amount. I have been trying to use various methods to find this element and I think finally found a way as I am typing this e-mail. I am not finished yet. but it looks as follows. I wrote a method to identify element by label. One I am satisfied with final product I will send you the method again. def check_elemnet_by_lable(text1) for i in 1..50 if @ie.text_field(:index, i).exists? p @ie.label(:index, i).text #p @ie.text_field(:index, i).text x = @ie.label(:index, i).text p x if @ie.label(:index,i).text.include? #{text1} p found it # do whatever needs to be done. end else break end end end On Thu, Aug 25, 2011 at 10:20 AM, Željko Filipin zeljko.fili...@wa-research.ch wrote: On Thu, Aug 25, 2011 at 4:09 PM, yadula chodankar ychodan...@gmail.com wrote: I think probably I did not ask correctly. The labels for the fields are generated dynamically. I do not know which id it will have. So how do I find a field id or sst a field whose label is created dynamically ? How do you recognize it when you are testing manually? Željko -- Before posting, please readhttp://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com- Hide quoted text - - Show quoted text - -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
Re: [wtr-general] Re: How do I find the id for element which has a label ?
Here is the final product def check_element_by_lable(text1) # this method will find element by lable and return the corresponding index value. # if lable is not found it returns 0. for i in 1..50 if @ie.text_field(:index, i).exists? p @ie.label(:index, i).text #p @ie.text_field(:index, i).text #x = @ie.label(:index, i).text #p x if @ie.label(:index,i).text.include? #{text1} p found it break end else i = 0 break end end # return index i end Thank you, Yadula. On Thu, Aug 25, 2011 at 10:20 AM, Željko Filipin zeljko.fili...@wa-research.ch wrote: On Thu, Aug 25, 2011 at 4:09 PM, yadula chodankar ychodan...@gmail.com wrote: I think probably I did not ask correctly. The labels for the fields are generated dynamically. I do not know which id it will have. So how do I find a field id or sst a field whose label is created dynamically ? How do you recognize it when you are testing manually? Željko -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com
[wtr-general] Re: How do I find the id for element which has a label ?
You can't set a label, you need to use the input (known in watir as text_field) @ie.text_field(:id = 'adjustment_invoices_ attributes_6_amount').set '16' -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com