Micro Focus QTP (UFT) Forums
Not going to Else (False) statement - 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: Not going to Else (False) statement (/Thread-Not-going-to-Else-False-statement)



Not going to Else (False) statement - mv8167 - 06-17-2011

This seems to work. But if my browser is "Page not Found" ie the webserver is down, etc, the path in my code still goes to the "If" statement (True), and not to the "Else" (False).

Can I get a look at my code to see why, the Else (False) is not sellected, even though the web server is clearly down?

My code:-)

Code:
Browser("Wisdom").Page("WisdomLogin").WebElement("Welcome to Wisdom").WaitProperty "visible", True, 5000

If Browser("Wisdom").Page("WisdomLogin").WebElement("Welcome to Wisdom").GetROProperty("visible") Then  'Gets stuck here when "The page cannot be displayed"
       ''Browser Opened successfully in URL
       Reporter.ReportEvent micPass, "Browser in URL: " & DataTable.GlobalSheet.GetCurrentRow, "URL: " & " - opened SUCCESFULLY."
Else
       'Browser Failed to open in URL
        Reporter.ReportEvent micFail,"Browser in URL: " & DataTable.GlobalSheet.GetCurrentRow, "URL: " & " - opened UNSUCCESFULLY."
        Browser("Wisdom").Close
        ExitTest
End If
Should I change:

Code:
Valid = Browser("Wisdom").Page("WisdomLogin").WebElement("Welcome to Wisdom").WaitProperty "visible", True, 5000

If Valid Then 'Gets stuck here when "The page cannot be displayed"


RE: Not going to Else (False) statement - parminderdhiman84 - 06-17-2011

Hello,

Please try by using the below code:

Code:
If Browser("Wisdom").Page("WisdomLogin").WebElement("Welcome to Wisdom").Exist(5) Then  
       ''Browser Opened successfully in URL
       Reporter.ReportEvent micPass, "Browser in URL: " & DataTable.GlobalSheet.GetCurrentRow, "URL: " & " - opened SUCCESFULLY."
Else
       'Browser Failed to open in URL
        Reporter.ReportEvent micFail,"Browser in URL: " & DataTable.GlobalSheet.GetCurrentRow, "URL: " & " - opened UNSUCCESFULLY."
        Browser("Wisdom").Close
        ExitTest
End If

Regards,
Parminder


RE: Not going to Else (False) statement - mv8167 - 06-18-2011

Thx, I nvr relized that the Exist and WaitProperty werer so interchangeable.

bye