0

I'm trying to upload a file using Capybara script. I got some help from the below link and I'm trying to use the autoIT option that specified in the below link:

Testing HTML5 File Upload with Capybara/Selenium Webdriver - Ruby

From the above page, I have a question on the below two lines:

find_field(<<upload_file_id>>).click

system("<<full_path>>\\file_upload.exe \"#{<<file_path>>}\" \"File Upload\"")

Thanks to the script, I have created an .exe with the given code and gave the above two lines in order to upload the file, but it is giving a syntax error.

What is "File Upload" in the above syntax? Is this the name of the file that I would like to upload? I tried so many ways (forward/backward slashes), but it is returning Syntax error (syntax error, unexpected keyword_end, expecting ')' (SyntaxError)). Here is what my syntax is. Please suggest and let me know what I'm missing. Appreciate suggestions in this regard. Any example with a specific file name in the syntax will really helps.

system("C:/Cucumber/cucumberdemo/features/file_upload.exe/"#     
{C:/Cucumber/cucumberdemo/Capybara.PNG}\"\File Upload\"")

system("C:\Cucumber\cucumberdemo\features\file_upload.exe\"#
{C:\Cucumber\cucumberdemo}\"\"Capybara.PNG\"")

system("C:/Cucumber/cucumberdemo/features//file_upload.exe/"#
{C:/Cucumber/cucumberdemo}/"/"Capybara.PNG/"")

system("C:/Cucumber/cucumberdemo/features/file_upload.exe/"#
{C:/Cucumber/cucumberdemo/Capybara.PNG}/"")

Also, will the System command also click the "Open" button from the dialog box or do I need to write a separate script for that?

2 Answers 2

1

Why not just use attach_file method from Capybara?

attach_file method

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

Comments

0

try with this system("C:/Cucumber/cucumberdemo/features/file_upload.exe /"#
{"C:/Cucumber/cucumberdemo/Capybara.png"}\ "\File Upload\"") file path also should placed in double quotes that u forgot like

{"file path"}

Comments

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.