The else if command will work as depicted above

[Precondition]

[Steps]

  1. Use the command to login to the website.
  2. Enter email and password
  3. Click Login.

 [Expected]

3. Login to the website successfully.

3. Manipulate actions on web pages.

Create Test precondition

Open website: https://profile.w3schools.com/log-in?redirect_url=https%3A%2F%2Fmy-learning.w3schools.com

  • Click “Record script”  button  to start making “record” at the website.
  • Enter the website link in the text box “Base URL” and Click “Start Recording” button.

Create steps for script

  • When the URL link is opened, the tool will automatically generate the default steps: open and set window size.
  • Use “Store xpath count” command to retrieve and store the number of UI elements, get the target of the command by copying the xpath of the element to be selected on the website (copy xpath element Log in).
  • Then set Value as “Log in”.
  • Use the “If” statement: to check if the element (Log in) exists on the screen of the website or not. If the visible element (at least 1 Login element is displayed on the screen) -> True, the steps inside the “If” command will be executed.
  • Follow the steps to type email, password and click the “Login” button on the screen.  
  • If the element (Log in) is not visible -> False, the steps inside the “If” statement will be skipped and not executed.  Next, use the “else” command to perform the desired actions on the current login screen.
  • Then use “end” to end the command.

Run Test script

  • Click button “Stop Recording” and do “Run current Test”.

➩ Test script was created and run successfully:

Leave a Reply

Your email address will not be published. Required fields are marked *