Jump to content

[Solved] Web Based Automation


Recommended Posts

Howdy,

I am on a quest to improve my web-based automation skills but for this website i am running into some difficulty.

Hopefully someone might know the best direction to point me in.

The Dom Inspector returns this;

Here is the code i have tried;

#NoTrayIcon
#include <IE.au3>

$oIE = _IECreate("https://office.local/cuadmin/home.do") ;Create IE Object and waits to load
sleep(1250) ;Extra wait just to make sure.

_IEAction(_IEGetObjById($oIE, "cutree_2"), "click") ;Cant find object
$IE.document.parentwindow.execScript("javascript:cuesInvokeDrawerURL('cutree','/cuadmin/ccm-import.do?op=newImport','parent.content','cutree_2');")

Local $oElements = _IETagNameAllGetCollection($oIE)
For $oElement In $oElements
   ConsoleWrite("Tagname: " & $oElement.tagname & @CRLF & "id: " & $oElement.id & @CRLF & "innerText: " & $oElement.innerText & @crlf & @CRLF)
Next

The Click Returns;

;--> IE.au3 T3.0-2 Warning from function _IEGetObjById, $_IESTATUS_NoMatch (cutree_2)
;--> IE.au3 T3.0-2 Error from function _IEAction(click), $_IESTATUS_InvalidDataType

Execscript returns;

Variable used without being declared.:
$IE.document.parentwindow.execScript("javascript:cuesInvokeDrawerURL('cutree','/cuadmin/ccm-import.do?op=newImport','parent.content','cutree_2');")
^ ERROR

IETagNameAllGetCollection returns;

Tagname: HTML
id: 
innerText: Cisco Unity Connection Administration

Tagname: HEAD
id: 
innerText: Cisco Unity Connection Administration

Tagname: TITLE
id: 
innerText: Cisco Unity Connection Administration

Tagname: LINK
id: 
innerText: 

Tagname: FRAMESET
id: 
innerText: 

Tagname: FRAMESET
id: 
innerText: 

Tagname: FRAME
id: 
innerText: 

Tagname: FRAMESET
id: bottomPane
innerText: 

Tagname: FRAME
id: tree
innerText: 

Tagname: FRAME
id: 
innerText:

So I am at a loss of where we go?

 

Edited by IanN1990
Link to comment
Share on other sites

Hi Danp2, 

 

You are quite correct about my typo, though it returns the same error message :)

So following your advice and taking the code from the help file (edited a little) i get this.

#NoTrayIcon
#include <IE.au3>

$oIE = _IECreate("https://office.local/cuadmin/home.do") ;Create IE Object and waits to load
sleep(1250) ;Extra wait just to make sure.

Local $oFrames = _IEFrameGetCollection($oIE)
Local $iNumFrames = @extended
Local $sTxt = $iNumFrames & " frames found" & @CRLF & @CRLF
Local $oFrame = 0
For $i = 0 To ($iNumFrames - 1)
    $oFrame = _IEFrameGetCollection($oIE, $i)
    $sTxt &= _IEPropertyGet($oFrame, "innertext") & @CRLF
Next
ConsoleWrite($sTxt)

I find on $I = 1 it returns this

Cisco Unity ConnectionUsers

Users
Import Users
Synch Users

Class of Service

Class of Service
Class of Service Membership

Templates

User Templates
Call Handler Templates
Contact Templates
Notification Templates 

Notification Templates
Custom Variables
Custom Graphics
Administrative Replaceable Image

Contacts

Contacts

Distribution Lists

System Distribution Lists

Call Management

System Call Handlers
Directory Handlers
Interview Handlers
Custom Recordings
Call Routing

Direct Routing Rules
Forwarded Routing Rules

Message Storage

Mailbox Stores
Mailbox Stores Membership
Mailbox Quotas

Mailbox Quotas
Quota Alert Text

Message Aging

Aging Policies
Aging Alert Text
Message Expiration

Networking

Legacy Links

Intrasite Links
Intersite Links

Branch Management

