Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
53 views
in Technique[技术] by (71.8m points)

javascript - Nightmare JS selector logic

I'm using nightmare over my own site, for testing frontend. The problem is about selector, my site is a bit dynamic and the selector logic of Nightmare seem intricate. I'll try to explain:

var test = yield nightmare
        .goto('http://example.com')
        .type('#input_1', text1)
        .type('#input_2', text2)
        .click(".submit")
        .end()
        .then(()=>console.log('done'));

This works well, but sometimes i need to select the input type more flexible, somethings like this:

var test = yield nightmare
        .goto('http://example.com')
        .type('div:contains("label1") > input').val('text1'), text1)
        .type('div:contains("label2") > input').val('text2'), text2)
        .click(".submit")
        .end()
        .then(()=>console.log('done'));

With this i receive this error:

Error: Failed to execute 'querySelector' on 'Document': 'div:contains("Sinistro") > input' is not a valid selector.

question from:https://stackoverflow.com/questions/65934861/nightmare-js-selector-logic

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...