Trouble with web element in UFT

Category:
Question ID: 110127
0
0

UFT is not clicking on a web element in a table when the web element text is displayed in two lines. When the same link on other page displayed in one line, it is working fine. If it is displayed in two lines, it is highlighting but not clicking on it.
Below is the code
If rCount > 1 Then

For r=1 to rCount
If cstr(strLicenseNum)=trim(Browser(“micclass:=Browser”).Page(“micClass:=Page”).WebTable(“html tag:=TABLE”).GetCellData(r,1)) then

set cl = Browser(“micclass:=Browser”).Page(“micClass:=Page”).WebTable(“html tag:=TABLE”).ChildItem(r, 5, “WebElement”,3)

temp = cl.getroproperty(“innertext”)
If InStr(1, temp, “Print Cert”) Then

Setting.WebPackage(“ReplayType”) = 2
cl.highlight
cl.click
‘ cl.FireEvent “onclick”
Setting.WebPackage(“ReplayType”) = 1
wait 5
gfunClickOnPrintCertForInternalUser = True
Else
Reporter.ReportEvent micFail,”PrintCert link is not found for this License”,””
End If

r=rCount
Exit For
End if
Next
Else
Reporter.ReportEvent micFail,”No license found”,””
Browser(“micclass:=Browser”).Close
EXITTEST
End If

Marked as spam
Posted by (Questions: 214, Answers: 22)
Asked on April 29, 2021 12:51 pm
4 views
Answers (1)
0
Private answer

I've been going over the code, and I wanted to try a few different things to see if we can get this to work. The first thing I would like to try is to see if the cl.click actually just sets focus to the object when going through multiple lines of an element. I would like to see if adding a second click opertation might work:

Setting.WebPackage("ReplayType") = 2
cl.highlight
cl.click
cl.click
' cl.FireEvent "onclick"
Setting.WebPackage("ReplayType") = 1
wait 5
gfunClickOnPrintCertForInternalUser = True
Else
Reporter.ReportEvent micFail,"PrintCert link is not found for this License",""
End If

If that doesn't work, I'd like to add a few additional lines of code to check if the object is still displayed and if so, try to click on it again, for a total of 5 tries before exiting the routine:

Setting.WebPackage("ReplayType") = 2
cl.highlight
cl.click

For i=1 to 5
If cl.exist (1) Then
cl.click
End If
Next
' cl.FireEvent "onclick"
Setting.WebPackage("ReplayType") = 1
wait 5
gfunClickOnPrintCertForInternalUser = True
Else
Reporter.ReportEvent micFail,"PrintCert link is not found for this License",""
End If

Marked as spam
Posted by (Questions: 2, Answers: 464)
Answered on April 29, 2021 12:51 pm