ChromeGetElementData from table

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
DWEd
Newbie
Posts: 12
Joined: Fri Jul 15, 2016 2:54 pm

ChromeGetElementData from table

Post by DWEd » Wed Apr 29, 2020 1:45 pm

Hi,
I'm moving code over that used to pull data in via IE to use the new Chrome integration.

The page I want to pull data from has all the values in a table like this:

Code: Select all

<tr>
<th>Increment Id</th>
<td class="increment_id">100134934</td>
</tr>
<tr>
<th>Entity Id</th>
<td class="entity_id">141553</td>
</tr>
My old code to pull the increment id looked like this:

Code: Select all

IEGetTagsByAttrib>{%URL%},TD,classname=increment_id,T,increment_id
I've now changed this to

Code: Select all

ChromeFindElements>session_id[2],class name,increment_id,elements
ChromeGetElementData>session_id[2],elements_1,value,increment_id
The ChromeFindElements command can see the element on the page, but the GetElementData returns nothing.
I've tried "value" and "text". How can I pull this data? Is there a better way to pull table data from Chrome?

DWEd
Newbie
Posts: 12
Joined: Fri Jul 15, 2016 2:54 pm

Re: ChromeGetElementData from table

Post by DWEd » Thu Apr 30, 2020 8:51 am

I've resolved my issue.
I had a read up on xpath, which seems like a nice powerful tool that should help with eliminating some of my image recognition elements I had to use, so that's great.

To grab the data from my tables the following works fine:

Code: Select all

ChromeFindElements>session_id[2],xpath,//td[@class='increment_id'],elements
ChromeGetElementData>session_id[2],elements_1,value,increment_id

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: ChromeGetElementData from table

Post by Marcus Tettmar » Tue May 05, 2020 4:07 pm

Well done. Sorry didn't get to this sooner. XPath is very powerful.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

DWEd
Newbie
Posts: 12
Joined: Fri Jul 15, 2016 2:54 pm

Re: ChromeGetElementData from table

Post by DWEd » Thu May 07, 2020 12:45 pm

No problem, I got a bit carried away and re-wrote most of the code using xpath to replace every one of the image recognition calls I had, which has made things much faster and reliable (especially with our range of monitors and resolutions)
Very happy so far.
For reference I found this page incredibly useful:
https://devhints.io/xpath

ocnuybear
Pro Scripter
Posts: 100
Joined: Sun Jul 15, 2018 5:14 pm

Re: ChromeGetElementData from table

Post by ocnuybear » Wed Feb 02, 2022 3:03 pm

I found this very simple way of testing a live website's Xpath:

Code: Select all

https://www.browserstack.com/guide/find-element-by-xpath-in-selenium

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts