Sign in to follow this  
Followers 0
Davion

Catch, fill and send site login-form maked on JavaScript

15 posts in this topic

Hello.
Sorry for my bad English, but I can't find help on my language forums.

I try to login on web site (fill and send form), but I can't get a source code from this web page.

Please, could you help me with this issue.
 

This is the source code of web page, but in browser I can see 2 input fields (login, password) and "SignIn" button, that generate on JavaScript:

<!doctype html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>
       <link type="text/css" rel="stylesheet" href="tm.css">
<link rel="icon" href="images/favicon.ico">
        <title>Program Tool</title>
    
    <script type="text/javascript" language="javascript" src="tm/tm.nocache.js"></script>
  </head>
  <body>
    <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
    <noscript>
      <div style="width: 22em; position: absolute; left: 50%; ; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
        Your web browser must have JavaScript enabled
        in order for this application to display correctly.
      </div>
    </noscript>

  <div id= "loginContainer"> </div> 
    
  </body>
</html>
 

This method doesn't help me (login to gmail), it return empty value:

#include <IE.au3>

$login = InputBox("Enter User Name", "Enter user name:", "", "", "200", "130")
$pass = InputBox("Enter Password", "Enter password:", "", "", "200", "130")


$oIE = ObjCreate("InternetExplorer.Application.1")
With $oIE
    .Visible = 1
    .Height = 768
    .Width = 1024
    .Navigate("https://accounts.google.com/ServiceLogin?sacu=1&scc=1&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&hl=ru&service=mail")
EndWith
_IELoadWait ($oIE)

$oForm = _IEGetObjById($oIE, "gaia_loginform")
$iLogin = _IEFormElementGetObjByName($oForm, "Email")
_IEFormElementSetValue($iLogin, $login)
$iPass = _IEFormElementGetObjByName($oForm, "Passwd")
_IEFormElementSetValue($iPass, $pass)
$oTik_galochka = _IEGetObjByName($oIE, "PersistentCookie")
_IEAction($oTik_galochka, "click") 
_IEFormSubmit($oForm)

 

Function "_IEBodyReadHTML()" and the code below

#include <IE.au3>

$oIE = _IECreate('site URL')
$oHead = _IETagNameGetCollection($oIE, 'head', 0)

ConsoleWrite(_IEPropertyGet($oHead, 'innerhtml') & @LF) 
show result, that represented in first spoiler.

 

Thank you for any help.

Share this post


Link to post
Share on other sites



Download and use: DebugBar


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Thank you for answer.
Please, could you explain in what way this tool can help with program on AutoIt?

Is work AutoIt script on PC where this tool isn't installed?(It important beacause I havn't permitions to install any soft on all PC where this script need work.)
I have read description to it and understood, that it something like "FireBug" in FireFox or "Chrome Developer Tool". I think these tools don't help browser to do something, they need just to see web information. With "Chrome Developer Tool" I can detecte names and ID's of needed elements, but when I press "ctrl+U" Chrome can't show me generate in JS source code.

In what way DebugBar can help with my problem if I need IE identify (catch) element names and ID's?

But it may be, Are you know another way to solve my problem (without using sours code)?

Share this post


Link to post
Share on other sites

Install it on the PC you're programming on.  Use it to find the objects you want to deal with.  Their ID/Name/Class so that you can interact with them.

I'm not going to look at the site or code an example without you attempting to use tools to help yourself first.  This proves you understand the IE* functions with AutoIt and how to use the Debugbar tool to get the data you need to use the IE* functions.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Sure, but not as easy to use as debugbar.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Does IE not come with a dev tool now same as chrome and firefox?

 

Just press F12 in IE :thumbsup:


My UDFs, Abbrevs and Snippets
If you like my post, just click the like button :) 

Share this post


Link to post
Share on other sites

Last time I used debugbar it was trial and pay.

If you want all the goodies, but for basic uses, it's fine.

Not sure when it went to that pay part, didn't use to be that way, but I just use it for basic stepping through.

Then again, I have no issues paying for something that works.  Devs deserve to get paid for their product if it's helping me with mine IMHO.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

I totally agree with that, I pay for my OS and Visual Studio.

Saying that, I only bought visual studio cause I never knew there were free IDE's that people say are just as good, at the time.

I think the de2vs of debugbar need to make it something really special now that MS are integrating a tool, but who knows, they might hae bought it of them.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Dear SmOke_N, sorry for my bad English, thats why I has problem to explain the heart of my problem. And you wrongly understood it.
I got ID's and names of needed elements with Developer Tool. Than I had put them to functions "_IEGetElemetnbyID" and "_IEGetElemetnbyName", but they return empty values, because in HTML source code there are no this elements, they are stored in JavaScript functions (DOM).
And I can't get them from DOM and ask you to help me with this actions. 
But general question is how to fill and send form on JS. May be You as an expert can determine better way without trying to access DOM?
Edited by Davion

Share this post


Link to post
Share on other sites

What version of AutoIt are you using?  If it's IE11, and you have the dec 18 update, find the hotfix for it because it rendered your IE unable to use automation (not all but ones that matter).

What returns an empty value?

The source returned has a frame in it, did you check that?

Anyway, before I suffer more from the language barrier, try this for logging in change the $bCheckTheBox variable to True if you want the persisitant checkbox checked.

