mardi 17 juillet 2018

Clicking Menu Options In Nightmare js

I'm trying to fill out this form on my company's site with nightmarejs tests. I can't click the menu, but I can fill out everything else.

The goal of this is to click the "State" menu, and click the "Alabama" option.

What am I doing wrong here? Here's my code:

const Nightmare = require('nightmare')
const nightmare = Nightmare({ show: true })
//the goal here is to click through the site, purchase some products, and successfully make it to the receipt page.

nightmare
  //cobalt forskolin July 2018 URL
  .goto('https://activeforskolinplan.com/lim-f-i/home')
  .wait(5000)
  //fill out the form
  .type('input[name="firstName"]', 'TEST')
  .type('input[name="lastName"]', 'TEST')
  .type('input[name="address1"]', 'TEST')
  .type('input[name="aptNum"]', 'TEST')
  .type('input[name="zip"]', '66666')
  .type('input[name="city"]', 'TEST')
  .click('select[name="state"]')
  .click('option[value="AL"]')
  .type('input[name="phone"]', '4444444444')
  .type('input[name="email"]', 'test@ipartnr.com')
  //click the "RUSH MY TRIAL" button
  .click('button[class="submit-button"]')
  .wait(1000)
  .evaluate(() => document.querySelector('button[class="submit-button"]').href)
  .end()
  .then(console.log)
  .catch(error => {
    console.error('Search failed:', error)
  })

Aucun commentaire:

Enregistrer un commentaire