Question

I read that you can use a pipe-separated format for Robot Framework tests, but in my code:

*** Settings ***
| Documentation | A test suite with a single test for valid login.
| Library | Selenium2Library
| Resource | AdminResource.txt

*** Variables ***
| ${LOGIN URL} | http://local.econnect-admin.com/
| ${BROWSER} | ff

| ${Login button} | xpath=//body/div[2]/div/div[2]/div[2]/div/form/fieldset/div[3]/button

*** Test Cases ***
| Valid Login
|| Open Browser To Login Page
|| Input Text | a11y-username | username
|| Input Text | a11y-password | password
|| Click Log in
|| Welcome Page Should Be Open

*** Keywords ***
| Open Browser To Login Page
|| Open Browser | ${LOGIN URL} | ${BROWSER}
|| Maximize Browser Window
|| Wait Until Page Contains Element | ${Login button} | 5s

| Click Log in
|| Click Element | ${Login button}

| Welcome Page Should Be Open
|| Location Should Be | ${LOGIN URL}
|| Wait Until Page Contains | Accounts | 5s
|| Page Should Contain | Accounts

When ran the code gives a variety of errors:

[ ERROR ] Error in file 'C:\Python\AdminTests\test.txt': Setting variable '|${LOGIN URL} | http://local.econnect-admin.com/' failed: Invalid variable name '|${LOGIN URL} | http://local.econnect-admin.com/'.
[ ERROR ] Error in file 'C:\Python\AdminTests\test.txt': Setting variable '|${BROWSER} | ff' failed: Invalid variable name '|${BROWSER} | ff'.
[ ERROR ] Error in file 'C:\Python\AdminTests\test.txt': Setting variable '|${Login button} | xpath=//body/div[2]/div/div[2]/div[2]/div/form/fieldset/div[3]/button' failed: Invalid variable name '|${Login button} | xpath=//body/div[2]/div/div[2]/div[2]/div/form/fieldset/div[3]/button'.

It also tells me that each line of my test cases (including the name of the test case) contain to keywords.

Have I wrongly formatted my test scripts, or am I misinformed about pipe-separated formatting?

Edit - In another question the answer was given using this format

Thanks in advance.

Was it helpful?

Solution

You must have spaces between pipes. Consider this line:

|| Open Browser | ${LOGIN URL} | ${BROWSER}

you need to change it to this:

| | Open Browser | ${LOGIN URL} | ${BROWSER}

From the user guide:

Pipe and space separated lines are recognized by the mandatory leading pipe, but the pipe at the end of the line is optional. There must always be at least one space on both sides of the pipe (except at the beginning and end) but there is no need to align the pipes other than if it makes the data more clear.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top