Closed justin-parker closed 6 years ago
@justin-parker You will need to do it like this...
let chromy = new Chromy({visible:true})
var selector = "div.content";
chromy.chain()
.goto('https://www.google.com/')
.evaluate(`_selector = '${selector}'`)
.evaluate( function() {
return document.querySelectorAll(_selector).length;
}, selector)
.result((r) => console.log("selector length: " + r))
.end()
.then(_ => chromy.close())
Thanks @garris
@justin-parker I'll add an way to make it easier.
This works for me:
const cssConfirm = '#maincontent > div.page.messages > div:nth-child(2) > div > div > div';
await chromy.wait(cssConfirm);
await chromy.evaluate(`_cssConfirm = '${cssConfirm}'`);
await chromy.evaluate(() => {
console.log('CSS: ' + _cssConfirm);
});
out:
CSS: #maincontent > div.page.messages > div:nth-child(2) > div > div > div
Thanks, @garris
The test below should return 1. Running
document.querySelectorAll("div.content").length
in the console on google.com returns 1. It appears the Chromy does not yet support args passed in toevaluate
(like nightmarejs).