wbOmniWV2 - Embedded Browser

Started by JTaylor, January 13, 2025, 08:06:56 AM

Previous topic - Next topic

JTaylor

I have created a way to embed WebView2 into a Dialog.  Hopefully Tony won't tell me this was already doable via the COM Control :)   Once I do a little more with this with my production stuff and give time for feedback, assuming anyone is interested in giving it a try, I will fold into the main wbOmnibus package.

In any event, it also has DOM access to the browser.  My goal was to have a replacement for Internet Explorer as I used that a lot, and I am reasonably pleased with the results.  The "Test DOM" button only works on the Amazon page to which it browses or, I guess, some other book page on Amazon.

    http://www.jtdata.com/anonymous/wv2_demo.zip

Please read the Help.  It is under the "WebView" section.   There are some quirks.  I included the executable for the demo script due to one of the quirks but, of course, it is always wise to compile your own.

Also, it might be a little slow the first time your run it as WebView2 creates some support structures.

Jim

spl

Jim graciously allowed me to test privately. It is worth the look.
Stan - formerly stanl [ex-Pundit]

JTaylor

I also intended to mention that I am not sure how forgiving the DOM access is regarding poorly formed HTML.  If you have problems you might check that possibility first.


Thanks Stan.  It is a lot prettier now :-)

Jim

td

Interesting. WebView2 is already on our to-do list. But since the list is long it hasn't been gotten to yet.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

JTaylor

If you know how I could initialize WebView2 without having to compile a script, that would GREATLY appreciated.  Development/Testing is very annoying.

Jim

Quote from: td on January 13, 2025, 09:28:06 AMInteresting. WebView2 is already on our to-do list. But since the list is long it hasn't been gotten to yet.

JTaylor

Also, if someone downloaded this earlier and you seem to be missing a file, I posted an update to correct that problem.

Sorry.

Jim

spl

Quote from: JTaylor on January 13, 2025, 01:55:42 PMIf you know how I could initialize WebView2 without having to compile a script, that would GREATLY appreciated.  Development/Testing is very annoying.


Jim, I'll take a discussion of this with you offline to avoid crowding this thread with tangents.
Stan - formerly stanl [ex-Pundit]

JTaylor

I posted an update.  Added a few more Functions for DOM features.

    http://www.jtdata.com/anonymous/wv2_demo.zip


Jim

spl

Attached is a simple test, based on Jim's sample .wbt in the download. I simply copied to a diferent name in the same folder, added a test URL [great for testing web scraping] and modified the code associated with the DOM button at the top of the Window.
  • Must be compiled, 32 bit (I tried 64 bit with dll load error)
  • Might take a bit load and if you use Avast it will be flagged for suspicion
  • Assumes an understanding of Dom elements, and I'm a little rusty

But will return a list of Product Names, for current page in about a second. My plan is to collect the:
Product Name
Price
URL
Image

for all products and perhaps for first 10 pages as site is built for pagination. As Jim pointed out it is a little annoying to have to re-compile before testing any code changes/additions.

Hope this might be tested/extended as Jim put a lot of work into the Extender.
Stan - formerly stanl [ex-Pundit]

JTaylor

Thanks Stan.   Also, I did post another update last night.  It moves the WebView2 support files to the User's Local AppData folder under the wvWebView2 folder.


http://www.jtdata.com/anonymous/wv2_demo.zip

http://www.jtdata.com/anonymous/wv2_demo_no_edge.zip   -  Excludes WebView2 files for those who have downloaded full zip already.  Drops size by about 260 mb.

May have added some more functions.  Can't remember what I posted previous to this one.

Jim

JTaylor

Again, if anyone has a solution for avoiding having to compile, I would LOVE to hear it.

jim

JTaylor

Posted another update. 

Added option to limit wvGetElementsByClass() by tagname.
Added option to retrieve items by name attribute wvGetElementsByName().
Added wvRefreshDOM() for times one might alter web page using wvExecuteScript()

http://www.jtdata.com/anonymous/wv2_demo.zip

http://www.jtdata.com/anonymous/wv2_demo_no_edge.zip   -  Excludes WebView2 files for those who have downloaded full zip already.  Drops size by about 260 mb.

JTaylor


Posted another update.  This has a breaking change.  Sorry but I think it was a good one.

Added wvGetClasses() to retrieve list of class attributes by element.

Removed wvGetElementsByName() and wvGetElementsById() and replaced with wvGetElementsByAttribute()  -- Realized I could do this and make any Attribute accessible in this fashion rather than just those two.

http://www.jtdata.com/anonymous/wv2_demo.zip

http://www.jtdata.com/anonymous/wv2_demo_no_edge.zip   -  Excludes WebView2 files for those who have downloaded full zip already.  Drops size by about 260 mb.