Questions tagged [nightmare]

Nightmare is a node module which implements a high-level bridge between node.js and the headless PhantomJS browser. Nightmare v2 switches to electron (atom-shell) as the underlying browser. Please include the version that you use in your question.

Definition:

According to the Official Documentation:

Nightmare is a high-level browser automation library from Segment.

The goal is to expose a few simple methods that mimic user actions (like goto, type and click), with an API that feels synchronous for each block of scripting, rather than deeply nested callbacks. It was originally designed for automating tasks across sites that don't have APIs, but is most often used for UI testing and crawling.

Under the covers it uses Electron, which is similar to PhantomJS but roughly twice as fast and more modern.

Important Links:

456 questions
10
votes
1 answer

Specify SOCKS Proxy For NightmareJS?

I'm able to set an HTTP proxy just fine for NightmareJS but how do I specify the type (http/socks5/socks4)? Here's the code I use to set an HTTP proxy: const nightmare = Nightmare({ show:true, switches: { …
xendi
  • 2,332
  • 5
  • 40
  • 64
10
votes
1 answer

clear cache in Nightmare.js (Electron)

I'm using nightmare js to log into a site that sets a token in local storage. However, any future tests I run the user is already logged in. I'm guessing the local storage wasn't cleared. Is there any way to do this? My code in…
Saad
  • 26,316
  • 15
  • 48
  • 69
9
votes
4 answers

Download a file using Nightmare

I am using Nightmare to create a automated downloader for today's newspaper. I managed to login and go the the specified page. However I could not find out how to download a file with Nightmare. var Nightmare = require('nightmare'); new…
Fokke Dekker
  • 101
  • 1
  • 6
8
votes
3 answers

Cannot understand how to open a simple TWA inside an app (using AndroidX)

I am trying to open a TWA inside my app and have researched for 2 days. I've already managed to create a single TWA app, no fuss, just edit the manifest and a few things more. Now I need to have my own app - let's say the app has a splash screen…
Shadow
  • 4,168
  • 5
  • 41
  • 72
8
votes
1 answer

How to make a POST request in NightmareJs

I have been writing some test cases in PhantomJs and CasperJs. Recently I stumbled on NightmareJs which uses ElectronJs. I wanted to know if I can automate POST requests (such as below) in NigthmareJs (maybe using goto, but I don't see any…
zubair1024
  • 843
  • 8
  • 24
8
votes
2 answers

How to run nightmare.js on google appengine for node.js

There is famous issue with nightmare and electron not running on headless linux servers. The official electron docs suggest to use xvfb in order to fake the display. They suggest to use this .yml file for travis. addons: apt: packages: …
hhsadiq
  • 2,871
  • 1
  • 25
  • 39
8
votes
4 answers

Nightmare.js not working as expected on Ubuntu Linux cloud server

I can't seem to get nightmare.js to work on an Ubuntu Linux 14.04 server [via DigitalOcean]. I've installed PhantomJS (1.9.8) and Node (4.2.4), and they are working well as far as I can tell. For example, when I run this: phantomjs loadspeed.js…
ObiHill
  • 11,448
  • 20
  • 86
  • 135
8
votes
1 answer

Running electron (atom-shell) headlessly on linux server through Nightmare.js

I am building a scraper to make JS single page applications easily crawlable. After some incredible frustration with PhantomJS (memory leaks, outdated webkit, undead processes, among many other problems) I decided to switch to NightmareJS which can…
Rayjax
  • 7,494
  • 11
  • 56
  • 82
7
votes
2 answers

Nightmare.js screenshot buffer length 0

I'm running a nightmare.js script where where I'm trying to take a screenshot of multiple elements on a page. The first element is captured just fine, but every other element that is below the fold is captured with a zero length. I am struggling to…
auser
  • 13,808
  • 4
  • 21
  • 15
7
votes
4 answers

Is it possible to copy/paste with Electron?

I'm using Electron + Nightmare.js to do unit tests. I need to copy a string to the clibboard > focus a element > paste the content. Then the test is about if my JavaScript is handling behaving properly. I read in the electron docs about the…
Sergio
  • 28,539
  • 11
  • 85
  • 132
7
votes
1 answer

Returning HTML body from Nightmare.js

I'm currently working on some scraping with cheerio and nightmare. The reason why I'm using both and not just cheerio is because I have to manipulate the site to get to the part that I want to scrape and I found nightmare very good at doing those…
Jose Bernhardt
  • 887
  • 1
  • 10
  • 24
7
votes
3 answers

How can I pass a callback to a generator that I pass to the "vo" library?

I am trying to understand how callbacks work so I created a function and passed a second argument named 'callback', which I call at the end of the function with 'callback(arr)' . However I am getting an error which says : "callback is not a…
RetroCode
  • 342
  • 5
  • 14
7
votes
1 answer

Dynamic paging with Nightmare / Electron (page scrape)

I'm attempting to scrape dynamic paging websites with Nightmare / Electron. I don't see a way to perform a do... until with nightmare functions OR a way to chain evaluate calls with logic. Here's a simple code example that merely Googles a phrase…
Stan Smith
  • 896
  • 7
  • 19
7
votes
1 answer

Use Nightmare.js without ES6 syntax and yield

I built a simple node script using nightmare.js to scrape websites var Nightmare = require('nightmare'); var vo = require('vo'); vo(run)(function(err, result) { if (err) throw err; }); function *run() { var x = Date.now(); var…
Rayjax
  • 7,494
  • 11
  • 56
  • 82
6
votes
0 answers

How do I use Jest to test a browserify bundle of front-end code which needs a DOM API?

I'm attempting to use Nightmare to test front-end code which will eventually manipulate an SVG client-side. I'm using jest to write these tests. I'm attempting to define an asynchronous utility function which I can use as an interface to…
aresnick
  • 1,635
  • 12
  • 24
1
2 3
30 31