FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Help about TWebView class. reading something from website.
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Help about TWebView class. reading something from website.
Posted: Wed Jun 29, 2022 07:45 PM
Hi,

I have read this result in DevTools console.

Code (fw): Select all Collapse
document.getElementById("dosya_listesi_result")


Result
Code (fw): Select all Collapse
<tbody id="dosya_listesi_result">
    <tr role="row" class="odd">
        <td>Sanık</td>
        <td>Erzurum Bölge Adliye Mahkemesi 6. Ceza Dairesi</td>
        <td>2022/487</td>
        <td>Ceza Dava Dosyası</td>
        <td data-order="1654865877000" class="sorting_1">10.06.2022 15:57:57</td>
        <td>Açık</td>
        <td>
            <button class="btn btn-default btn-sm pull-left" onclick="javascript: void(0);">
                <i class="fa fa-eyes"></i> Dosya Görüntüle</button>
        </td>
    </tr>
    <tr role="row" class="even">
        <td>Sanık</td>
        <td>Erzurum Bölge Adliye Mahkemesi 6. Ceza Dairesi</td>
        <td>2022/348</td>
        <td>Ceza Dava Dosyası</td>
        <td data-order="1650025383000" class="sorting_1">15.04.2022 15:23:03</td>
        <td>Kapalı ( 16.05.2022 11:26:22 )</td>
        <td>
            <button class="btn btn-default btn-sm pull-left" onclick="javascript: void(0);">
                <i class="fa fa-eyes"></i> Dosya Görüntüle</button>
        </td>
    </tr>
    <tr role="row" class="odd">
        <td>Sanık</td>
        <td>Erzurum Bölge Adliye Mahkemesi 6. Ceza Dairesi</td>
        <td>2021/250</td>
        <td>Ceza Dava Dosyası</td>
        <td data-order="1613999200000" class="sorting_1">22.02.2021 16:06:40</td>
        <td>Kapalı ( 23.03.2021 16:31:28 )</td>
        <td>
            <button class="btn btn-default btn-sm pull-left" onclick="javascript: void(0);">
                <i class="fa fa-eyes"></i> Dosya Görüntüle</button>
        </td>
    </tr>
    <tr role="row" class="even">
        <td>Sanık</td>
        <td>Erzurum Bölge Adliye Mahkemesi 6. Ceza Dairesi</td>
        <td>2019/207</td>
        <td>Ceza Dava Dosyası</td>
        <td data-order="1548421164000" class="sorting_1">25.01.2019 15:59:24</td>
        <td>Kapalı ( 28.04.2022 08:48:50 )</td>
        <td>
            <button class="btn btn-default btn-sm pull-left" onclick="javascript: void(0);">
                <i class="fa fa-eyes"></i> Dosya Görüntüle</button>
        </td>
    </tr>
</tbody>


Code (fw): Select all Collapse
    xml := oWebView:Eval('document.getElementById("dosya_listesi_result")')


How Can I read this xml from oWebView? There is not anything in xml var.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Help about TWebView class. reading something from website.
Posted: Wed Jun 29, 2022 08:16 PM

Dear Hakan,

With Method oWebView:Eval() you can execute javascript but you can not get the return value.

To get a return value you have to use oWebView:bOnBind, so to get a returned value you should do:

