使用Nightwatch.js上传图片文件 [英] Uploading an image file with Nightwatch.js

查看:913
本文介绍了使用Nightwatch.js上传图片文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Chrome驱动程序使用nightwatch.js来运行前端测试。我需要测试图像上传工作正常,大概通过提供的文件输入,因为有一个成功的帖子上运行的回调。

I'm running front-end tests using nightwatch.js using the Chrome Driver. I need to test that image uploading works properly, presumably through the provided file input since there are callbacks that run on a successful post.

我知道这可以使用Selenium Web Driver的sendKeys方法完成。

I'm aware that this can be done using sendKeys method of the Selenium Web Driver.

你用javascript和nightwatch.js完成了这个吗?
您可以访问Selenium webdriver或者一个接口吗?

How can you accomplish this using javascript and nightwatch.js? Can you access the Selenium webdriver or an interface with it?

推荐答案

使用这个从本地桌面上传图片

Use this for uploading image from local desktop

.setValue('input[type="file"]', require('path').resolve('/home/My-PC/Desktop/img.png')) 

这篇关于使用Nightwatch.js上传图片文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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