Newbie to Javascript in Node environment...
Using this code below where the script is getting css values for a particular web element, how do I parse this in javascript?
driver.executeScript(script, ele).then(p => {
console.log(p);
})
The code above shows this result in the console.
{ class: 'container ng-scope', 'ng-controller': 'CalcCtrl' }
It's returned as type Object, so I can't figure out for example how to get the value of the key "class"...
If I change the code to this:
driver.executeScript(script, ele).then(p => {
console.log(p);
var obj = JSON.parse(p);
console.log(obj.class);
})
Where column 27 is the parse in JSON.parse...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.