I'm having some problems getting these two commands to work together. Here is the issue.
I execute the ChromeFindElements command thusly:
ChromeFindElements>session_id,xpath,/html/body/form/div[3]/div[2]/table/tbody/tr/td/div[2]/div/div[3]/table/tbody/tr/td[1]/div/div/table/tbody/tr[1]/td/table/tbody/tr/td/a,elements
When I inspect elements in the watchlist, I see that there is data there, and that the elements array has one entry.
Then, in order to properly view the contents of the elements array, I execute the ChromeGetElementData command like so:
ChromeGetElementData>session_id,elements_1,text,ElementText
ChromeGetElementData>session_id,elements_1,value,ElementValue
For good measure, I am looking at both text and values.
But the result is that ElementText is blank and ElementValue is Null
How can the ChromeFindElements command return what appear to be valid values, while the ChromeGetElementData command appears to be blissfully ignorant of any data at all?
Any help on this would be appreciated.
Photos are attached.
Respectfully,
Chris
ChromeFindElements & ChromeGetElementData
Moderators: JRL, Dorian (MJT support)
Re: ChromeFindElements & ChromeGetElementData
Here is the other photo which did not seem to load....
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: ChromeFindElements & ChromeGetElementData
Hi,
Looks like you are querying an anchor ('a') tag?
If so there won't be a value - anchors don't have values - but would often have text. E.g. if it looks something like:
<a ...>text here</a>
But an anchor doesn't always have text - it could have an image within it instead for example. It could have some other element within it and not have any text.
There's an undocumented feature (will update docs now) that lets you specify any html attribute, so we could query the innerHTML, or even get the outerHTML:
ChromeGetElementData>session_id,elements_1,attribute/innerHTML,ElementText
Or:
ChromeGetElementData>session_id,elements_1,attribute/outerHTML,ElementText
innerHTML will get you everything that sits inside the anchor tag - it's children. outerHTML will include the html of itself. Could be useful - could then parse that to pull out what you need.
https://www.w3schools.com/jsref/prop_html_innerhtml.asp
https://www.w3schools.com/jsref/prop_html_outerhtml.asp
Looks like you are querying an anchor ('a') tag?
If so there won't be a value - anchors don't have values - but would often have text. E.g. if it looks something like:
<a ...>text here</a>
But an anchor doesn't always have text - it could have an image within it instead for example. It could have some other element within it and not have any text.
There's an undocumented feature (will update docs now) that lets you specify any html attribute, so we could query the innerHTML, or even get the outerHTML:
ChromeGetElementData>session_id,elements_1,attribute/innerHTML,ElementText
Or:
ChromeGetElementData>session_id,elements_1,attribute/outerHTML,ElementText
innerHTML will get you everything that sits inside the anchor tag - it's children. outerHTML will include the html of itself. Could be useful - could then parse that to pull out what you need.
https://www.w3schools.com/jsref/prop_html_innerhtml.asp
https://www.w3schools.com/jsref/prop_html_outerhtml.asp
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Re: ChromeFindElements & ChromeGetElementData
Thank you Marcus!
I will take a look to see if (1) I can get the data I need without reference to the <a> tag and (2) if those new features you mentioned will help me out.
Regards,
Chris
I will take a look to see if (1) I can get the data I need without reference to the <a> tag and (2) if those new features you mentioned will help me out.
Regards,
Chris
Re: ChromeFindElements & ChromeGetElementData
Dear Marcus,
Thank you! It worked!!!
I struggled with the code for another hour, because no matter what I tried, the ChromeFindElements command was not returning any values to me. But then I stumbled upon the css selector option, and I gave that a try. Sure enough, the ChromeFindElements returned a value.
And then I used this line of code.....
ChromeGetElementData>session_id,URL_Elements_1,attribute/href,URLTextInner
...and the system returned the complete URL to me... perfectly!
I went to bed after that - it was 3 AM. But I slept with a smile on my face, finally having a solution.
THANKS MARCUS!!!
Thank you! It worked!!!
I struggled with the code for another hour, because no matter what I tried, the ChromeFindElements command was not returning any values to me. But then I stumbled upon the css selector option, and I gave that a try. Sure enough, the ChromeFindElements returned a value.
And then I used this line of code.....
ChromeGetElementData>session_id,URL_Elements_1,attribute/href,URLTextInner
...and the system returned the complete URL to me... perfectly!
I went to bed after that - it was 3 AM. But I slept with a smile on my face, finally having a solution.
THANKS MARCUS!!!
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Re: ChromeFindElements & ChromeGetElementData
Magic 

Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Macro Veteran
- Posts: 260
- Joined: Fri Apr 15, 2005 8:32 am
Re: ChromeFindElements & ChromeGetElementData
Where can I see a list of what HTML attributes are supported, e.g. innerHTML, outerHTML, etc.?Marcus Tettmar wrote: ↑Tue Jun 30, 2020 3:44 pmThere's an undocumented feature (will update docs now) that lets you specify any html attribute, so we could query the innerHTML, or even get the outerHTML:https://www.w3schools.com/jsref/prop_html_innerhtml.asp
https://www.w3schools.com/jsref/prop_html_outerhtml.asp
Thanks.