The online community for software testing & quality assurance professionals
 
 
Calendar   Today's Topics
Sponsors:




Lost Password?

Home
BetaSoft
Blogs
Jobs
Training
News
Links
Downloads



Testing Tools >> HP Functional Testing / Mercury QuickTest Pro / QTP

Pages: 1
abscr
Newbie


Reged: 10/10/07
Posts: 3
Why won't this checkbox solution work?
      #428502 - 10/29/07 04:08 PM

I've been trying to work out a more elegant solution to determining if all the checkboxes in a WebTable are checked than looping over all of them. Currently, this solution works

Code:

Dim obj_Unchecked
Set obj_Unchecked = Description.Create

obj_Unchecked("type").value = "checkbox"

Dim allUnchecked
Set allUnchecked = browser("Upstream").Page("Upstream").Frame("Frame1").WebTable("Acct Name").ChildObjects(obj_Unchecked)



checked = True

For i=0 to allUnchecked.Count - 1
If allUnchecked(i).getROProperty("checked") = 0 Then
checked = False
End If
Next

If not checked Then
Reporter.ReportEvent micFail, "All checkboxes checked", "There is an unchecked checkbox"
else
Reporter.ReportEvent micPass, "All checkboxes checked", "All checkboxes checked"
End If




What I've been trying to get to work is

Code:

Dim obj_Unchecked
Set obj_Unchecked = Description.Create

obj_Unchecked("type").value = "checkbox"
obj_Unchecked("checked").value = "0" 'or obj_Unchecked("value").value = "off" ; neither works

Dim allUnchecked
Set allUnchecked = browser("Upstream").Page("Upstream").Frame("Frame1").WebTable("Acct Name").ChildObjects(obj_Unchecked)

If allUnchecked.Count > 0 Then
Reporter.ReportEvent micFail, "All checkboxes checked", "There is an unchecked checkbox"
else
Reporter.ReportEvent micPass, "All checkboxes checked", "All checkboxes checked"
End If



Now, I know some will wonder why I care; it's because I don't understand why the one doesn't work and it makes me uncomfortable when I don't understand something like this. Also, the solution that is working would be a little slower than the one I want. The documentation doesn't say, but I'm guessing ChildObjects() is O(n), and theoretically it won't be slower with the extra loop, but there might be some of a difference (I know very very small, but hey, it can't hurt).

Is there some sort of difference between getROProperty("checked") and obj_Unchecked("checked").value that I don't know about, or any other kind of assumption that I could be making?

Thanks for your time.


Post Extras: Print Post   Remind Me!   Notify Moderator  
TReddyModerator
Veteran


Reged: 01/17/07
Posts: 2565
Loc: Pittsburgh, PA
Re: Why won't this checkbox solution work? [Re: abscr]
      #428504 - 10/29/07 05:04 PM

Try without double quotes to value zero.

obj_Unchecked("checked").value = 0


Post Extras: Print Post   Remind Me!   Notify Moderator  
abscr
Newbie


Reged: 10/10/07
Posts: 3
Re: Why won't this checkbox solution work? [Re: TReddy]
      #428507 - 10/29/07 05:30 PM

My god . . . . This is what I get when I stare at the problem for hours without taking a break.

Not currently at the office, so I'll test this out tomorrow and get back for anyone that cares.

Thanks.


Post Extras: Print Post   Remind Me!   Notify Moderator  
thorwathModerator
Veteran


Reged: 07/22/99
Posts: 3840
Loc: Grand Rapids, MI
Re: Why won't this checkbox solution work? [Re: abscr]
      #428508 - 10/29/07 05:30 PM

I am not sure your Descriptor is well formed, and as such your first code example, the one that "works" will log the "all checkboxes checked" message when allUnchecked.Count is zero (and the FOR loop fails to run). Did you step through this code, or just use the log messages to determine progress?

Try this code, seeing I can' run yours:
Code:

Dim CBs, oDesc, iChecked, iUnchecked
'
Set oDesc=Description.Create
oDesc("micClass").Value="WebCheckBox"
oDesc("checked").Value=1
'
set CBs=browser("Upstream").Page...ChildObjects(oDesc)
iChecked=CBs.Count()
'
Reporter.ReportEvent micDone, "Selected CheckBoxes: " & iChecked
'
oDesc("checked").Value=0
'
set CBs=browser("Upstream").Page...ChildObjects(oDesc)
iUnchecked=CBs.Count()
'
Reporter.ReportEvent micDone, "Unselected CheckBoxes: " & iUnchecked



I hate to recommend code I have not tried, but if there are any syntax errors I apologize in advance. This though should work once the syntax is corrected, if that is required.

-Hope this helps, Terry


Post Extras: Print Post   Remind Me!   Notify Moderator  
thorwathModerator
Veteran


Reged: 07/22/99
Posts: 3840
Loc: Grand Rapids, MI
Re: Why won't this checkbox solution work? [Re: TReddy]
      #428509 - 10/29/07 05:38 PM

Quote:

Try without double quotes to value zero.
.
obj_Unchecked("checked").value = 0




There was a recent thread discussing this issue and I believe Tarun among others agreed that "0" and 0 can be used interchangeably when assigned to a Descriptor value. I was skeptical, but did confirm it for myself with some experimentation (I am though using QTP 9.2 and who knows if 8.2 differs...).

But you are correct in that the integer value of 0 and not the string value of "0" is defined for the WebCheckBox Object in online help.

I am still thinking that the Descriptor is not defined correctly--so now Jeff has two suggestions to try.

P.S. Here is the mentioned thread:

http://www.sqaforums.com/showflat.php?Cat=&Board=UBB20&Number=420777


Post Extras: Print Post   Remind Me!   Notify Moderator  
abscr
Newbie


Reged: 10/10/07
Posts: 3
Re: Why won't this checkbox solution work? [Re: thorwath]
      #428776 - 10/30/07 08:36 AM

Interestingly, taking the quotes from obj_Unchecked("checked").value = "0" worked. So, I don't know why it was working for Tarun both ways and not me. I'm using 9.2.0.0 Build: 2610. But, whatever. I feel it shouldn't work with the quotes, as you did in that thread you linked to.

Thanks for your help/time.


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 86 anonymous users are browsing this forum.

Moderator:  IanFraser, Rajkumar_Rajangam, thorwath, TReddy, AJ, Tarun Lalwani, mwsrosso 

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 1062

Rate this topic

Jump to

Contact Us | Privacy statement SQAForums

Powered by UBB.threads™ 6.5.5