.

might wanna look into this – watir stuff

Want to use watir to achieve an operation, open a Web page, the confirmation page checkbox is not checked, that is checked state.

Search revealed that the watir of the checkbox control is only set and clear operations operations

1. Using the name attribute set to check
ie.checkbox (: name, “checkme”). set
2. Use the name attribute check box cleared
ie.checkbox (: name, “checkme”). clear
3. Use the check box name and value property
ie.checkbox (: name, “checkme”, “1″). set
4. Use the name and value attributes check box cleared
ie.checkbox (: name, “checkme”, “1″). clear

There is no direct way to achieve, multi-query, get ideas from here ( http://blog.chinaunix.net/u/15010/showart_2058597.html ),

Script can get innerHTML, and then if there are keyword “<INPUT type = checkbox CHECKED” can confirm that the state is not checked, generally the code is as follows:

#———————–

require ‘watir’
$ HIDE_IE = true
ie = Watir:: IE.new

ie.goto (” http://localhost:8080/ “)

scripts = ie.document.body.parentElement.getElementsByTagName (“td”)
scripts.each do | script_tag |
script_tag.invoke (“innerHTML”). each do | script |
puts script
if script.match (/ <INPUT type = checkbox CHECKED /)
puts ‘status is checked’
end
end
end

#————————

Another more complex example, when there are multiple checkbox, requires recognizing checkbox1 previous name, found that match well with, we use the index, as follows:

#————————-

$ Name = ‘color’
keyword = “<INPUT type = checkbox CHECKED”
num_checked = 0
flag = false
scripts = $ ie.document.getElementById (“name_iframe”). contentWindow.document.body.getElementsByTagName (“tr”)
scripts.each do | script_tag |
script2 = script_tag.invoke (“innerHTML”)
if script2.index (keyword) and script2.match (<\ / TABLE >/)== nil
print_message (script2)
num_checked = num_checked +1
if script2.index ($ name)
flag = true
break
end
end
end
#————————–

Note:

index () which can be variable
match () which can not be a variable

a = ‘ddddddsdoddsfsf’
b = ‘s’
puts a.match (/ do /)
puts a.index (b)

What's your thoughts on this?

*

Protected by WP Anti Spam