Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
If...Then... ElseIf...Else statement
#1
Solved: 11 Years, 4 Months ago
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
      'Login Failed
         Reporter.ReportEvent micPass, "Login", "Login Failed - Bad User ID or Password"
       Browser("WisdomLogin").Close
ElseIf (Browser("WisdomLogin").Page("Wisdom CTE").Image("Wisdom").WaitProperty "visible", True, 3000).exists Then
        'Login Passed -  Logout only appears when the login is successful
       Reporter.ReportEvent micPass, "Login", "Login Passed"  
Else
       'None of the object exist
      Reporter.ReportEvent micFail, "Login", "Login Failed. Unknown error"
        Browser("WisdomLogin").Close
End If

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
Reply
#2
Solved: 11 Years, 4 Months ago
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?
Reply
#3
Solved: 11 Years, 4 Months ago
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!
Reply
#4
Solved: 11 Years, 4 Months ago
Thx!
I figured it out bu using Index:=0 also in my statement.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)