Help about TWebView class. reading something from website.

Help about TWebView class. reading something from website.

Postby Horizon » Wed Jun 29, 2022 7:45 pm

Hi,

I have read this result in DevTools console.

Code: Select all  Expand view
document.getElementById("dosya_listesi_result")


Result
Code: Select all  Expand view
<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&#058; 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&#058; 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&#058; 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&#058; void(0);">
                <i class="fa fa-eyes"></i> Dosya Görüntüle</button>
        </td>
    </tr>
</tbody>


Code: Select all  Expand view
    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.04
Horizon
 
Posts: 1288
Joined: Fri May 23, 2008 1:33 pm

Re: Help about TWebView class. reading something from website.

Postby Antonio Linares » Wed Jun 29, 2022 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Help about TWebView class. reading something from website.

Postby Horizon » Thu Jun 30, 2022 9:49 am

Hi Antonio,

I have changed that you describe.

Code: Select all  Expand view
  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.04
Horizon
 
Posts: 1288
Joined: Fri May 23, 2008 1:33 pm

Re: Help about TWebView class. reading something from website.

Postby Antonio Linares » Thu Jun 30, 2022 3: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Help about TWebView class. reading something from website.

Postby Horizon » Thu Jun 30, 2022 4: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.04
Horizon
 
Posts: 1288
Joined: Fri May 23, 2008 1:33 pm

Re: Help about TWebView class. reading something from website.

Postby Antonio Linares » Thu Jun 30, 2022 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Help about TWebView class. reading something from website.

Postby Horizon » Thu Jun 30, 2022 9: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: Select all  Expand view
oWebView:Eval( "SendToFWH( '"+aaa+"' )" )   

Code: Select all  Expand view
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: Select all  Expand view
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: Select all  Expand view
oWebView:Eval( "SendToFWH( '"+aaa+"' )" )   
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1288
Joined: Fri May 23, 2008 1:33 pm

Re: Help about TWebView class. reading something from website.

Postby Antonio Linares » Fri Jul 01, 2022 5: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Help about TWebView class. reading something from website.

Postby Horizon » Fri Jul 01, 2022 7: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.04
Horizon
 
Posts: 1288
Joined: Fri May 23, 2008 1:33 pm

Re: Help about TWebView class. reading something from website.

Postby Antonio Linares » Fri Jul 01, 2022 7: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Help about TWebView class. reading something from website.

Postby Horizon » Mon Jul 04, 2022 9:03 am

Hi Antonio,

I have insert log messages like below.
Code: Select all  Expand view
 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
Image

My app shows like this.
Image

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.04
Horizon
 
Posts: 1288
Joined: Fri May 23, 2008 1:33 pm

Re: Help about TWebView class. reading something from website.

Postby Antonio Linares » Mon Jul 04, 2022 2: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Help about TWebView class. reading something from website.

Postby Horizon » Mon Jul 04, 2022 2: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.
Image
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1288
Joined: Fri May 23, 2008 1:33 pm

Re: Help about TWebView class. reading something from website.

Postby Antonio Linares » Mon Jul 04, 2022 2:51 pm

Please try it like this:

oWebView:Eval( 'SendToFWH( ' + aaa + ' )' )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Help about TWebView class. reading something from website.

Postby Horizon » Mon Jul 04, 2022 3:07 pm

Antonio Linares wrote:Please try it like this:

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


Hi Antonio,

Same.
Image
Regards,

Hakan ONEMLI

Harbour & MSVC 2022 & FWH 23.04
Horizon
 
Posts: 1288
Joined: Fri May 23, 2008 1:33 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 89 guests