#include <IE.au3>

$login = InputBox("Enter User Name", "Enter user name:", "", "", "200", "130")
$pass = InputBox("Enter Password", "Enter password:", "", "", "200", "130")


$oIE = ObjCreate("InternetExplorer.Application.1")
With $oIE
    .Visible = 1
    .Height = 768
    .Width = 1024
    .Navigate("https://accounts.google.com/ServiceLogin?sacu=1&scc=1&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&hl=ru&service=mail")
EndWith
_IELoadWait ($oIE)

$oForm = _IEGetObjById($oIE, "gaia_loginform")
$iLogin = _IEFormElementGetObjByName($oForm, "Email")
_IEFormElementSetValue($iLogin, $login)
$iPass = _IEFormElementGetObjByName($oForm, "Passwd")
_IEFormElementSetValue($iPass, $pass)
$oTik_galochka = _IEGetObjByName($oIE, "PersistentCookie")
; $oTik_galochka is a checkbox
Global $gbCheckTheBox = False
If $gbCheckTheBox Then
    If $oTik_galochka.checked Then
        $oTik_galochka.checked = False
        $oTik_galochka.fireEvent("onchange")
        $oTik_galochka.fireEvent("onclick")
    EndIf
Else
    If Not $oTik_galochka.checked Then
        $oTik_galochka.checked = True
        $oTik_galochka.fireEvent("onchange")
        $oTik_galochka.fireEvent("onclick")
    EndIf
EndIf
_IEFormSubmit($oForm)

I still have no idea what you're looking to do unfortunately, that's just a wild stab at it.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Thank you for answer.
AutoIt version is v3.3.12.0
IE version is 9.0.8112.16.4212
 
What returns an empty value? -> These functions can't get any element: 
_IEGetObjById, _IEFormElementGetObjByName, _IEFormElementGetObjById, _IEAction (I think because in HTML are not stored they. Elements are in JavaScript DOM)
 
The source returned has a frame in it, did you check that? -> Yes, there is an one iframe:
<iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
 
I try to explain by another way.
My general goal - get file from site in local network (thats why I can't show you URL). I think, that I need to do next steps: 1) Login on site. 2) To fill special field (make some params for my file). 3) Get link to file and download it.
But I faced with the next problem - all site maked on JavaScript and the usual way haven't gave any result (I tried to login with gmail login-form, tried to use functions "_IEGet..." and "InetGet" - still no result)
Now I don't know, which function can to get or to send login form. Or what step I need to do to solve this problem.
 
Funcion "InetGet" does not help me, because every time web site to access on the server (I think the site create SQL-request on JS and send to the server), it generate a new file with unic name and send link back to browser.

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

Yep, still no idea what you're asking.

This works fine for me with the same IE version:

; Objects don't have a visible value
; So we check them with "IsObj"

#include <IE.au3>

Global $gbCheckTheBox = True ; true = make sure it's checked / false = make sure it's unchecked

$login = InputBox("Enter User Name", "Enter user name:", "", "", "200", "130")
$pass = InputBox("Enter Password", "Enter password:", "", "", "200", "130")


$oIE = ObjCreate("InternetExplorer.Application.1")
If Not IsObj($oIE) Then
    MsgBox(16 + 262144, "Error", "Could not find browser object.")
    Exit 1
EndIf
With $oIE
    .Visible = 1
    .Height = 768
    .Width = 1024
    .Navigate("https://accounts.google.com/ServiceLogin?sacu=1&scc=1&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&hl=ru&service=mail")
EndWith
_IELoadWait ($oIE)

$oForm = _IEGetObjById($oIE, "gaia_loginform")
If Not IsObj($oForm) Then
    MsgBox(16 + 262144, "Error", "Could not find form object.")
    Exit 2
EndIf

$oLogin = _IEFormElementGetObjByName($oForm, "Email")
If Not IsObj($oLogin) Then
    MsgBox(16 + 262144, "Error", "Could not find email object.")
    Exit 3
EndIf
_IEFormElementSetValue($oLogin, $login)

$oPass = _IEFormElementGetObjByName($oForm, "Passwd")
If Not IsObj($oPass) Then
    MsgBox(16 + 262144, "Error", "Could not find password object.")
    Exit 4
EndIf
_IEFormElementSetValue($oPass, $pass)

$oTik_galochka = _IEGetObjByName($oForm, "PersistentCookie")
If Not IsObj($oTik_galochka) Then
    MsgBox(16 + 262144, "Error", "Could not find persisitent cookie object.")
    Exit 5
EndIf

If Not $gbCheckTheBox Then
    If $oTik_galochka.checked Then
        $oTik_galochka.checked = False
        $oTik_galochka.fireEvent("onchange")
        $oTik_galochka.fireEvent("onclick")
    EndIf
Else
    If Not $oTik_galochka.checked Then
        $oTik_galochka.checked = True
        $oTik_galochka.fireEvent("onchange")
        $oTik_galochka.fireEvent("onclick")
    EndIf
EndIf

_IEFormSubmit($oForm)

_IELoadWait($oIE) ; wait for new page to load

; find your download link
; <code here>

Provide a URL to your issue, because I am of the thought that this is just a practice page for us.

A practice page that doesn't show the issue, and you unable to provide clear and precise information on the issue, does nothing but waste time.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0