Branches
Branch Synch Results

HTTP(S) Links
Locations
VPIM
Connection Location Passwords

Unified Messaging

Unified Messaging Services
Unified Messaging Accounts Status
SpeechView Transcription

Services
Error Codes

Video

Video Services
Video Services Accounts Status

Dial Plan

Partitions
Search Spaces

System Settings

General Configuration
Cluster
Authentication Rules
Roles
Restriction Tables
Licenses
Schedules
Holiday Schedules
Global Nicknames
Subject Line Formats
Attachment Descriptions
Enterprise Parameters
Service Parameters
Plugins
Fax Server
LDAP

LDAP Setup
LDAP Directory Configuration
LDAP Authentication
Phone Number Conversion
LDAP Custom Filter

SAML Single Sign on
Cross-Origin Resource Sharing (CORS)
SMTP Configuration

Server
Smart Host

Advanced

SMPP Providers
Conversations
Messaging
Intrasite Networking
Telephony
Reports
Connection Administration
TRAP
Disk Capacity
PCA
RSS
Cluster Configuration
Fax
Unified Messaging Services
API Settings

Telephony Integrations

Phone System
Port Group
Port
Speech Connect Port
Trunk
Security

Root Certificate
SIP Certificate
SIP Security Profile

Tools

Task Management
Bulk Administration Tool
Custom Keypad Mapping
Migration Utilities

Migrate Users
Migrate Messages

Grammar Statistics
SMTP Address Search
Show Dependencies

Which is perfect because it can see "import users" but i am struggling to see how i would select a single frame out of that collection.

I tried  _IEFrameGetObjByName(_IEFrameGetCollection($oIE, 1), "Inport Users") but got "No Frames Found"

Link to comment
Share on other sites

Quote

I tried  _IEFrameGetObjByName(_IEFrameGetCollection($oIE, 1), "Inport Users") but got "No Frames Found"

You are using the commands incorrectly (you wouldn't use both of those together like that). Also, I would suggest that you not combine commands in this fashion. Instead, try this:

$oFrame = _IEFrameGetCollection($oIE, 1)

_IELinkClickByText($oFrame, "Import Users")

 

Link to comment
Share on other sites

@aa2zz6 
I have written almost 1,000 lines of code automating cisco for inputting and deleting user accounts. The finial step is setting up voicemails, because i ran into issues i have used control sends (which is proving very unreliable)

@Danp2
Using your code i am now able to click all the left-hand menu items i need and using the same idea automate the rest of the webpage :) thank you

 

 

Link to comment
Share on other sites

So I automated the webpage using IE (using advice above) but it is terribly slow, i suspect this is how to how the company plugins work. (What takes 10 seconds in Firefox, takes a minutes in IE)

I used what i learnt to port it across to Firefox. I know my understanding is correct because

#include "FF V0.6.0.1b-15.au3"

_FFConnect()
_FFFrameEnter(2, "index")
__FFSetValue("4995", "searchString", "name")

Works, and sets the inputbox "searchstring" to 4995 but i am unable to click the "import users" to bring this inputbox up. In IE

#include "ie.au3"

$oFrame = _IEFrameGetCollection($oIE, 1) ;Finds frame with my info in it
_IELinkClickByText($oFrame, "Import Users") ;Searchs for Link by name, within that frameset

Works. The firefox port would be;

#include "FF V0.6.0.1b-15.au3"

_FFConnect()
_FFFrameEnter(1)
_FFLinkClick("Import Users", "Text")

but it returns 0, FF cant find it. I looked into how the FFLinkClick code works compared to IE.

FFLinkClick seams to perform a normal _FFClick. Click seams to work by using

.getElementByID,.getElementByName, .getElementByClassName, .getElementTagName or using XPath-Query to return the element (XPaths really confuse me)

This all seams very similar to the 

On 12/3/2016 at 3:48 AM, aa2zz6 said:

Optional ways ;-)

document.getElementById("")

document.getElementsByTagName("")

In terms of my code attempts, here is what i have tired;

