mardi 17 juillet 2018

Using Selectors In Nightmare js

I'm still pretty new at automated testing, and I'm trying to write tests for my company.

My biggest problem here is using selectors. I can't seem to figure out how to use them for my purposes.

It's super easy for me to use ID's, like .click('#example'), but we usually don't use id="example" in our CSS.

To start, I'm trying to make it fill out the "first name" input in a form on our site. Here's my code:

const Nightmare = require('nightmare') const nightmare = Nightmare({ show: true })

const Nightmare = require('nightmare')
const nightmare = Nightmare({ show: true })

nightmare
  .goto('https://activeforskolinplan.com/lim-f-i/home')
  .wait(5000)
  .click('.firstName')
  .type('.firstName', 'TEST')
  .wait(5000)
  .evaluate(() => document.querySelector(5000).href)
  .end()
  .then(console.log)
  .catch(error => {
    console.error('Search failed:', error)
  })

The '.firstName' selector in this test is the input classified as name="firstName" in our code.

But in my terminal, it's always saying it "can't find the selector .firstName"

What am I doing wrong here? What can I be doing better?

Aucun commentaire:

Enregistrer un commentaire