I am using UFT 12.51 to automate a Web based application on IE11. Here is my scenario:
I have to go through a few pages to complete the process I'm trying to automate (9 pages to be precise). On page 4, I click on a link which opens a Frame (as a popup). I enter required information and click on the button to submit the information which closes the Frame and returns me to page 4 on the browser. Here is where my problems start: at this point UFT stops recognizing any elements on the page. It picks up that there is a page but does not recognize that it has any child 'visible' objects. If I manually click on the link again to display the Frame again and them close the Frame, UFT starts recognizing the objects on the page again. Is there a way I can trigger a link click (I have the URL) to open the Frame again when the link is not visible to UFT? If I can do that, I will be able to close the Frame and objects on the page will be visible again .. hopefully :)
I have tried things like 'devicereplay', browser.navigate, sendkeys but none of them are working. Unfortunately due to the nature of my app, I cannot provide any screen prints. Any help would be greatly appreciate as I have been trying to figure this out for 2 days now with no luck.
Code
Dim oDR : Set oDR = CreateObject("Mercury.DeviceReplay")
' Lets get the X and Y chordinates for 'Next Step' button
Dim iX, iY
iX = Browser("MyBrowser").Page("MyPage").Link("NextStep").GetROProperty("x") + 5
iY = Browser("MyBrowser").Page("MyPage").Link("NextStep").GetROProperty("y") + 5
If MyFunction(dCurrVals, sErrorMsg) Then
LOG_ReportEvent "PASS", "Set Investment/Allocate", "Successfully initialised page"
Else
LOG_ReportEvent "FAIL", "Set Investment/Allocate", sError
End If
'Browser("MyBrowser").Page("MyPage").Object.body.doscroll "scrollbarPageUP"
wait(1)
oDR.MouseMove iX, iY
oDR.MouseClick iX, iY, 0
Set oDR = Nothing
Browser("MyBrowser").RefreshWebSupport
Wait(1)
Browser("MyBrowser").Page("MyPage").Link("Search")
'Browser("MyBrowser").Navigate "MyURL"
'Browser("MyBrowser").Page("MyPage").Sync
'Browser("MyBrowser").Page("MyPage").Link
'Wait(1)
'Browser("MyBrowser").Page("MyPage").Link("Search")
'Browser("MyBrowser").Page("MyPage").WebElement("Search").FireEvent "onclick"
NOTE
For security reason, I have changed the names of object but above code is just an example of things that I have tried. dCurrVals
is a dictionary object which is being pre-populated before the function call
After a lot of research, I have a solution for this problem. I cant think of another way to get round this problem. Thought I'd put it here just incase anyone else is facing the same problem
Approach
As UFT was not recognising anything on the page, I decided to use InsightObject
. Advantage of using InsightObject
is that as long as the object is visible, UFT will find it on the page. Ironically, this is a disadvantage as well: object has to be visible on the screen. So I decided to write the below UDF. UDF moves to the top of the page, then performs a search for the InsightObject
. If the object is not found, it moves the page down and performs another search for the object. It repeats this process until it either finds the object or counter limit is reached. If it finds the InsightObject
, it clicks on the object and then performs a check for specified object on the page.
UDF
Public Function EnablePage(ByVal oInsightObject, ByVal oCheckObject, ByVal iPgMoveCount ByRef sError)
LOG_Write vbNewLine & "EnablePage"
Dim oWS: Set oWS = CreateObject("WScript.shell")
Dim iC
Dim bFoundIO
' Set default values
EnablePage = True
bFoundIO = False
' Move to the top of the page
For iC = 1 To CInt(iPgMoveCount)
oWS.SendKeys "{PGUP}"
Wait 0, 500
Next
' Navigate to the bottom of the page to find the object
For iC = 1 To CInt(iPgMoveCount)
' Check if Insight object exists
If oInsightObject.Exist(1) Then
bFoundIO = True
oInsightObject.Click
Wait 0, 500
Exit For
Else
oWS.SendKeys "{PGDN}"
Wait 0, 500
End If
Next
' Check if Insight object was found
If bFoundIO Then
' Check if object to check is visible
If Not oCheckObject.Exist(2) Then
EnablePage = False
sError = "Clicked on Insight Object but unable to find the object to check"
End If
Else
EnablePage = False
sError = "Unable to find the Insight Object"
End If
' Clear objects
Set oWS = Nothing
End Function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With