#include "FF V0.6.0.1b-15.au3"

_FFConnect()
_FFFrameEnter(1)

_FFClick("Import Users", "id")
_FFClick("Import Users", "name")
_FFClick("Import Users", "class")
_FFClick("Import Users", "tag")
_FFClick("cutree_2", "id")

_FFLinkClick("javascript:cuesInvokeDrawerURL('cutree','/cuadmin/ccm-import.do?op=newImport','parent.content','cutree_2'", "href")
_FFLinkClick("Import Users", "Text")

$ButtonName = _FFXPath(".//*[@Span='Import Users']")
_FFClick($ButtonName)

$ButtonName = _FFXPath(".//*[@Class='Import Users']")
_FFClick($ButtonName)

$ButtonName = _FFXPath(".//*[@id='cutree_2']")
_FFClick($ButtonName)

$ButtonName = _FFXPath(".//*['cutree_2']")
_FFClick($ButtonName)

$ButtonName = _FFXPath(".//*['Import Users']")
_FFClick($ButtonName)

 

Link to comment
Share on other sites

#NoTrayIcon
#include "FF V0.6.0.1b-15.au3"

_FFConnect()
_FFWindowSelect()
_FFTabSetSelected()
_FFFrameEnter(1)

$xref  = "//a[@class='cuesDrawerItemLink']"
$oLink = _FFXPath($xref)
_FFClick($oLink)

_FFClick returned 0. Firefox had the page preloaded with only 1 tab option. The Window Select did activate Firefox but the button wasn't clicked.

I also tried cuesDrawerItemLink in all the attempts i did above, but they all returned 0 as well

Edited by IanN1990
Link to comment
Share on other sites

I edited the code a little, to return an array.

#NoTrayIcon
#include "array.au3"
#include "FF V0.6.0.1b-15.au3"

_FFConnect()
_FFFrameEnter(1)

$xref  = "//a[@class='cuesDrawerItemLink']"
$oLink = _FFXPath($xref, "", 7)

_ArrayDisplay($oLink)

For $i = 1 to ubound($oLink)-1
   _FFClick($oLink[$i], "elements", 0, False)
Next

I clicked though all of them but nothing happened.

cisco troubleshooting.png

Edited by IanN1990
Link to comment
Share on other sites

It would help if you provided more information beyond "doesn't work". Which lines returned errors?

If the _FFXpath succeeded, then you could try something like --

_FFCmd("FFau3.xpath.onclick()")

Seems like there are multiple links with that same class. You would need to add another qualifier to reduce the results down to the desired one.

Link to comment
Share on other sites

Are we still on the button not clicking? If so I posted something to test.

The .document.getElementsByTagName basically wants the object type. In our case it's a button.

I create a variable called $fButton to run in a loop to search for "import user"<name displayed> then use a .click once it's found.

$fButton = .document.getElementsByTagName("button")
    For $b In $fButton
        If $b.innerHTML = "import user" Then
            $b.click()
        EndIf
    Next

 

Time for bed :|

 

Link to comment
Share on other sites

6 hours ago, Danp2 said:

It would help if you provided more information beyond "doesn't work". Which lines returned errors?

If the _FFXpath succeeded, then you could try something like --

_FFCmd("FFau3.xpath.onclick()")

Seems like there are multiple links with that same class. You would need to add another qualifier to reduce the results down to the desired one.

Sorry, i will try and provide more information :)

As you suspected the _FFXPath is succeeding and returning "OBJECT|FFau3.xpath".

I changed it to _FFXPath($xref, "", 10) to get the count and it returns 150 matches (which we can see in the array).

When i cycled though that array (using code above) _FFClick Returns 0

If i run your original code with _FFCmd("FFau3.xpath.onclick()") it returns "_FFCmd_Err"

I also tired it with _FFLinkClick and _FFOpenUrl with the arrayed information, all return 0.

6 hours ago, aa2zz6 said:

Are we still on the button not clicking? If so I posted something to test.

The .document.getElementsByTagName basically wants the object type. In our case it's a button.

