If...Then... ElseIf...Else 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: If...Then... ElseIf...Else statement (/Thread-If-Then-ElseIf-Else-statement) |
If...Then... ElseIf...Else statement - mv8167 - 04-21-2011 Now that I have my checkpoints working, how can I use them in an If...Then... ElseIf...Else statement? I have 3 scenerios I must consider. 1, succesfull login screen appears, 2, if the Failure screen apppears and, 3, if (1or 2 not seen) the server is down so exit. My code so far (but it is not working) Code: If Browser("Wisdom CTE").Page("WisdomLogin").WebElement("Login Failure.").Check CheckPoint("Login Failure.").exists Then To check which page opened, is the If...Then... statement Ok to use? If so, what am I incorrectly doing? Or should I not even try checkpoints? If "Text1" then...Else If "Text2" then ... Else ... Thx Lor RE: If...Then... ElseIf...Else statement - mv8167 - 04-21-2011 Ok, I have my new code working, I changed Exists to Exist (which one is correct). Now just my Elseif statement does not see the "Login Failure" text on the page. I found the statement: ElseIf Browser("Wisdom CTE").Page("WisdomLogin").WebElement("text:=Login Failure.").Exist Then 'Login Failed by searching this site. But I must be using WebElement("text:=Login Failure.") incorrectly? RE: If...Then... ElseIf...Else statement - futureQTPpro - 05-26-2011 Exist is correct, not Exists. When you're typing in the whole line and put a '.' in all the available methods for that type of object should appear in a drop-down menu. That's probably the easiest way to check things like this. Also, I'm guessing it should either be ("innertext:=Login Failure.") or ("outertext:=Login Failure.") Use object spy - the icon looks like Sherlock Holmes and is at the far right at the top (in the Tools Toolbar). Using that you can select the WebElement you want and find the text in the right-hand column matching "Login Failure." Then just look at whatever is in the corresponding left-hand column. That's what should be where "text" is now in your line WebElement("text:=Login Failure."). Hopefully this was helpful and wasn't insultingly basic or anything. I'm new to all this stuff too but I'll try to help if I can. Have a nice day! RE: If...Then... ElseIf...Else statement - mv8167 - 05-26-2011 Thx! I figured it out bu using Index:=0 also in my statement. |