-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getValue returns undefined #6
Comments
I'm trying this with evaluate now which I suspect may be a better solution but getting a syntax error:
returns a syntax error. Looking at the remote interface that seems to be valid syntax? And how do I enable the debug logging? |
Ah, seems that requires a function input. Not sure how to extract data better, but creating a evaluateElement function removing the .apply gives the desired result. Would it make sense to add a function to evaluate simple non-function expressions? This would allow for extracting page elements more easily. |
Hi @bobbysteel ! Regarding the first comment, I didn't code the .getValue() method thinking on how to get the text between HTML tags; it was made to get HTML Form elements values. I think that for that case, it's better to get it using .evaluate(), which refers also to your second message: The correct way to use the .evaluate method is this: const location = await browser.evaluate(function(selector) {
const selectorHtml = document.querySelector(selector)
return selectorHtml.innerText
}, '.graph-metric-current'); About the debugging, you just need to start the app setting an environment variable called DEBUG, to the value "HeadlessChrome:[file]', like this:
or:
or, if you want all the logs:
I hope it helps! |
Thanks Luciano. I'm almost there, but in your sample it throws ReferenceError: selector is not defined. I'm probably being really dumb here but what am I missing? |
My example was wrong! haha, sorry! |
MAGIC! Thanks!!! |
Hm. Not sure if this is my error or a bug.
Using getValue returns undefined for a valid element.
The returned should be a HTML value of the .graph-metric-current node shouldn't it? Using util.inspect also returns undefined, so I'm not quite sure what the object is meant to be.
Cheers
The text was updated successfully, but these errors were encountered: