Web browser login

I can open an url using the webviewer.
But I want to login on the web page with login account and password using AI2.
How can i do this? Do i need webviewer or web component for storing the account?

Search javascript injection in this community

Taifun

The inject snippet is working fine if the login informations are provided as text blocks, but when i want to let the user enter the login and password it isnt working.
I also replaced the clock block by submit button.
grafik
grafik

You should use the when PageLoaded event to ensure everything is in place on the web page

image

There is also the runJavascript block (which came along after the guide was written)

image

2 Likes


Taifun

1 Like

@TIMAI2 How is the Js Code with this runJavascript Block?

Not tested but something like this (very similar to what Taifun has done) :

As a procedure:

Can I also extract the text from an html string with JavaScript?
Or is there an API necessary?
The HTML file is from one of my online account.

where, what, why ?

I want to read text by id from Web Page and display it at AI2 similar to this post

Well I show how to do it in that link.

window.AppInventor.setWebViewString(document.getElementById("idValue").innerHTML)

You should set the webviewstring to a blank text before running the javascript, and use the webviewstringChanged block to capture the value into the app.

You should also wait until the web page has loaded, so that any scripts running on the page have completed, and all rendered text is available.

Not tested but something like this (very similar to what Taifun has done) 

After slightly modifying your blocks the login is working fine now with Javascript:

1 Like

The Webviewer PageLoaded event is firing several times, the hmtl page is loading and loading again. How can i run the block only one time?


Do i need the WebViewer1.StopLoading block?

Is the url different after you have signed in ?

Yes, it is different, i used new url with GoToURL instead of HomeURL for sign in.

Then test for the specific "login" url in the PageLoaded event, and only run the login javascript if that url is loaded.

You mean use the HomeURL as specific login in the PageLoaded event?
grafik

Probably...

Is the WebViewStringChange the only way to copy the result from js to a variable and use it in other screen as start value?
grafik