I create a variable called $fButton to run in a loop to search for "import user"<name displayed> then use a .click once it's found.

$fButton = .document.getElementsByTagName("button")
    For $b In $fButton
        If $b.innerHTML = "import user" Then
            $b.click()
        EndIf
    Next

 

Time for bed :|

 

We are though slightly deviated from original question. Using Danp2 previous code, i am able to click the "import users" button using internet explorer but its just terribly slow. Using the principle being inside a frame before trying to interact with it i can automate the rest of the page with Firefox / IE. Its just this import users i am struggling with.

#NoTrayIcon
#include "array.au3"
#include "FF V0.6.0.1b-15.au3"

_FFConnect()
_FFFrameEnter(1)

$fButton = .document.getElementsByTagName("button")
    For $b In $fButton
        If $b.innerHTML = "import user" Then
            $b.click()
        EndIf
    Next

Causing Autoit v3 Script to stop working (with a crash error), doing my best to understand i converted it to FF

#NoTrayIcon
#include "array.au3"
#include "FF V0.6.0.1b-15.au3"

_FFConnect()
_FFFrameEnter(1)

$fButton = _FFCmd('.getElementsByTagName("button")')

    For $b In $fButton
        If $b.innerHTML = "import user" Then
            $b.click()
        EndIf
    Next

$Fbutton = [object HTMLCollection] - {item: function() {...}, namedItem: function() {...}, length: 0}

and i get 

Variable must be of type "Object".:
For $b In $fButton
For $b In $fButton^ ERROR

Link to comment
Share on other sites

First thing i tired :)

Quote

_FFXPath is succeeding and returning "OBJECT|FFau3.xpath".

If i run your original code with _FFCmd("FFau3.xpath.onclick()") it returns "_FFCmd_Err"

Code Used (to ensure i have not messed something up)

#NoTrayIcon
#include "array.au3"
#include "FF V0.6.0.1b-15.au3"

_FFConnect()
_FFFrameEnter(1)

$xref  = "//a[@class='cuesDrawerItemLink']"
$oLink = _FFXPath($xref)

_FFCmd("FFau3.xpath.onclick()")

 

Edited by IanN1990
Link to comment
Share on other sites

4 hours ago, IanN1990 said:

Sorry, i will try and provide more information :)

As you suspected the _FFXPath is succeeding and returning "OBJECT|FFau3.xpath".

I changed it to _FFXPath($xref, "", 10) to get the count and it returns 150 matches (which we can see in the array).

When i cycled though that array (using code above) _FFClick Returns 0

If i run your original code with _FFCmd("FFau3.xpath.onclick()") it returns "_FFCmd_Err"

I also tired it with _FFLinkClick and _FFOpenUrl with the arrayed information, all return 0.

We are though slightly deviated from original question. Using Danp2 previous code, i am able to click the "import users" button using internet explorer but its just terribly slow. Using the principle being inside a frame before trying to interact with it i can automate the rest of the page with Firefox / IE. Its just this import users i am struggling with.

#NoTrayIcon
#include "array.au3"
#include "FF V0.6.0.1b-15.au3"

_FFConnect()
_FFFrameEnter(1)

$fButton = .document.getElementsByTagName("button")
    For $b In $fButton
        If $b.innerHTML = "import user" Then
            $b.click()
        EndIf
    Next

Causing Autoit v3 Script to stop working (with a crash error), doing my best to understand i converted it to FF

#NoTrayIcon
#include "array.au3"
#include "FF V0.6.0.1b-15.au3"

_FFConnect()
_FFFrameEnter(1)

$fButton = _FFCmd('.getElementsByTagName("button")')

    For $b In $fButton
        If $b.innerHTML = "import user" Then
            $b.click()
        EndIf
    Next

$Fbutton = [object HTMLCollection] - {item: function() {...}, namedItem: function() {...}, length: 0}

and i get 

Variable must be of type "Object".:
For $b In $fButton
For $b In $fButton^ ERROR

Okay, after work I'll revise it to work on Firefox.

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...