Forum Discussion
Hi Colin,
Just in case - maybe the below function will help (it returns the Window that is parent for the given Page so you can Activate it):
'-----------------------------------------------------------------------------
' Returns BrowserWindow object that corresponds to the given page object
' From: http://smartbear.com/forums/f75/t83264/how-to-match-a-page-object-to-its-browserwindow
Function BrowserWindowByPageGet(ByRef page)
Const cProcName = "BrowserWindowByPageGet"
Dim cProcNameMsgPrefix : cProcNameMsgPrefix = cUnitNameMsgPrefix & cProcName & "(): "
Dim title
Dim wnd
Dim strMsg
Set wnd = Utils.CreateStubObject
If (Not IsNull(page)) Then
If ("Page" = page.ObjectType) Then
strMsg = "Waiting for the page to load from the web server..."
Do Until aqObject.IsSupported(page, "contentDocument")
Call aqUtils.Delay(500, strMsg)
Loop
Do Until BuiltIn.varDispatch = aqObject.GetVarType(page.contentDocument)
Call aqUtils.Delay(500, strMsg)
Loop
Do Until aqObject.IsSupported(page.contentDocument, "title")
Call aqUtils.Delay(500, strMsg)
Loop
title = page.contentDocument.title
Set wnd = page.Parent.FindChild("WndCaption", title & "*")
If (Not wnd.Exists) Then
Set wnd = page.Parent.FindChild("WndCaption", Project.Variables.pvtBaseURL)
End If
End If
End If
Set BrowserWindowByPageGet = wnd
End Function
'-----------------------------------------------------------------------------
- Colin_McCrae10 years agoCommunity Hero
Thanks Alex
Handy for future reference.
In the end, using the caption was simple enough after the devs made some mods to the code to include part of the URL (the same part I use to identify the page) in the caption. In end use, the browser is full screen and an embedded system so tabs, nav bars, browser buttons etc are not visible to the end user thus we can use them as we see fit. Which was handy for me. So three lines of code in a couple of strategic places has sorted it out in the end. (The project in question sends all key press events at page level. So there are only two keypress routines in use by the whole project. One for short presses - using Keys(), one for long presses - using KeyUp/KeyDown. These were the only places I need to put the activation code in.)
I still need to have a poke around and find out why the browser doesn't activate when you send things to the page. It used to using the NPAPI driver. But doesn't using whatever it uses now. But not in all cases. I think it may have something to do with how the browser is started. Was hoping to check that out last week but had to focus on getting all the tests working and run.
Hopefully checking that out today and will raise a support ticket accordingly.
** EDIT **
Just wondering if you have tried the above with Chrome and it worked consistently?
One problem I had in the past with Chrome was using "page.contentDocument". It has a "readyState" property which does not work properly. Or at least, it didn't when I hit this problem. See below:
As I wonder if might send you off to the BrowserWindow object before it's fully ready and populated becuase of the same problem?
Related Content
- 13 years ago
- 2 years ago
- 8 years ago
- 8 years ago
Recent Discussions
- 3 days ago
- 3 days ago
- 6 days ago