oWebView:bOnBind = { | cJson, nCalls | MsgInfo( cJson, nCalls ) }
oWebView:Bind( "SendToFWH" )
oWebView:Eval( [SendToFWH( 'document.getElementById("dosya_listesi_result" )' ] )

Sometimes you have to call Sleep( nMillisecs ) to give the browse enough time to process it.

Please review FWH\samples\webviewuni.prg to review a working example :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Help about TWebView class. reading something from website.
Posted: Thu Jun 30, 2022 09:49 AM
Hi Antonio,

I have changed that you describe.

Code (fw): Select all Collapse
   PROCEDURE XBROWSER_Show(cJson, nCalls)
    XBROWSER cJson slnum TITLE "cJson - Calls:"+NTRIM(nCalls)
RETURN

    oWebView:bOnBind = { | cJson, nCalls | XBROWSER_Show( cJson, nCalls ) }
    oWebView:Bind( "SendToFWH" )
....
....

oWebView:Eval( "SendToFWH( 'I am here' )" )
      aaa := "document.getElementById('dosya_listesi_result' )"
    oWebView:Eval( "SendToFWH( "+aaa+" )" )


"I am here" message is comes. but next line just comes "[{}]"
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Help about TWebView class. reading something from website.
Posted: Thu Jun 30, 2022 03:11 PM
Dear Hakan,

Please try it this way:

oWebView:Eval( "SendToFWH( '" + aaa + "' )" )

Please notice the "red" single quote that I have added at both sides
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Help about TWebView class. reading something from website.
Posted: Thu Jun 30, 2022 04:00 PM
Antonio Linares wrote:Dear Hakan,

Please try it this way:

oWebView:Eval( "SendToFWH( '" + aaa + "' )" )

Please notice the "red" single quote that I have added at both sides


Hi Antonio,

Tried. There is not any message.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Help about TWebView class. reading something from website.
Posted: Thu Jun 30, 2022 08:11 PM

Dear Hakan,

Please right click on the webview, open the inspector and check if there is any error or warning

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Help about TWebView class. reading something from website.
Posted: Thu Jun 30, 2022 09:11 PM
Antonio Linares wrote:Dear Hakan,

Please right click on the webview, open the inspector and check if there is any error or warning


Hi Antonio,

without above code there is only 2 warning.
Code (fw): Select all Collapse
oWebView:Eval( "SendToFWH( '"+aaa+"' )" )

Code (fw): Select all Collapse
Audit usage of navigator.userAgent, navigator.appVersion, and navigator.platform
A page or script is accessing at least one of navigator.userAgent, navigator.appVersion, and navigator.platform. Starting in Chrome 101, the amount of information available in the User Agent string will be reduced.
To fix this issue, replace the usage of navigator.userAgent, navigator.appVersion, and navigator.platform with feature detection, progressive enhancement, or migrate to navigator.userAgentData.
Note that for performance reasons, only the first access to one of the properties is shown.
1 source
jquery-migrate-1.2.1.js:1

Code (fw): Select all Collapse
Deprecated Feature Used
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help, check https://xhr.spec.whatwg.org/ .
1 source
pace.min.js:188


with above code there is no more error and warnings.
Code (fw): Select all Collapse
oWebView:Eval( "SendToFWH( '"+aaa+"' )" )
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Help about TWebView class. reading something from website.
Posted: Fri Jul 01, 2022 05:30 AM

Dear Hakan,

many thanks for all your feedback about webview

We are all learning about it and its really usefull that we share our findings

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Help about TWebView class. reading something from website.
Posted: Fri Jul 01, 2022 07:52 AM
Antonio Linares wrote:Dear Hakan,

many thanks for all your feedback about webview

We are all learning about it and its really usefull that we share our findings


So, we are waiting.

Where is te WV_SENDTOFWH() function?. Is it internal?
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Help about TWebView class. reading something from website.
Posted: Fri Jul 01, 2022 07:59 AM

Dear Hakan,

Yes, it is internal, but as you have checked it works on many other cases. So it seems to me as the sent javascript is not correct.

Have you been able to inspect it (right click on webview) and see if you get any warning or errors there ?

You can trace the javascript code from such inspector. It is very powerful.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Help about TWebView class. reading something from website.
Posted: Mon Jul 04, 2022 09:03 AM
Hi Antonio,

I have insert log messages like below.
Code (fw): Select all Collapse
  oWebView:Eval( "SendToFWH( 'I am here' )" )
    
  oWebView:Eval('console.log( "Antonio, Starting here" )')  

  aaa := "document.getElementById('dosya_listesi_result' )"
  oWebView:Eval( "SendToFWH( "+aaa+" )" ) 
  oWebView:Eval('console.log( '+aaa+' )')  

  aaa := 'document.getElementById("yargiTuru").value'
  oWebView:Eval( "SendToFWH( "+aaa+" )" ) 
  oWebView:Eval('console.log( yargiTuru = '+aaa+' )')  
    
    oWebView:Eval('console.log( "Antonio, Finished" )')


The console shows


My app shows like this.


I think javascript is not wrong. there is something wrong getting array variable from twebview.

Any help?
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Help about TWebView class. reading something from website.
Posted: Mon Jul 04, 2022 02:04 PM

Dear Hakan,

From the inspector console please type this and press return:

document.getElementById('dosya_listesi_result' ); (you may try it with or without the ;

and let me know what you get in the console

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Help about TWebView class. reading something from website.
Posted: Mon Jul 04, 2022 02:42 PM
Antonio Linares wrote:Dear Hakan,

From the inspector console please type this and press return:

document.getElementById('dosya_listesi_result' ); (you may try it with or without the ;

and let me know what you get in the console


Hi Antonio,

As I said it in first thread I can read it from console with same javascript.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Help about TWebView class. reading something from website.
Posted: Mon Jul 04, 2022 02:51 PM

Please try it like this:

oWebView:Eval( 'SendToFWH( ' + aaa + ' )' )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Help about TWebView class. reading something from website.
Posted: Mon Jul 04, 2022 03:07 PM
Antonio Linares wrote:Please try it like this:

oWebView:Eval( 'SendToFWH( ' + aaa + ' )' )


Hi Antonio,

Same.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06