HTML Viewer DOM Parser / Editor

  1. 7 weeks ago

    Aurelian N

    Dec 3 Pre-Release Testers, Xojo Pro

    Hello,

    Does anybody hav an idea on how to parse the DOM from HTML Viewer , I need to be able to hide a part of the page before displaying it to the viewer and the only way to hide is to hide a class .

    I did saw that MBS has something but unfortunately they don't have

    getElementsByClassName

    available to I'll have to look for other ways doing that.

    Any ideas would be more than helpful.

    Thanks.

  2. Aurelian N

    Dec 3 Pre-Release Testers, Xojo Pro

    Ok so apparently the

    ExecuteJavaScript

    worked in this case but apparently I have a problem with the HTMLViewer.

    The process is the following

    I load the page, I fill the form , I submit the form and once the processing complete it changes the url from https://website/submit to https://website/submitted?caseid=xxxx, but in my case I cannot get the URL change anywhere in the HTML Viewer events.

    Is there a way to be able to do that ? if I fill that form in a normal browser I can see the url changed but not in the HTML Viewer events. I tried in DocumentComplete, DocumentProgressChanged; StatusChanged but unfortunately nothing shows the correct URL.

    Thanks.

  3. Michael D

    Dec 3 Pre-Release Testers, Xojo Pro

    Look in the https://docs.xojo.com/HTMLViewer.CancelLoad or possibly https://docs.xojo.com/HTMLViewer.NewWindow events

  4. Aurelian N

    Dec 4 Pre-Release Testers, Xojo Pro

    Hello Michael, unfortunately it does not work , CancelLoad gets fired if the load was canceled so it's not my case ,and NewWindow is when you want to load new window, as well not my case .

    On my side the URL gets changed I guess by js or something and does not refresh the page at all so the Viewer does not know that URL was changed if no page refresh was requested , I assume, I'm not sure.

    Apparently there is no other way to detect that with the current module.

    thanks.

  5. Joost R

    Dec 4 Pre-Release Testers, Xojo Pro The Netherlands
    Edited 7 weeks ago

    The webhtmlviewer has a hashtagchanged event which works fine for this purpose. I am in the same boat, want to use this functionality with htmviewer control for desktop but don't know how.

  6. Tim S

    Dec 4 Pre-Release Testers Canterbury, UK

    @Aurelian N I tried in DocumentComplete, DocumentProgressChanged; StatusChanged but unfortunately nothing shows the correct URL.

    StatusChanged is unwise to use except with macOS (and that may change). TitleChange should work but is limited in the number of characters you get in the event.

  7. Aurelian N

    Dec 4 Pre-Release Testers, Xojo Pro

    @Tim S StatusChanged is unwise to use except with macOS (and that may change). TitleChange should work but is limited in the number of characters you get in the event.

    Well none of them are working , Status change works only if you press or hoover a url in the interface and it shows the URL but that defeats the purpose of automating things, as Joost said as well, there are things on Web that are not on desktop so I guess it would be nice to have same functionality everywhere at least on this side as after all it supposed to work that way .

    @XOJO side, is it possible to have this changed ? or add the functionality by subclassing it ? and how ?

    Thanks.

  8. Michael D

    Dec 4 Pre-Release Testers, Xojo Pro

    @Aurelian N Hello Michael, unfortunately it does not work , CancelLoad gets fired if the load was canceled so it's not my case ,and NewWindow is when you want to load new window, as well not my case .

    You are mistaken about https://docs.xojo.com/HTMLViewer.CancelLoad - it fires when the page requests to load a URL - the load is only canceled if you return True. It may not work in your particular case, depending on how the javascript/HTML is changing the page URL...

    Another way would be to set up a repeating Xojo timer which uses HTMLViewer ExecuteJavascript to check the javascript variables - it's likely that some variable on the page is changing that you could monitor to detect the change.

    Is this a public website? If you give us the URL we might be able to help.

  9. Tim S

    Dec 4 Pre-Release Testers Canterbury, UK

    @Aurelian N Well none of them are working , Status change works only if you press or hoover a url in the interface and it shows the URL but that defeats the purpose of automating things, as Joost said as well, there are things on Web that are not on desktop so I guess it would be nice to have same functionality everywhere at least on this side as after all it supposed to work that way .

    You'll get a statuschanged or titlechanged event if, in the HTMLviewer, your javascript changes the status or the title, as in:

    window.status = "some string"
    document.title = "some string"

    Your event handler is then called with the new status/title as parameter.

  10. Aurelian N

    Dec 4 Pre-Release Testers, Xojo Pro

    @Tim S You'll get a statuschanged or titlechanged event if, in the HTMLviewer, your javascript changes the status or the title, as in:

    window.status = "some string"
    document.title = "some string"

    Your event handler is then called with the new status/title as parameter.

    While I did get that part the problem is that the service is not changing the title and because it is an external service, I cannot control it , so I have to depend and adapt for it , and now having title changed is out of the question . Status changed in the same time is little bit fishy and not always firing properly I guess so I cannot rely on that.

  11. Aurelian N

    Dec 4 Pre-Release Testers, Xojo Pro

    @Michael D You are mistaken about https://docs.xojo.com/HTMLViewer.CancelLoad - it fires when the page requests to load a URL - the load is only canceled if you return True. It may not work in your particular case, depending on how the javascript/HTML is changing the page URL...

    Another way would be to set up a repeating Xojo timer which uses HTMLViewer ExecuteJavascript to check the javascript variables - it's likely that some variable on the page is changing that you could monitor to detect the change.

    Is this a public website? If you give us the URL we might be able to help.

    Hello Michael, well the problem is that the service is public but it requires a username and password to login and as well a certificate so unfortunately we cannot share that , I wish I could.

    The service works like following ,

    You have the login page which we managed to make it work, by inputing the username and password and logging in

    Then you have to fill the form with the requirements you need, and once this is done it generates a document with a barcode and as well changes the url with

    https://website/submitted?caseid=xxxx

    where xxxx could be one or multiple separated by "," then once we get those id's we call the api and we do the rest of the processing.

    And so far we are obliged to use it that way so we cannot skip it .

    Regarding the timer so far I have no idea how they doit and how they use it, I already asked the question and if I could have the exact script that is doing the update then maybe as you said I could add a trigger handler and update and get the id's once updated , so far waiting for update from their side, but as well looking for other solutions.

    Thanks

  12. Michael D

    Dec 7 Pre-Release Testers, Xojo Pro
    Edited 7 weeks ago

    @Aurelian N changes the url with
    https://website/submitted?caseid=xxxx

    Can you dig into the javascript to see exactly how they are doing this? For example, if they are calling

     // JavaScript
      window.location.href = "https://website/submitted?caseid=xxxx"

    then I think (but am not 100% sure) that HTMLViewer.CancelLoad will fire.

  13. Greg O

    Dec 7 Xojo Inc scout.galaxy.barn

    Seems like it’d be easier to get the company to provide you with an API for this. Otherwise the next time they change their site, all of this stuff could stop working.

  14. 6 weeks ago

    Aurelian N

    Dec 8 Pre-Release Testers, Xojo Pro

    @Michael D Can you dig into the javascript to see exactly how they are doing this? For example, if they are calling

     // JavaScript
      window.location.href = "https://website/submitted?caseid=xxxx"

    then I think (but am not 100% sure) that HTMLViewer.CancelLoad will fire.

    Thanks Michael, I'll have a look, so far waiting for their reply.

  15. Aurelian N

    Dec 8 Pre-Release Testers, Xojo Pro

    @Greg OLone Seems like it’d be easier to get the company to provide you with an API for this. Otherwise the next time they change their site, all of this stuff could stop working.

    Nope, they will not change and due to the restrictions and accreditations we are obliged to use the interface. They do have an API as well but for this part we need to stick to their interface.

    Thanks.

  16. 2 weeks ago

    Aurelian N

    Jan 9 Pre-Release Testers, Xojo Pro

    Ok so they did offered for us an option that is quite ok if we make it work, so apparently they did added an attribute that supposed to hold those id's once generated , now because the page gets loaded via Ajax so there is no page refresh what would be the best way to trigger this and get the data ?

    They have something like this :

    <div class="topBottom"> resultids="4323">

    and they did said that I could get it using

    document.querySelector('.topBottom').GetAttribute('resultids')

    Now I guess I could call a timer that will always check if there is any result for that but how do I get the result of that in the process and do the rest of the steps ?

    Thanks in advance

  17. Tim S

    Jan 9 Pre-Release Testers Canterbury, UK

    @Aurelian N Now I guess I could call a timer that will always check if there is any result for that but how do I get the result of that in the process and do the rest of the steps ?

    It's unclear to me that one can get anything back from an HTMLViewer without using the StatusChanged or TitleChanged events as I mentioned upthread.

    How about this: can you make yourself an HTML page containing an <iframe> which you put into the HTMLViewer and load their page into the <iframe>? Then your page can reach into the iFrame to get the results. Then it can use the events to get info back to the Xojo side.

or Sign Up to reply!