Akhlesh vishnoi
Akhlesh vishnoi

Reputation: 141

Can anyone help me out to debug below Robot framework code?

I have written below Robot framework test case code to login into the application but facing "Test case cannot be empty" error.

I have installed Data driver library properly mapped the data in XLSX file

Below is the code

*** Settings ***
Library            SeleniumLibrary
Resource           ../Resources/Loginresources.robot
Library            DataDriver          ../TestData/Test.xlsx  

Test Template       Verify Login Message

*** Variables ***
${URL}            https://uat.tastelifelivelife.com/


*** Test Cases ***
LoginPage        
      [Template]  Verify Login Message
     
   
 
*** Keywords ***  
Verify Login Message
    [Arguments]    ${username}    ${password}    ${expected_message}
    Open Browser    ${URL}    chrome
    Maximize Browser Window
    Click Link      link=SIGN UP / LOGIN
    sleep   2s
    Click Element   xpath://div[@class='login']
    Input username       ${username}
    Input pwd            ${password}
    #Input Text      id=edit-name    ${username}
    #Input Text      id:edit-pass    ${password}
    Click Button    id=edit-submit
    sleep   3s
    #Wait Until Page Contains    ${expected_message}   timeout=5s 
    
    Page Should Contain    ${expected_message}
    Close Browser


 

Upvotes: 0

Views: 44

Answers (2)

You're expecting 3 arguments in your test template:

*** Keywords ***  
Verify Login Message
    [Arguments]    ${username}    ${password}    ${expected_message}

But you're not passing any argument to your test. So it's technically "empty" as there are only empty values in the variables. You only need to add the values for those arguments next to the test name:

*** Test Cases ***
LoginPage         my_username    my_password    expected_message
    [Template]  Verify Login Message

You can use the template for many other test cases as long as you name them and add the values for the expected arguments:

*** Test Cases ***
LoginUser1         username_1    password_1    expected_message_1    
LoginUser2         username_2    password_2    expected_message_2

Upvotes: 0

Helio
Helio

Reputation: 3737

Searching the Internet returned this message on our Forum, which mentions the DataDriver project page, and there you can see the structure of a test case: https://github.com/Snooz82/robotframework-datadriver?tab=readme-ov-file#structure-of-test-suite

You should check if you need to configure the dialect for the Excel file type, and also the delimeter (comma, semi-column).

Most probably your test is failing because you declared a classic Robot Framework Template, here:

LoginPage        
      [Template]  Verify Login Message

You should only the declaration at Test Template Verify Login Message and then verify the arguments passed to the first test. Maybe the *** Test Cases*** section is possible to omit.

Upvotes: 0

Related Questions