Just starting to learn Javascript in a Node environment...
I'm trying to use the code snippet below to extract CSS values for a specific web element, but I'm having trouble parsing it in JavaScript.
driver.executeScript(script, ele).then(p => {
console.log(p);
})
When this script is executed, the following output is displayed in the console:
{ class: 'container ng-scope', 'ng-controller': 'CalcCtrl' }
The result is of type Object and I'm struggling to access the value associated with the "class" key.
If I modify the code as follows:
driver.executeScript(script, ele).then(p => {
console.log(p);
var obj = JSON.parse(p);
console.log(obj.class);
})
An error occurs with reference to column 27 during the execution of JSON.parse...
Error Screenshot