Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uploading an image file with 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.

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

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

like image 234
Jeffpowrs Avatar asked Jun 26 '14 21:06

Jeffpowrs


People also ask

Can we upload file using JavaScript?

html file through a browser, the client will be able to upload a file to the server using Ajax and pure JavaScript. A pure JavaScript file uploader simplifies Ajax based interactions with the server.

How does Nightwatch js work?

Nightwatch. js framework is a Selenium-based test automation framework, written in Node. js and uses the W3C WebDriver API (formerly Selenium WebDriver). It works by communicating over a restful HTTP API with a WebDriver server (such as ChromeDriver or Selenium Server).

Does Nightwatch use Selenium?

Nightwatch. js is an automated testing framework for web applications and websites, written in Node. js and using the W3C WebDriver API (formerly Selenium WebDriver).


1 Answers

Use this for uploading image from local desktop

.setValue('input[type="file"]', require('path').resolve('/home/My-PC/Desktop/img.png')) 
like image 104
Ankit K Gupta Avatar answered Sep 23 '22 06:09

Ankit K Gupta