0

I have written code using robot framework, to open a browser and enter the values in a fields, but what is happening, it is opening the browser and redirecting the URL, but it is not writing to the fields and it is throwing the error ( i have attached in the screenshot ).

Please find below to check for the code and please help me resolve this.

Here is my tests.robot :

*** Settings ***
Library Selenium2Library
Resource resource.robot
*** Variables ***
@{TEST_DATA} = fname lname 9734565432 abcdefgh@3
@{TEST_DATA1} = lname fname 8756454456 sadsadef#1
*** Test Cases ***
open linkedin
 [Tags] linkedin
 open browser about:blank ${BROWSER}
 maximize browser window
 go to ${URL}
add entries
 resource.FIRST_NAME @{TEST_DATA}[0]
 resource.LAST_NAME @{TEST_DATA}[4]
 resource.PHONE_NUMBER @{TEST_DATA}[4]
 resource.PASSWORD @{TEST_DATA}[4]
close Linkedin
 close all browsers

And here resources.robot :

*** Settings ***
Library Selenium2Library
*** Variables ***
${BROWSER} = gc
${URL} = https://www.linkedin.com/
${FIRST_NAME} = xpath=//*[@id="reg-firstname"]
${LAST_NAME} = xpath=//*[@id="reg-lastname"]
${PHONE_NUMBER} = xpath=//*[@id="reg-email"]
${PASSWORD} = xpath=//*[@id="reg-password"]
*** Keywords ***
FIRST_NAME
 input text ${FIRST_NAME}
LAST_NAME
 input text ${LAST_NAME}
PHONE_NUMBER
 input text ${PHONE_NUMBER}
PASSWORD
 input text ${PASSWORD}

Error Snap :

Image showing the Error

NarendraR
1,5731 gold badge17 silver badges35 bronze badges
asked Nov 4, 2017 at 14:43

2 Answers 2

3

The error should be very self-explanatory: you are passing an argument to the keyword FIRST_NAME ("got 1"), but that keyword doesn't take an argument ("expected 0").

To define your keyword to take an argument use [Arguments] to list the arguments that your keyword accepts. For example:

FIRST_NAME
 [Arguments] ${FIRST_NAME}
 input text ${FIRST_NAME}

For more information see User Keyword Arguments in the robot framework user guide:

The syntax is such that first the [Arguments] setting is given and then argument names are defined in the subsequent cells. Each argument is in its own cell, using the same syntax as with variables. The keyword must be used with as many arguments as there are argument names in its signature. The actual argument names do not matter to the framework, but from users' perspective they should be as descriptive as possible. It is recommended to use lower-case letters in variable names, either as ${my_arg}, ${my arg} or ${myArg}.

answered Nov 7, 2017 at 13:14
1

As per Input Text Keyword definition

Input Text locator, text 

Types the given text into text field identified by locator.

So your as per it you need to pass the locator and text to the Input Text keyword, so in your above code you need to pass argument for text as you are using locator in the same file, You need to refactor resource.robot file as below,

resource.robot

*** Settings ***
Library Selenium2Library
Library BuiltIn 
*** Variables ***
${BROWSER} = gc
${URL} = https://www.linkedin.com/
${FIRST_NAME} = xpath=//*[@id="reg-firstname"]
${LAST_NAME} = xpath=//*[@id="reg-lastname"]
${PHONE_NUMBER} = xpath=//*[@id="reg-email"]
${PASSWORD} = xpath=//*[@id="reg-password"] 
*** Keywords ***
 FIRST_NAME
 [Arguments] ${TEST_DATA}
 Input Text ${FIRST_NAME} ${TEST_DATA}
 LAST_NAME
 [Arguments] ${TEST_DATA}
 Input Text ${LAST_NAME} ${TEST_DATA}
 PHONE_NUMBER
 [Arguments] ${TEST_DATA}
 Input Text ${PHONE_NUMBER} ${TEST_DATA} 
 PASSWORD
 [Arguments] ${TEST_DATA}
 Input Text ${PASSWORD} ${TEST_DATA}
answered Nov 27, 2017 at 11:57

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.