下载文件并使用 Protractor e2e 测试 [英] Download and use file with Protractor e2e test

查看:49
本文介绍了下载文件并使用 Protractor e2e 测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编写下载文件并将其发布到表单中的测试.

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?

推荐答案

通过将文件添加到项目中解决并得到如下所示的绝对路径:

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')

这篇关于下载文件并使用 Protractor e2e 测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