Download and use file with Protractor e2e test

2020-07-25 10:07发布

How do I write a test that download a file, and post it in a form.

it "should support download and upload a file", ->
    upload = element(By.id 'UploadInput');
    upload.sendKeys 'C:\\path\\to\\file\\file.txt'

Currently the upload works, but how do I download a file before and get it's path?

1条回答
劫难
2楼-- · 2020-07-25 10:43

Solved it by adding the file to project and got the absolute path like this:

it "should support download and upload a file", ->
    upload = element(By.id 'UploadInput');
    upload.sendKeys path.resolve(__dirname, '../../assets/file.txt')
查看更多
登录 后发表回答