B4J Question Javascript Engine returns error in "Build Standalone Package"

Edgardo PuntoCom

Member
Licensed User
Longtime User
This code is for autologing in web site
B4X:
Sub recarga_Tick
    Try
    we1.InitializeNewInstance("javafx.scene.web.WebEngine",Null)
    doc1.InitializeStatic("org.w3c.dom.Document")
    temp1 = wv1
    we1 = temp1.RunMethod("getEngine",Null)
    we1.RunMethod("load",Array As Object(startPage1))
    recarga.Enabled = False
    Catch
        Log(LastException)
    End Try
End Sub

Sub wv1_PageFinished (Url As String)
    Try
        js1.enginePut("doc",we1.RunMethod("getDocument",Null))''Returns error in "Build Standalone Package"
        js1.evalString("var t = doc.body.innerHTML;")
        js1.evalString("doc.getElementById('LoginPh').value = 'user';")
        js1.evalString("doc.getElementById('PasswordPh').value = 'password';")
        js1.evalString("doc.getElementById('btnlogin').click();")
        js1.evalString("doc.getElementById('CORRUGATORLINEUPDRYEND').click();")
        js1.evalString("var tt = doc.getElementsByTagName('frame')[0].contentWindow.getElementsByTagName('frame')[0].contentWindow;")


        'get font code of web site
        codigo = js1.engineGet("t")


but, the line
B4X:
 js1.enginePut("doc",we1.RunMethod("getDocument",Null))''Returns error in "Build Standalone Package"


Return this error:



when I run the jar file it works perfectly, but the exe returns that error
 

Edgardo PuntoCom

Member
Licensed User
Longtime User
That too I have added


I'm afraid that there isn't enough information in the error message to say anything.

As a general rule, the less you use WebView the better. Why don't you make the log-in with OkHttpUtils2?
I have never done it with OkHttpUtils2. But I can try.

Is there an example of how to do it and get the source code of the website?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Is there an example of how to do it and get the source code of the website?
B4X:
Dim j As HttpJob
j.Initialize("", Me)
j.Download("https://www.google.com")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
   Log(j.GetString)
End If
j.Release
 
Upvote 0

Edgardo PuntoCom

Member
Licensed User
Longtime User
I use the WebView because I need to navigate the website and take the code in several screens, with WebView it is easier for me since I don't know how to use okhttputils2.

I think I will fix it better using Visual Studio
 
Upvote 0

bdunkleysmith

Active Member
Licensed User
Longtime User
There is no doubt in my mind that a solution is possible using B4J, but if you prefer to use Visual Studio I'm sure all here will wish you success.

But if you want to find a solution with B4, I feel you need to explain "what you are trying to do" as per the comment of @Erel above. My experience with B4J has been that the community here will always assist to find a solution with the best assistance coming when one explains the objective clearly. Just providing a small piece of code which doesn't achieve the desired outcome is generally not sufficient.

The community here helped me with a similar problem when I was trying to "screen scrape" some website data, but that required me to explain my objective and indicate the URL of the website concerned.

So perhaps you could describe what the code needs to do and the target URL, and let's see if we can help.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…