Jump to content

How to automate javascript part of Website


ThomasQ
 Share

Recommended Posts

Hi All!

I've been using autoit for my work for two years now. Unfortunately, the latest update on the site I work with, changed the whole structure of the site!

I used to be fine getting collection objects of all the form's straigt from the page's source, but now they started using javascript as the interface of the site, and I'm boned! Everything I need is generated within this one certain javascript function they call.. The whole interface is build with Vaadin: http://www.vaadin.com

So, Is it possible to use Autoit on those Links & Forms? And if so, How do I do it? Where do I start?? Are there any Diagnostical scripts so I can find my way through the forrest?? Or am I seriously ff'ed? :graduated:

Thanks in advance!!

Thomas

Edited by ThomasQ
Link to comment
Share on other sites

Hi thomas! Try this one:

#include<IE.au3>
$oIE = _IECreate("http://vaadin.com/home")
$oLis = _IETagNameGetCollection($oIE,"li")
For $oLi in $oLis
If String($oLi.id) = "nav_Download" Then
  ;found the Download LI tag in html!
  $oLink = _IETagNameGetCollection($oLi,"a",0)
  ;take the first link in the LI tag!
  _IEAction($oLink,"click")
  ;click on the download page!
  _IELoadWait($oIE)
  ;wait for IE status LOADED
  ExitLoop
EndIf
Next

Regards

Giordano

[font=courier new, courier, monospace]Una piccola riflessione: [/font] [font=courier new, courier, monospace]Se guardassi la Terra da un pianeta distante 1 anno luce, vedresti la terra 1 anno prima di quell'istante! Quindi se tu potessi arrivare a quella distanza impiegando solo 6 mesi (quindi viaggiando a 2 volte la velocita della luce) vedresti il mondo com'era 6 mesi prima della partenza.. il passato![/font]
Link to comment
Share on other sites

Hi All!

I've been using autoit for my work for two years now. Unfortunately, the latest update on the site I work with, changed the whole structure of the site!

I used to be fine getting collection objects of all the form's straigt from the page's source, but now they started using javascript as the interface of the site, and I'm boned! Everything I need is generated within this one certain javascript function they call.. The whole interface is build with Vaadin: http://www.vaadin.com

So, Is it possible to use Autoit on those Links & Forms? And if so, How do I do it? Where do I start?? Are there any Diagnostical scripts so I can find my way through the forrest?? Or am I seriously ff'ed? :graduated:

Thanks in advance!!

Thomas

Try FireBug plugin in mozilla firefox to catch the code for what you are looking for, and use IE.au3 to automatize it!

[font=courier new, courier, monospace]Una piccola riflessione: [/font] [font=courier new, courier, monospace]Se guardassi la Terra da un pianeta distante 1 anno luce, vedresti la terra 1 anno prima di quell'istante! Quindi se tu potessi arrivare a quella distanza impiegando solo 6 mesi (quindi viaggiando a 2 volte la velocita della luce) vedresti il mondo com'era 6 mesi prima della partenza.. il passato![/font]
Link to comment
Share on other sites

Hi man, thanks for the example. At least now I know it is possible, and I will read up on the _IETagNameGet function. So far I see that the main page has 262 ID's, (using _IETagNameGetCollection), and the object I need to access has about 200.. How do I Consolewrite a list of those tag's their names, valuies, etc? *EDIT* : Stupid Question, I should have just checked the Example for _IETagNameGetCollection. Never mind! :)

Between posting this thread and now I made a little progress. I haven't been able to get the InnerHTML of the Javascript object with Firebug, but I did get it by checking the object ID, wich I found in the source code:

$oDiv = _IEGetObjById ($oIE,
"p_p_id_dtghsppdataentry_WAR_dtghsppdataentryportlet_")<BR>$oDivInnerText =
_IEPropertyGet($oDiv, "innerhtml")<BR>; ConsoleWrite($oDivInnerText &amp;
@LF)<BR>

This gives me back the whole string with all the buttons and forms I need to access, for example this button:

<TD class=v-formlayout-contentcell width="100%">
<DIV class=v-button role=button tabIndex=0 __eventBits="7165" tkPid="PID44" __uiObjectID="6"><SPAN class=v-
button-wrap><SPAN class=v-button-caption>Zoeken</SPAN></SPAN></DIV></TD>

They all have tkPid's and _uiObjectID's. Any idea on how to click the "Zoeken" button for example? :graduated:

Many thanks again, since it's for my work, I very much apricatie the quickness of your awnsers! ;)

Edited by ThomasQ
Link to comment
Share on other sites

Good Thomas!

the same thing:

$oDivs = _Ietagnamegetcollection($oIE,"div")
For $oDiv in $oDivs
if string($oDiv.id) = "p_p_id_dtghsppdataentry_WAR_dtghsppdataentryportlet_" then
  consolewrite(String($oDiv.innertext))
  exitloop
endif
next

$oDiv.id = ID

$oDiv.innertext = inner text

$oDiv.innerhtml = inner html

$oDiv.classname = class

these are the most sub tag that you can use to find what you want!

[font=courier new, courier, monospace]Una piccola riflessione: [/font] [font=courier new, courier, monospace]Se guardassi la Terra da un pianeta distante 1 anno luce, vedresti la terra 1 anno prima di quell'istante! Quindi se tu potessi arrivare a quella distanza impiegando solo 6 mesi (quindi viaggiando a 2 volte la velocita della luce) vedresti il mondo com'era 6 mesi prima della partenza.. il passato![/font]
Link to comment
Share on other sites

<input type="search" results="5" placeholder="Search" autosave="vaadin.com" name="q" id="query"> (I THINK THIS IS THE ZOEKEN BUTTON U NEED)

if you need to find this one:

$oForms = _IETagNameGetCollection($oIE,"form")
For $oForm in $oForms
If String($oForm.id) = "search" Then
  $oFormObj = $oForm
  ExitLoop
EndIf
Next
;now i found the search form!
;now search for the input in this form...
$oInputs = _IETagNameGetCollection($oIE,"input")
For $oInput in $oInputs
If String($oInput.id) = "query" Then
  $oSearchInput = $oInput
  ExitLoop
EndIf
Next
;now i have the form and i have the input of the research!
_IEFormElementSetValue($oSearchInput,"hello")
Sleep(2000)
_IEFormSubmit($oFormObj)
[font=courier new, courier, monospace]Una piccola riflessione: [/font] [font=courier new, courier, monospace]Se guardassi la Terra da un pianeta distante 1 anno luce, vedresti la terra 1 anno prima di quell'istante! Quindi se tu potessi arrivare a quella distanza impiegando solo 6 mesi (quindi viaggiando a 2 volte la velocita della luce) vedresti il mondo com'era 6 mesi prima della partenza.. il passato![/font]
Link to comment
Share on other sites

Thanks!

Your scripts have been a great help! I got the whole Tag concept now, and I feel I'm getting closer!

The last script you posted, that searches for Forms, wich he doesn't find in the P_P_ID... object.

I've been searching through the tagnames for the innertext Zoeken. This gave me back 6 results, tagnamed: TR, TD, DIV & Span. When I tried to find a link to click using your lines:

$oLink = _IETagNameGetCollection($oLi,"a",0)
  ;take the first link in the LI tag!
  _IEAction($oLink,"click")
, nothing is found either. I expect that the "a" is a tagname for links?

Is it smart to search for the innertext "Zoeken"? All the classes that are returned seem to be CSS & Table tagnames, right? There's probably nothing to click there?

Should I then search for Forms, wich aren't found in the P_P_etc object. Am I lookin in the wrong object?

Many thanks again man!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...