0

I want to upload a text file in application under test. The path of text file is put in one of the cells of excel. I tried using excel library but I am facing issue here. My code is not identifying excel library. I have installed robot framework excel library package in pycharm. Below is my excel and code snippet.

*** Settings ***
    Library           Selenium2Library
    Library           ExcelLibrary
    Library           Collections

*** Variables ***
${path_excel}   D:\\Users\\test.xls

*** Test Cases ***
open Excel    ${path_excel}
   #Click File Upload Here   
    Choose File   xpath=//input[@class="dz-hidden-input"]    ${path}
    

*** Keywords ***
[Arguments]  ${path}

enter image description here enter image description here

1 Answer 1

1

You need to give your test case a name and run the excel keyword within it (indented)

e.g.

*** Settings ***
Library           Selenium2Library
Library           ExcelLibrary
Library           Collections

*** Test Cases ***
Test Case A
   ${path}  Get Path From Excel   D:\\Users\\test.xls
   Choose File   xpath=//input[@class="dz-hidden-input"]    ${path}

*** Keywords ***
Get Path From Excel
    [Arguments]  ${excel_file_path}
    Open Excel    ${excel_file_path}
    ${path}   Read Cell Data By Name   Robot_framework   A2
    [Return]  ${path}  

   

Your keyword also needs a name, just argument in keyword section isn't correct format, you use a keyword similar to how functions work in other languages

User Keyword Syntax

Sign up to request clarification or add additional context in comments.

8 Comments

Thanks Matthew but it is not working. Can you elaborate more specific with my example.
@Amaze_Rock can you tell me please the error you are getting in the output?
I have put this in keywords *** Keywords *** ${my_data} open Excel ${path_excel} :For ${i} in range 2 \ ${my_data} Read Cell Data By Name Robot_framework A${i} \ Append To List ${my_datalist} ${my_data} Log ${my_data} and then below under test case Choose File xpath=//input[@class="dz-hidden-input"] ${my_data} and error is Keyword '${my_data}' expected 0 arguments, got 1.
@Amaze_Rock okay I added a basic example of how to define a keyword, although this is unrelated to the question of not identifying an excel keyword. You really need to look up some fundamentals in the docs like in the link
Another error Replacing variables from keyword return value failed: Variable '${Path}' not found. I think it is not reading the cell where file path has been defined to upload.
|

Your Answer

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.