1
votes

I've encountered a problem relating to Robot Framework test cases. After executing it, the console (cmd screen) displays error:

"[ ERROR ] Parsing 'Login_admin_page.txt' failed: File has no test case table."

Please take a look my test suite as well as test case and help me figure out the issue:

A. Structure of Test cases:

TS_test(folder)

--Login_admin_page.txt (--> main test case)

--resource.txt (--> resource file)

B. Content of test cases file:

Login_admin_page.txt

***Settings***
Documentation     A resource file with reusable keywords and variables.
...               This test is functionally identical to the example in
...               valid_login.txt file               

Resource          resource.txt
Test Teardown     Close Browser

***Test Cases***
Open Login page
    Open Browser To Login Page

resource.txt

    *** Settings ***
Documentation     A resource file with reusable keywords and variables.
...
...               The system specific keywords created here form our own
...               domain specific language. They utilize keywords provided
...               by the imported Selenium2Library.

Library     Selenium2Library


*** Variables ***
${SERVER}         http://google.com
${BROWSER}        Firefox
${DELAY}          0
${VALID USER}     admin
${VALID PASSWORD}    admin
${INVALID USER}      xyz
${INVALID PASSWORD}  invalid 

*** Keywords ***
Open Browser To Login Page
    Open Browser    ${SERVER}    ${BROWSER}
    Maximize Browser Window
    Set Selenium Speed    ${DELAY}
    Login Page Should Be Open

Login Page Should Be Open
    Title Should Be    Google

Use cmd and access to folder "TS_test", execute "pybot Login_admin_page.txt". The screen displays error.

Thanks.

6
The four spaces before Settings in resource.txt is proably just a copy-paste-error?Harri
Your code works for me. Are you absolutely certain these are the exact files you are using? I ask because these files will not give you the "no test case table" error that you report.Bryan Oakley
@Bryan Oakley: yes, it's exact my test cases. But Idon't know why this doesn't work, also try to copy all them to a new blank file,, then they works ???? WOuld you like to give out comments ?Little Chicken
@Harri - NO spaces before Setting in my test case in local disk. Just copy content to Stack-overflow to need your help.Little Chicken
If you copy the same exact file to a different location, the only thing I can think of is that you weren't running this file when you got the error. Maybe you renamed it earlier and were accidentally running an old version. Look in the log file that has an error and verify that the exact file it tried to run is the file you think you're running. My guess is, you're running an older version of the file. Robot isn't flakey or random -- if it parses OK in one folder it will parse OK when you move it, and if it gives a parse error in one folder, it will give parse errors in another folder.Bryan Oakley

6 Answers

2
votes

The error File has no test case table can only occur in one circumstance: you do not have a testcase table. If you have a test case table but have no test cases, you'll get a different error.

A testcase table is denoted by a line that begins with one or more asterisks and then the phrase "Test Case" or "Test Cases". Case doesn't matter, and trailing asterisks are ignored. A fairly common pattern seems to be to use multiple asterisks on both ends of the line, eg: *** Test Cases ***

If you try to give a file without such a heading to robot, you will get the error you report. For example, trying to run robot on a completely empty file will give that exact error. Also, if you misspell "Test Case", you'll get the same error.

Given that, I'm wondering if your error is simply that you forgot to save the file before trying to run it.

1
votes

Please set proper line endings. In my case I've changed from Mac (CR) to UNIX (LF)

0
votes

How about encoding of your test case files? I saved unicode encoded test file and I use to have the same error. Save your test case files in UTF-8 and It will fix your problem.

0
votes

I have encountered similar file - parsing errors using Robot Framework in the past, mostly when trying to use Microsoft Word to author html files (not recommended!). I have always found that following the advice given in the Robot Framework user Guide about Debugging eventually helps me track the problem down.

In this case, I would recommend you try switching on Robot Framework's syslog output and looking through to see what it has managed to parse, if anything, from your test case file. I recently used this to figure out a nasty UTF-8 character encoding problem introduced into a html test case file by Microsoft Word (again, not recommended unless you really have to!).

(From the User Guide):

#!/bin/bash

export ROBOT_SYSLOG_FILE=/tmp/syslog.txt
export ROBOT_SYSLOG_LEVEL=DEBUG

pybot --name Syslog_example path/to/tests
0
votes

I had the same problem happen to me, and in my case it was simply a missing new line after * Test Cases * and the start of the actual test table.

0
votes

This happened when you copy past the content of the test case file. In my case I have copied test case content and paste in nano editor

It got pasted something like below without proper spacing

*** Settings *** Library    Selenium2Library *** Variables *** ${BROWSER}    firefox *** Testcases *** Hello    Open Browser    http://www.google.com   browser=${BROWSER}

Then I have intend and aligned properly like below and its works

*** Settings ***
Library    Selenium2Library

*** Variables ***
${BROWSER}    firefox

*** Testcases ***
Hello
    Open Browser    http://www.google.com   browser=${BROWSER}