Android Question Web View Login

alon

Active Member
Licensed User
Longtime User
Hi Everyone,

I am trying to connect to a web page login and then put the password and username,
After that to download a file from my account.

So I read all the posts on
"How to load a url, with username/password", "Enter text in web page" and some other posts.

I understand that I can do that with "WebViewExtras" Or with http request, or to send java script.
I also downloaded the Martin's samples: WebViewForm and WebViewLogin,
But I could not login to the page.

My guess is that the fields id are wrong.
Can anyone help me with that ?

The Url Is: https://services.cal-online.co.il/Card-Holders/SCREENS/AccountManagement/Login.aspx

Thanks...
B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: WebViewLogin
    #VersionCode: 1
    #VersionName:
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

'Activity module
Sub Process_Globals

End Sub

Sub Globals
    Dim WebView1 As WebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    WebView1.Initialize("WebView1")
    Activity.AddView(WebView1, 0, 0, 100%x, 100%y)
  
  
    WebView1.LoadUrl("https://services.cal-online.co.il/Card-Holders/SCREENS/AccountManagement/Login.aspx")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub WebView1_PageFinished (Url As String)
    If Url="https://services.cal-online.co.il/Card-Holders/SCREENS/AccountManagement/Login.aspx" Then
        Dim Javascript As StringBuilder
        Javascript.Initialize
        Javascript.Append("document.forms.UserName.value='my_username';")
        Javascript.Append("document.forms.password.value='my_pass';")
        Javascript.Append("document.forms.submit()")
        Log("Executing javascript: "&Javascript.ToString)
      
        Dim WebViewExtras1 As WebViewExtras
        WebViewExtras1.executeJavascript(WebView1, Javascript.ToString)
      
        '    alternatively you could execute the javascript without requiring WebViewExtras by using the javascript protocol:
        '    WebView1.LoadUrl("javascript:"&Javascript.ToString)
      
    Else
        Log("BLA BLA")
    End If
End Sub
 

alon

Active Member
Licensed User
Longtime User
The actual form is in an iframe and it belongs to a different domain. I'm not an expert in this field but I don't think that you will be able to inject JavaScript to the iframe.

is there any other way to do that?
 
Last edited:
Upvote 0
Top