Micro Focus QTP (UFT) Forums
Help with If - Then 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: Help with If - Then statement (/Thread-Help-with-If-Then-statement)



Help with If - Then statement - pipsonian - 05-19-2009

My company has just introduced the QTP and we have been asked to start working on it. I have no prior experience with it.

as an exercise, i started testing the yahoo mail. Those of you who have used yahoo, know that Yahoo lets you sign into the messenger chat by clicking on the offline link (on top of the page in yahoo inbox) and then lets u chose the options like available, or sign in as invisible etc. I am trying to write a statement which checks that if the value for that web element is "offline", then it should click on offline and then click on the available link. i have written the following code but it doesnt seem to work. Your help is much appreciated.
Code:
If Browser("Yahoo! Mail: The best").Page("(9 unread) Yahoo! Mail,_3").WebElement("Offline") Then
Browser("Yahoo! Mail: The best").Page("(9 unread) Yahoo! Mail,_3").WebElement("Offline").Click
Browser("Yahoo! Mail: The best").Page("(9 unread) Yahoo! Mail,_2").WebElement("Available").Click
End If



RE: Help with If - Then statement - sreekanth chilam - 05-19-2009

hi,

try the following.

Code:
If Browser("Yahoo! Mail: The best").Page("(9 unread) Yahoo! Mail,_3").WebElement("Offline").exist Then
Browser("Yahoo! Mail: The best").Page("(9 unread) Yahoo! Mail,_3").WebElement("Offline").Click
Browser("Yahoo! Mail: The best").Page("(9 unread) Yahoo! Mail,_2").WebElement("Available").Click
End If



RE: Help with If - Then statement - stephenlb4u - 05-28-2009

Hi,

Hope you forget to give the condition...

If (Condition) = true then

Statement....

Else

Statement

End If


Code:
If Browser("Yahoo! Mail: The best").Page("(9 unread) Yahoo! Mail,_3").WebElement("Offline").GetROProperty("value",Offline)=False Then
Browser("Yahoo! Mail: The best").Page("(9 unread) Yahoo! Mail,_3").WebElement("Offline").Click Else
Browser("Yahoo! Mail: The best").Page("(9 unread) Yahoo! Mail,_2").WebElement("Available").Click
End If

Stephen