I've got several working Robot Framework tests that I'm trying to consolidate into one test suite and run through a template. The tests are functionally the same, just being executed from a different URL. So that's the one parameter that's different. I'm trying to pass the URL into each test case, but I am getting an error: "Keyword 'Setup' expected 0 arguments, got 2."
*** Settings ***
Documentation Login tests
Library Zoomba.GUILibrary
Suite Setup Setup
Test Template Template 1
*** Variables ***
${browser} chrome
${url1} https://<test.url1>
${url2} https://<test.url2>
${url3} https://<test.url3>
*** Keywords ***
Setup
Open Browser ${url} browser=${browser} options=add_argument("<argument>")
Maximize Browser Window
Set Selenium Speed 0.2s
Log To Console Setup complete. Logging in...
Template 1
[Arguments] ${url} ${browser}=${browser}
Setup ${url} ${browser}
<Login tests>
*** Test Cases ***
Site 1 Login
${url1}
Site 2 Login
${url2}
Site 3 Login
${url3}
Anybody have any ideas? Please let me know, thanks!
You are calling Setup with two arguments, like the error says:
Template 1
[Arguments] ${url} ${browser}=${browser}
Setup ${url} ${browser}
<Login tests>
How can I stop Chromium (RobotFrameWork with Browser Library) stop from running in incognito?
what I try is:
*** Settings ***
Library Browser
*** Test Cases ***
test1
New Browser chromium headless=false args=["--user-data-dir"]
error message is:
Error: browserType.launch: Pass userdDataDir parameter to 'browserType.launchPersisentContext(userDataDir, ...)' instead of specifying --user-data-dir argument....
but...
how would that look like in .robot framework language so to speak?
I am trying to make a testcase in robotframework with SSHLibrary and running into an error trying to connect with the FTP server. The error I get is keyword login.login expects 0 arguments and gets two. I do not really understand why it does expect 0 arguments.
the resource file in which the keyword file exists has the following code:
*** Settings ***
Library SSHLibrary
*** Keywords ***
lOGIN
Set Default Configuration 30s
Open Connection ${HOST}
Login ${USERNAME} ${PASSWORD}
The test I like to run looks like:
*** Settings ***
Documentation Example of testing an accrual for TLOG
Resource ../Resources/login.robot
*** Variables ***
${HOST} sitenv
${USERNAME} crmapplication
${PASSWORD} Company11*
*** Test Cases ***
logintositenv
login.login
Any idea what is going wrong? I am especially surprised I cannot get it to work because I used the open connection and login keywords from SSHLibrary before when I was trying out a few things and it worked fine.
As you said login.login That tells me you have probably another library that has keyword login. In this case you have to specify that you want to use SSH library.
You can do this with
SSHLibrary.Login
Here you can have a look how to import library with custom name and use keywords
I'm new to Robot Framework. When I run ride.py, I'm getting this error.
here is my code:
Create Session chat ${URL1} headers=${MyHeaders1}
Thank you very mych in advance for your help.
Looks like you're trying to use the requests library but haven't imported it. I recommend that you read the user guide, especially the part on importing libraries.
Basically you want to add this in your *** Settings *** section:
*** Settings ***
Library RequestsLibrary
You may also want to check out the library's Github README, there's a few usage examples in there that will likely help you.
I have explain the issue and also the solution.
Problem :
*** Variables ***
${Base_URL} http://www.thetestingworldapi.com/
*** Test Cases ***
TC001_GetRequest
create session thetestingworldapi ${Base_URL}
${response} = get request thetestingworldapi api/studentsDetails
Error in console: No keyword with name '${response}= get request ggg' found.
To resolve this kind of error just do one change in the code part, am attching silution as well below.
Solution :
*** Variables ***
${Base_URL} http://www.thetestingworldapi.com/
*** Test Cases ***
TC001_GetRequest
create session thetestingworldapi http://www.thetestingworldapi.com/ --- Use the main base url instead of the variable and this will work.
${response} = get request thetestingworldapi api/studentsDetails
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.
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.
Please set proper line endings.
In my case I've changed from Mac (CR) to UNIX (LF)
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.
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
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.
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}