5

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

Zac
  • 1,924
  • 1
  • 8
  • 21
  • Does page 4 contains all custom controls and not web objects? – Pankaj Jaju Jan 11 '17 at 16:40
  • It's web objects only (i.e. tables, edit fields, links etc) – Zac Jan 11 '17 at 16:43
  • Then why isn't UFT recognising it? Have you tried descriptive programming or tried record your steps? – Pankaj Jaju Jan 11 '17 at 16:57
  • I don't know why UFT stops recognising the objects on the page. I've tried descriptive programming and recording but no go unfortunately. With descriptive programing, I get the same results: I can recognise the page but cannot recognise any objects on the page. Recording: it records until the Frame is closed but nothing after that. Hence why I thought if I can trigger the link somehow and open the Frame again, I can then work with it .. if that makes any sense – Zac Jan 11 '17 at 17:03
  • 1
    So descriptive programming, record and play, device replay, object identification - nothing worked. The other options you have is to use the `GetVisibleText` method or work with the developers. Check out this link too for other options --> http://www.learnqtp.com/uft-object-identification-tips/ – Pankaj Jaju Jan 11 '17 at 17:10
  • Are you handling the Pop up page and Page 4 as two separate objects, or you are replacing a single objPage with the current page being displayed? Can you provide some of the code so we can see how you are identifying your objects and how you are handling your pages? – Victor Moraes Jan 11 '17 at 18:57
  • @VictorMoraes: as per your request, I have added code snippet of some of the things I've tried. Popup page is set as a Frame of the main page (page4) in OR. While searching for solutions, I found a suggestion to not use the Frame in OR and have all objects on the main page. I copied all objects from Frame into main page object but unfortunately it was a no go as well – Zac Jan 12 '17 at 10:03
  • @PankajJaju: unfortunately `GetVisibleText` wont work as nothing is visible on the page. My normal approach in situations like this is to work with developers (as per your suggestion) to resolve the issue but as I am testing a third party product, we have no contact with developers. Also, I'm not convinced that this is an application issue (I have a feeling this is more of a UFT issue) – Zac Jan 12 '17 at 10:13
  • I'm sorry but it still isn't very clear which action is taken on Page4 and which one is taken on Frame, neither it is clear the issue that you are describing. The only thing you're actually doing in the code provided is clicking in the "NextStep" button and then trying to refresh the page. Is the "NextStep" button in Page 4 or in Frame? Furthermore, I understand you changed the names of objects, but you are always using "MyPage" page, which leads me to believe you are considering all objects to be in the same page and that is probably one of the reasons for the issue you are facing. – Victor Moraes Jan 12 '17 at 10:35
  • "*I found a suggestion to not use the Frame in OR and have all objects on the main page. I copied all objects from Frame into main page object but unfortunately it was a no go as well"* did you simply copy+paste them or remapped them in the main page? After doing this, did you try to highlight all mapped objects to make sure UFT is properly recognizing them? – Victor Moraes Jan 12 '17 at 10:38
  • @VictorMoraes: Let me see if I can clarify: 'MyFunction' performs the action on 'popup' (which is the Frame that popups on top of 'Page4'). There is no problem interacting with the Frame at this stage. 'MyFunction' closes the 'popup'. This is where the problem starts. Now that I am back on 'Page4', I cannot recognise any objects on the page (where I was able to before the 'popup'). Code I've provided are the things I've tried to interact with the page once 'popup' is closed. Hope this makes it a bit more clear? – Zac Jan 12 '17 at 11:51
  • It is clearer now. If not done yet, I'd try to put a breakpoint after closing the Frame so you can try to inspect your objects and check why they are not being recognized. And since you already tried many solutions with no success I would go with Motti's approach and contact HPE support. – Victor Moraes Jan 12 '17 at 12:16

2 Answers2

3

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
Zac
  • 1,924
  • 1
  • 8
  • 21
1

This sounds like a bug in UFT, you should contact HPE's support.

A workaround for such cases is available in the undocumented Browser("...").RefreshWebSupport method which tells UFT to re-connect to the DOM of the browser. This may help but since it's undocumented there are no guarantees :(

Motti
  • 110,860
  • 49
  • 189
  • 262
  • 1
    That's a good shout @Motti. I did try `Browser("..").RefreshWebSupport` but unfortunately it didn't work (just displayed a 'General Error' popup). As per your suggestion, if I don't get a solution this week, I will raise it as a bug in UFT – Zac Jan 12 '17 at 10:05