Micro Focus QTP (UFT) Forums
test if a web page is visible on the screen - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: test if a web page is visible on the screen (/Thread-test-if-a-web-page-is-visible-on-the-screen)



test if a web page is visible on the screen - kordirko - 10-12-2012

Hello All,
I'am facing a strange behavior of QTP, could someone please eplain me what's going on ?
I want to check if a web page was opened in a popup window, and I don't know how.
Here is a test script - this clicks on a link that opens a new window with another page,
then clicking on this new page on another link closes this page (popup):
Code:
Browser("micclass:=browser").Navigate("http://www.htmlcodetutorial.com/linking/linking_famsupp_70.html")

' ******* Test 0 ********
'If  Browser("Popup Window - HTML Code").Page("Popup Window - HTML Code").Exist Then
'     MsgBox( "Test 0 - Exists" )
'else
'    MsgBox( "Test 0 - Doesn't exist" )
'End If



Browser("HTML Popup Windows - HTML").Page("HTML Popup Windows - HTML").Link("this link").Click

' ******* Test 1 ********
'If  Browser("Popup Window - HTML Code").Page("Popup Window - HTML Code").Exist Then
'     MsgBox( "Test 1 - Exists" )
'else
'    MsgBox( "Test 1 - Doesn't exist" )
'End If


Browser("Popup Window - HTML Code").Page("Popup Window - HTML Code").Link("back to Popup Windows").Click

' ******* Test 2 ********
'If  Browser("Popup Window - HTML Code").Page("Popup Window - HTML Code").Exist Then
'     MsgBox( "Test 2 - Still exists" )
'else
'     MsgBox( "Test 2 - Doesn't exist" )
'End If

If I uncomment commented lines with 'TEST 1' and 'TEST 2' and run this script,
then results is:
TEST 1 - Exist ----> fine, web page is opened
TEST 2 - Exist ----> popup window is not visible, so my understanding is that the result should be 'Not Exists'

But if I uncomment lines marked as 'Test 0', the result is:
Test 0 - Exists ----> ???? window is not open yet ?
Test 1 - Exoists
then script breaks with 'run error - cannot identify the object 'back to popup window' on this line:
Code:
Browser("Popup Window - HTML Code").Page("Popup Window - HTML Code").Link("back to Popup Windows").Click
This is very strange for me,
please help me.



--- Edit ----
Now I use descriptive programming:
Code:
If  Browser("name:=Popup Window - HTML Code Tutorial").Page("name:=examplea","title:=Popup Window - HTML Code Tutorial").Exist Then
     MsgBox( "Test 1 - Exists" )
else
    MsgBox( "Test 1 - Doesn't exist" )
End If
and this works fine.
But still can't catch why cannot use repository objects to test this stuff.


RE: test if a web page is visible on the screen - harishshenoy - 10-12-2012

Hi ,

I think this might be bcoz of the 'creation time' of the Browser. Remove the 'smart identification and ordinal identification 'in the repository and use only the fields which you used in the 'descriptive programming' to identify the same. This might do...

Thanks,
Harish