Unified Functional Testing Practitioners Forum
Showing results for 
Search instead for 
Do you mean 

QTP Function to Check or Uncheck a Web Checkbox

Highlighted
Contributor

QTP Function to Check or Uncheck a Web Checkbox

[ Edited ]

Function which checks or uncheck a web checkbox. This QTP function will check or uncheck the specified web checkbox based on the value given in function call.

 

Read More>>

Kannan S
Test Engineer
Ernst & Young
3 REPLIES
Occasional Visitor

Re: QTP Function to Check or Uncheck a Web Checkbox

'Systemutil.Run "iexplore.exe","http://www.nucleation.in/check-uncheck-checkbox-web-table/?fb_ref=recommendations-bar"
'wait(10)

row=Browser("QTP Function to Check").Page("QTP Function to Check").WebTable("SNo").GetRowWithCellText("Passenger 1",2,2)
msgbox(row)
wait(2)

Browser("QTP Function to Check").Page("QTP Function to Check").WebTable("SNo").ChildItem(row, 2, "WebCheckbox", 1).set "ON"


Error:-Object Required[At last line].

Just copy it in qtp and run it and add the web table into object repositary.If u r able to cheke the check box plz send me the code @ spmishra2u@gmail.com.

Occasional Visitor

Re: QTP Function to Check or Uncheck a Web Checkbox

In My Application we have webtable where if we check the checkbox in any particular row we need to get the row number and ENitre data in the row 

Advisor

Re: QTP Function to Check or Uncheck a Web Checkbox

I'm not sure if I'm understanding correctly, but I've written a subroutine to check a checkbox and another to uncheck it based on the html id.

Sub CheckCBox (cbox)
b = "micclass:=Browser"
p = "micclass:=Page"
'Check to see if cbox includes "html id:=" and remove it if so
If Left(cbox,9) = "html id:=" Then
cbox = Replace(cbox,"html id:=","")
End If
'Check to see if cbox is already checked
If Browser(b).Page(p).WebCheckBox("html tag:=INPUT","html id:=" & cbox).GetROProperty("checked") = 0 Then
Browser(b).Page(p).WebCheckBox("html tag:=INPUT","html id:=" & cbox).Click
Else
reporter.ReportEvent micInfo,"Check checkbox " & cbox,"Checkbox was already checked."
End If
End Sub