B4J Question Automating data collecting from web pages with Ajax

iglrs1

Member
Licensed User
Longtime User
Hi,

I want to automate some tasks (data colleting) in some webpages. I'm using the webview control and I have some questions:

a) Error com.sun.webkit.network.URLLoader doRun error,
When I login on the webpage I receive in the log the current error:

Waiting for debugger to connect...
Program started.
may 14, 2020 8:35:33 AM com.sun.webkit.network.URLLoader doRun
ADVERTENCIA: Unexpected error
javax.net.ssl.SSLException: Received fatal alert: protocol_version
at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2020)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1127)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:162)
at com.sun.webkit.network.URLLoader.sendRequest(URLLoader.java:371)
at com.sun.webkit.network.URLLoader.doRun(URLLoader.java:167)
at com.sun.webkit.network.URLLoader.lambda$run$98(URLLoader.java:132)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.webkit.network.URLLoader.run(URLLoader.java:131)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)

Looking in the forum I found and added the SetSystemProperty but still same error

B4X:
SetSystemProperty("deployment.security.TLSv1", "true")
SetSystemProperty("https.protocols", "TLSv1")
MainForm = Form1
MainForm.RootPane.LoadLayout("1") 'Load the layout file.
MainForm.Show
WebView1.LoadUrl("https://www.audaxenergia.com/")

Wait For WebView1_PageFinished(Url As String)


b) In a Webpage with AJAX I need to wait until the Ajax is executed. This is done after pressing a enter in an input field (Pressing the enter is done by code ). The Wait For WebView1_PageFinished(Url As String) is not working. Could someone help me?

B4X:
Dim js As String = $"e=jQuery.Event('keyup');
                             e.which = 13;
                             e.keyCode = 13;
                             $('input[name="test"]').keypress().trigger(e);"$

joWV.RunMethodJO("getEngine", Null).RunMethod("executeScript", Array As String(js))
Wait For WebView1_PageFinished(Url As String)
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've tried it with:
B4X:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("1") 'Load the layout file.
    MainForm.Show
    WebView1.LoadUrl("https://www.audaxenergia.com/")
End Sub
The web page is loaded properly. There is an error about an invalid cookie which is probably a server problem. However the site loads.

I tested it with Java 11.
 
Upvote 0
Top