pesh
pesh

Reputation: 21

How to upload a file in Robot Framework?

I tried "choose file" but it is not working. I am not sure what to set 2nd argument to. I tried changing the different paths of file folder; it then navigates to the correct location but it's not selecting the text file or image in that location.

Choose File xpath   ${path} 

So I want to use AutoIt but I don't know how to combine it with Selenium, how to write code and where to keep the AutoIt script.

Upvotes: 1

Views: 6705

Answers (3)

aravin
aravin

Reputation: 1

The easiest way is to write C: then image file ex. C:\image.jpg

Choose file xpath C:\yourImageofYourFile.jpg

Upvotes: -2

Doanh Nguyen
Doanh Nguyen

Reputation: 11

It's better way to get Project Path and join it with your specific upload folder. After that just put the location with file name :)

Upvotes: 0

Humble_PrOgRaMeR
Humble_PrOgRaMeR

Reputation: 741

Here you need to give two arguments

  1. Web-element locator of the Browse button or link where you want to upload the file (locators like id, name xpath, css are user)
  2. then give the complete file path of the file you want to upload for Ex: If you file is in desktop and name of the file is fileName.txt then you path will be C:\Users\your_username\Desktop\fileName.txt (you can also use relative path of the file)

one such example line of code would be

1. Choose File  ${xpath_locator}  C:\Users\your_username\Desktop\fileName.txt
2. Chose File ${xpath_locator} ${file_path_variable}

where the ${file_path_varibale} taken from variable table of robot file.

you can explore more on all the Selenium Keywords in Robot Framework Here.

Upvotes: 2

Related Questions