MuiDataGrid Vs HTML Table

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
drunkenmonkey
Pro Scripter
Posts: 90
Joined: Fri Jan 31, 2020 10:52 am

MuiDataGrid Vs HTML Table

Post by drunkenmonkey » Thu Jun 29, 2023 10:47 am

Hi!
I was able with ChromeFindElements and XPath to access the text of an HTML table. The website was updated and they migrated from an HTML table to a MuiDataGrid component and it is more difficult to access the text from the XPath. Is it possible with XPath to achieve that or could you suggest a method of achieving that. The goal is to bring the data from the grid to an Excel worsksheet. Like I say with the HTML table it was possible because in the inspect the table and the ID was specified but it is not like that with that component.
Here's a link to a capture of the inspect. Thank you for your precious help. Always appreciated and helpful! :)
https://u.pcloud.link/publink/show?code ... hKp7ycKnvk

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: MuiDataGrid Vs HTML Table

Post by Dorian (MJT support) » Thu Jun 29, 2023 11:43 am

This should be a good starting point for you.

It should get everything in a div tag where role=row. Then just loop through with ChromeGetElementData however many times el_count is.

Code: Select all

ChromeFindElements>session_id,xpath,//div[@role='row'],el
Testing this...

Code: Select all

ChromeFindElements>session_id,xpath,//div[@role='row'],el

if>el_count>0
  Let>ExtractLoop=0
  repeat>ExtractLoop
    Let>ExtractLoop=ExtractLoop+1
    ChromeGetElementData>session_id,el_%ExtractLoop%,text,TheText
    mdl>TheText
  Until>ExtractLoop=el_count
  else
  mdl>Nothing found
Endif

...on this page ..

Code: Select all

<!DOCTYPE html>
<html>
<head>
<body>
<div role="row" <p>111</p></div>
<div role="row" <p>222</p></div>
<div role="row" <p>333</p></div>
<div role="row" <p>444</p></div>
</body>
</html>  
.. messagemodal shows 111, then 222, then 333, then 444.

You could of course also try something along these lines...

Code: Select all

//ChromeFindElements>session_id,xpath,//div[@class='Mui..etcetc'],el
//ChromeFindElements>session_id,xpath,//div[@data-rowindex='0'],el
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: MuiDataGrid Vs HTML Table

Post by Dorian (MJT support) » Thu Jun 29, 2023 11:58 am

I couldn't resist playing with it some more. This would find data-rowindex 0 to 1000.

Code: Select all

ChromeFindElements>session_id,xpath,//div[@data-rowindex>='0' and @data-rowindex <='1000'],el

if>el_count>0
  Let>ExtractLoop=0
  repeat>ExtractLoop
    Let>ExtractLoop=ExtractLoop+1
    ChromeGetElementData>session_id,el_%ExtractLoop%,text,TheText
    mdl>TheText
  Until>ExtractLoop=el_count
  else
  mdl>Nothing found
Endif
Yes, we have a Custom Scripting Service. Message me or go here

drunkenmonkey
Pro Scripter
Posts: 90
Joined: Fri Jan 31, 2020 10:52 am

Re: MuiDataGrid Vs HTML Table

Post by drunkenmonkey » Thu Jun 29, 2023 12:00 pm

Thank you so much Dorian!
The first piece of code displayed the headers titles.
I will test the loop.
Thank you again! :D

drunkenmonkey
Pro Scripter
Posts: 90
Joined: Fri Jan 31, 2020 10:52 am

Re: MuiDataGrid Vs HTML Table

Post by drunkenmonkey » Thu Jun 29, 2023 2:11 pm

Hi Dorian,
I have run the last piece of code, with rowindex >= 0 and rowindex <=1000. The grid has 208 items. The item_count in the debug show only 9 instead of 208.
Thank you for your precious help.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: MuiDataGrid Vs HTML Table

Post by Dorian (MJT support) » Thu Jun 29, 2023 3:02 pm

Does the first method with the loop give an el_count of 208 or more? If so, use that.
Yes, we have a Custom Scripting Service. Message me or go here

drunkenmonkey
Pro Scripter
Posts: 90
Joined: Fri Jan 31, 2020 10:52 am

Re: MuiDataGrid Vs HTML Table

Post by drunkenmonkey » Thu Jun 29, 2023 3:33 pm

Hi Dorian,
Unfortunately not. I have 10. I know the exact count when I log in.
Thank you! :)

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: MuiDataGrid Vs HTML Table

Post by Dorian (MJT support) » Thu Jun 29, 2023 4:05 pm

Does it only show/load 10 or so at a time? If so it might be that only 10 are accessible at a time.

What happens if you try either this? Make sure to paste the class in (working with jpgs of code in support is hideous).

Code: Select all

//ChromeFindElements>session_id,xpath,//div[@class='Mui..replacethis..imv0'],el
ChromeGetElementData>session_id,el_1,text,theText
ChromeGetElementData>session_id,el_1,attribute/innerHTML,theHtml
ChromeGetElementData>session_id,el_1,attribute/outerHTML,theHtml2
[/code]

Or this. If this one works then maybe you can get them all in a loop?

Code: Select all

//ChromeFindElements>session_id,xpath,//div[@data-rowindex='75'],el
Yes, we have a Custom Scripting Service. Message me or go here

drunkenmonkey
Pro Scripter
Posts: 90
Joined: Fri Jan 31, 2020 10:52 am

Re: MuiDataGrid Vs HTML Table

Post by drunkenmonkey » Thu Jun 29, 2023 4:28 pm

Hi Dorian,
Thank you again.
The result with the Mui... string is the same, 10.
the result with rowindex = 75 is null.
I have copy the class element in txt file.
https://u.pcloud.link/publink/show?code ... Y3b7yUTBWk

Captures when expand first row from inspect
https://u.pcloud.link/publink/show?code ... 1rx8HYP4Qy
https://u.pcloud.link/publink/show?code ... f70kaExer7

Thank you so much! :)

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: MuiDataGrid Vs HTML Table

Post by Dorian (MJT support) » Thu Jun 29, 2023 5:09 pm

That text snippet contained 100 rows and I was able to extract all 100. But of course I just saved that to a local html file to test it. It's hard to fully help without access to the same page. Are you able to share the URL?

Code: Select all

//Returns 100
ChromeFindElements>session_id,xpath,//div[@role='row'],el
mdl>el_count

//Returns 100
ChromeFindElements>session_id,xpath,//div[@data-rowindex>='0' and @data-rowindex <='1000'],el
mdl>el_count

//el_count is 1, extracts 100 listings in text
ChromeFindElements>session_id,xpath,//div[@class='MuiDataGrid-virtualScrollerRenderZone css-1inm7gi e1de0imv0'],el
ChromeGetElementData>session_id,el_1,text,TheText
mdl>TheText
Yes, we have a Custom Scripting Service. Message me or go here

drunkenmonkey
Pro Scripter
Posts: 90
Joined: Fri Jan 31, 2020 10:52 am

Re: MuiDataGrid Vs HTML Table

Post by drunkenmonkey » Thu Jun 29, 2023 6:37 pm

Hi Dorian,
Thank you for help.
On my side the output still show a limited amount of rows, not even 10.
https://u.pcloud.link/publink/show?code ... dLAVVJMtbk
Access to the website is secured. It would be a breach of contract with On24 if I was sharing my credentials. I'm sorry about that. :cry:

drunkenmonkey
Pro Scripter
Posts: 90
Joined: Fri Jan 31, 2020 10:52 am

Re: MuiDataGrid Vs HTML Table

Post by drunkenmonkey » Fri Jun 30, 2023 9:45 am

Hi Dorian,
thank you again for your support.
The reason it shows 100 records must be because of the default "Rows per Page" set option to 100.
https://u.pcloud.link/publink/show?code ... fOJQR7ryB7. :)
I was not yet able to show more than 10 rows. Wonder why you achieve the 100 rows.

drunkenmonkey
Pro Scripter
Posts: 90
Joined: Fri Jan 31, 2020 10:52 am

Re: MuiDataGrid Vs HTML Table

Post by drunkenmonkey » Fri Jun 30, 2023 11:04 am

Hi Dorian!
Found out that the screen could be what is the reason I could not retrieve more records.
By reducing chrome display to min (25%) on the laptop 50 records was retrieved.
By reducing chrome display to min (25%) on screen 2 (larger screen) 57 records was retrieved.

By changing the screen display to normal I get to monitor 2 I almost have the 100.

On your side you retrieved all 100 records. What do you make from these findings?

Thank you again for your help! :)

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1389
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: MuiDataGrid Vs HTML Table

Post by Dorian (MJT support) » Fri Jun 30, 2023 11:44 am

I've seen this behaviour before. I think because it only loads what can fit in to the panel. Maybe a workaround would be to zoom out, set less results on each page knowing that you can get them all, and then go to the next page.

I'm a little out of my depth on this particular aspect. If there is another way around it then it's outside my level of knowledge. I have asked Marcus to take a look at it and see if he has any suggestions.

Part of the challenge is that if he (or anyone else) cannot access the site, there's very little digging we can do. Working from screenshots in a scenario like this just isn't viable.

Let us know how you get on with that workaround.
Yes, we have a Custom Scripting Service. Message me or go here

drunkenmonkey
Pro Scripter
Posts: 90
Joined: Fri Jan 31, 2020 10:52 am

Re: MuiDataGrid Vs HTML Table

Post by drunkenmonkey » Mon Jul 03, 2023 9:15 pm

Hi Dorian, thank you again for your great support.
By googling I have found web sources related to dynamic web table and automation with Selenium. Looks promising when you have knowledge with the tool, java, eclipse. I use what MS offer and did it.
I agree with your last statement, without accessing the website you can give support to a certain point. After that user has to do his part.
Thank you again! Keep the good work! :D

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