Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attach file fails in Firefox and Windows 10 #2155

Closed
papitorcks opened this issue Feb 7, 2019 · 9 comments
Closed

Attach file fails in Firefox and Windows 10 #2155

papitorcks opened this issue Feb 7, 2019 · 9 comments

Comments

@papitorcks
Copy link

Meta

Capybara Version: 3.13.2
Driver Information (and browser if relevant): Selenium Driver with Firefox 65 on Windows 10

Capybara.configure do |config|
config.default_driver = :selenium
end

Expected Behavior

Upload with success

Actual Behavior

 Failure/Error: attach_file('file-upload', @arquivo)

 Selenium::WebDriver::Error::InvalidArgumentError:
   File not found: C:/project/spec/fixtures/arquivo.txt
 # WebDriverError@chrome://marionette/content/error.js:179:5
 # InvalidArgumentError@chrome://marionette/content/error.js:306:5
 # interaction.uploadFiles@chrome://marionette/content/interaction.js:502:13
 # ./spec/upload_spec.rb:11:in `block (2 levels) in <top (required)>'

Steps to reproduce

   @arquivo = Dir.pwd + '/spec/fixtures/arquivo.txt'
    attach_file('file-upload', @arquivo)
    click_button 'Upload'

    div_arquivo = find('#uploaded-file')
    expect(div_arquivo.text).to eql 'arquivo.txt'
@twalpole
Copy link
Member

twalpole commented Feb 7, 2019

You need to translate / to \ in the filename string since you're on windows

@lflucasferreira
Copy link

I am facing the same issue. And I am translating / to \ if "OS.windows?" as you can see below.

It works in Chrome but not in Firefox 68.0 (64-bits).

def attach_doc_file(id, file)
path = File.join(Dir.pwd, "features/support/public/doc/#{file}")
path = path.tr('/', '\') if OS.windows?
attach_file(id, path)
end

@twalpole
Copy link
Member

@lflucasferreira What is the actual error you get?

@lflucasferreira
Copy link

This is the actual error:

File not found: C:/Project/cnb/features/support/public/doc/CEP_Upload.xml (Selenium::WebDriver::Error::InvalidArgumentError)
WebDriverError@chrome://marionette/content/error.js:179:5
InvalidArgumentError@chrome://marionette/content/error.js:306:5
interaction.uploadFiles@chrome://marionette/content/interaction.js:501:13

@twalpole
Copy link
Member

@lflucasferreira Are you working with a remote driver by any chance?

@twalpole
Copy link
Member

twalpole commented Jul 12, 2019

@lflucasferreira If you're not using a remote driver but you're using Capybara >= 3.24, could you please try 3.23 and see if the issue goes away.

@lflucasferreira
Copy link

You are right. I downgraded the version to 3.23 and it worked. I was using 3.25. Do you know if this is gonna be fixed soon? Thank you!

@twalpole
Copy link
Member

@lflucasferreira c059bfe is the change that broke this -- I'm make a quick fix that only expands if the path is relative but then I need to think about a better way to handle this.

@twalpole
Copy link
Member

@lflucasferreira Please see #2228 and provide feedback

@lock lock bot locked and limited conversation to collaborators Aug 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants