Why so complex?

67 views
Skip to first unread message

Ed. M.

unread,
May 28, 2020, 9:53:49 AM5/28/20
to CefSharp
Hi,
I'm new to CefSharp, but not browser automation.  I've written scripts using Selenium for years.  In Selenium I can write statements that do:
1.  Load a page.
2.  Wait for an element on the page to become visible, clickable, etc.
3.  Locate page elements via Id, Class, or XPath.
These are all very straightforward in Selenium.  The only problem I have with Selenium is speed, which is why I'm looking at a CefSharp Offscreen bot.

The problem I'm having is nothing is straightforward.  For example, I need to:
1.  Open a page.
2.  Click on a calendar popup.
3.  Click on a date.
4.  Click on a button.  At this point, the web page takes several seconds to load and display a table of items via a web request.
5.  Step through the rows in the table to identify a specific item and then click on it.

Writing this has been a nightmare in CefSharp.  For example, when I click the button, how can I determine when the web request has completed and the table is fully populated?  I'm trying to do this:

                    (function(){
                        var checkExist = setInterval(function() {
                            var numRows = document.querySelectorAll('tr[role=""row""]').length;
                            if (numRows > 60) {
                                clearInterval(checkExist);
                            }
                        }, 50); // check every 10ms
                    })()";

but I suspect this isn't the best approach.  Also, if I want to return the list of rows, or the table, to my C# program, I can't find a way to do that as you can't return anything from inside the setInterval function.

Thanks for your time.

Reply all
Reply to author
Forward
0 new messages