Jump to content
Jamestay97

[Solved] help with button/link click

Recommended Posts

Posted (edited)

Hello! Thanks you for looking at my post

**No source code I'm sorry work related can't copy information**

I've been using autoit for about 1 year. 

I'm having trouble automating a click on an internet explorer web page and I've tried a lot of examples from help pages and forums already. The object I'm trying to click on isnt always in the same spot so I can't use mouse click or control click, I have tried to use the different get collection options and clickbyname, or index or get object. I'm just struggling. 

Description of object I'm trying to click -- 

HTML Code looks like <a ng-click.. "Click Here" it appears it's just a click able object named "click here" that opens a hidden window by running a script inside the web page. I'm not able to grab the information from the window unless it's open so I have to automate this click somehow. 

 

I understand it's difficult to assist without having something to look at, I apologize for that sincerely and appreciate and assistance and suggestions. 

Edited by Jamestay97
Issue solved

Share this post


Link to post
Share on other sites

Danp2, 

Yes I have tried the clickbytext and clickbyindex it seems like when I used a MsgBox to display the clickbyindex options it was there but can't be clicked for some reason. Using F5 in Sci yielding the usual not found error. 

Share this post


Link to post
Share on other sites

Danp2, 

I did look into frames, but I will also check again. The error was similar but it was specifically mentioning the name of the object I was trying to get, so "Click Here" not found  

Share this post


Link to post
Share on other sites

The HTML shows 

<a ng-click="showAdditionalinfo(order Task Detail.task.additionalinfo)" ng-show="ordertask detail.task.additionalInfo">click here</a>

Share this post


Link to post
Share on other sites
<!-- ngIf: !orderTaskDetail.order&&isAdditionalInfoExist() -->
<td class="ng-scope" ng-if="!orderTaskDetail.order&amp;&amp;isAdditionalInfoExist()">
                <a ng-click="showAdditionalInfo(orderTaskDetail.task.additionalInfo)" ng-show="orderTaskDetail.task.additionalInfo">
                    Click Here
                </a>
            </td>

The above text is for the "click here" button/link and below I'm linking my new problem which is a drop down list in the same instance.

<select class="inputTxt taskDetailsPrDisp ng-pristine ng-untouched ng-valid ng-not-empty" style="margin-left: 15px;" ng-change="selectPrimaryDisposition()" ng-model="viewTaskDetails.taskDetail.currPrimaryDispId" ng-options="item.id as item.value for item in viewTaskDetails.taskDetail.availablePrimaryDisps"><option selected="selected" value="">--Select--</option><option value="number:6205" label="Complete">Complete</option><option value="number:6206" label="Incomplete">Incomplete</option><option value="number:6345" label="Unable to Resolve - Send to PAC for Handling">Unable to Resolve - Send for Handling</option></select>

My current version of the code is pretty long and I've tried multiple things.  I'm mainly having an issue trying to find the form name and the object names. 

but for something like a radio button on the same page I was able to make something like this.. 

$oIE = _IEAttach("SMART")
   $sHtml=_IEBodyReadHTML($oIE)
$aArray = _StringBetween($sHtml, "rate.a.call.poor", "rate.a.call.no.contact")
$sString = _ArrayToString($aArray, " ", 0, 0)
$aArray1 = _StringBetween($sString, 'name="' , "class")
$sString1 = _ArrayToString($aArray1, " ", 0, 0)
$sStringLen = StringLen($sString1)
$final = StringLeft($sString1, $sStringLen - 2)
$oRadio = _IEGetObjByName($oIE,$final)
_IEAction($oRadio,"Click")

then for the text box on the same page is this...

$oIE = _IEAttach("SMART")
$oObj = _IEGetObjByName($oIE,"comment")
_IEPropertySet($oObj,"innertext","Account is CSG unable to complete task.")

 

Share this post


Link to post
Share on other sites
22 minutes ago, Jamestay97 said:

ng-click

This is indicative of a website using AngularJS, which has proven problematic to automate.

25 minutes ago, Jamestay97 said:

but for something like a radio button on the same page I was able to make something like this.. 

Why would you need to do this? Does the name dynamically change each time?

3 hours ago, Jamestay97 said:

I did look into frames, but I will also check again. The error was similar but it was specifically mentioning the name of the object I was trying to get, so "Click Here" not found  

This is too vague. Show us the actual error message if you want meaningful help. 😉

Share this post


Link to post
Share on other sites

 

Sure thing, here's some examples of what I've tried so far. 

#include <IE.au3>
$oIE = _IEAttach("SMART")
$oObj = _IEGetObjByName($oIE,"showAdditionalInfo(orderTaskDetail.task.additionalInfo)")
_IEAction($oObj, "click")
--> IE.au3 T3.0-2 Warning from function _IEGetObjByName, $_IESTATUS_NoMatch (Name: showAdditionalInfo(orderTaskDetail.task.additionalInfo), Index: 0)
--> IE.au3 T3.0-2 Error from function _IEAction(click), $_IESTATUS_InvalidDataType

This code does not yield an error in SciTE however does not produce a click to the object.

#include <IE.au3>

Local $oIE = _IEAttach("SMART")

Local $sMyString = "Click Here"
Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    Local $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $sMyString) Then
       _IEAction($oLink,"focus")
       sleep(500)
        _IEAction($oLink, "click")
        sleep(500)
        _IEAction($oLink, "enable")
        sleep(500)
        ExitLoop
    EndIf
Next

Here's another example, same kind of $_IESTATUS_NoMatch

$oIE = _IEAttach("SMART")
$oForm = _IEFormGetObjByName ($oIE, "ng-scope")
$oText = _IEFormElementGetObjByName ($oForm, "showAdditionalInfo(orderTaskDetail.task.additionalInfo)")
$oAction = _IEAction($oText,"Click")
--> IE.au3 T3.0-2 Warning from function _IEFormGetObjByName, $_IESTATUS_NoMatch
--> IE.au3 T3.0-2 Error from function _IEFormElementGetObjByName, $_IESTATUS_InvalidDataType
--> IE.au3 T3.0-2 Error from function _IEAction(Click), $_IESTATUS_InvalidDataType
>Exit code: 0    Time: 0.3138

Again this is the HTML it looks like it's part of a table so I'm going to try to edit my script to pander towards an IE table and see if  that resolves the issue.

<td class="ng-scope" ng-if="!orderTaskDetail.order&amp;&amp;isAdditionalInfoExist()">
                <a ng-click="showAdditionalInfo(orderTaskDetail.task.additionalInfo)" ng-show="orderTaskDetail.task.additionalInfo">
                    Click Here
                </a>
            </td>

 

 

 

Share this post


Link to post
Share on other sites

"showAdditionalInfo(orderTaskDetail.task.additionalInfo)" and "ng-scope" aren't valid element names, so the errors you received are expected.

In the code where you loop through all links, there's no way to tell if it found the desired link. You should add a ConsoleWrite or a MessageBox for diagnostic purposes.

 

Share this post


Link to post
Share on other sites
Posted (edited)

I will attempt to do that would you mind including that in the source code I provided? 

I would prefer a msgbox but I'm not sure how to make it cycle for each link found.

thank you again!

edit: this is what I tried however the msgbox is coming up blank.

edit2: I got the msgbox working but the "Click Here" link was not included in the list of links. Possibly because it's in the table?

 

For $oLink In $oLinks
    Local $sLinkText = _IEPropertyGet($oLink, "innerText")
    msgbox(0,"",$sLinkText & @Extended)
    If StringInStr($sLinkText, $sMyString) Then
       _IEAction($oLink,"focus")

 

Edited by Jamestay97
updated code

Share this post


Link to post
Share on other sites
Posted (edited)

This is an update to the code I've been working on as far as the object being in a table..

The ArrayDisplay shows the "Click Here" value in row 11 - col 2 .. included a screenshot .. hooray!(sort've)

The click portion of the code isn't doing anything still, but no errors in sciTE

Heres the code. 

Local $oIE = _IEAttach("SMART")
$oTable = _IETableGetCollection ($oIE, 1)
$aTableData = _IETableWriteToArray ($oTable)
_ArrayDisplay($aTableData); have I got the right table
$oLinks = _IELinkGetCollection ($oIE)
For $oLink In $oLinks
    If StringInStr($oLink.href , "Click " ) Then
        _IEAction($oLink, "click")
    EndIf
Next
_IELoadWait( $oIE )

 

screenshot61020.png

Edited by Jamestay97
explanation of code behavior

Share this post


Link to post
Share on other sites

You may want to try this :

#include <IE.au3>
#include <Array.au3>

Local $oIE = _IEAttach("SMART")
$oTable = _IETableGetCollection ($oIE, 1)
$aTableData = _IETableWriteToArray ($oTable)
_ArrayDisplay($aTableData); have I got the right table
$oLinks = _IETagNameGetCollection ($oTable, "a")
For $oLink In $oLinks
  ConsoleWrite (_IEPropertyGet ($oLink, "innertext") & @CRLF)
    If StringInStr($oLink.innerText , "Click" ) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next
_IELoadWait( $oIE )

 

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Zaoka
      I'm trying to create script that would login on my SAP WEBI "web page" and replace some uploaded excel files. But i'm having problem on even the log in.
      These are user fill elements with Firefox Inspector
      <input type="text" id="_id0:logon:CMS" name="_id0:logon:CMS"> <input type="text" id="_id0:logon:USERNAME" name="_id0:logon:USERNAME"> <input type="password" id="_id0:logon:PASSWORD" name="_id0:logon:PASSWORD"> LogOnButton
      <input type="submit" id="_id0:logon:logonButton" value="Log On" class="logonButtonNoHover logon_button_no_hover" onmouseover="this.className = 'logonButtonHover logon_button_hover';" onmouseout="this.className = 'logonButtonNoHover logon_button_no_hover';">  
       
      My example, I tried _IEGetObjByName and _IEGetObjById but the script only open page but will not even fill out the form
        #include <IE.au3> Call("signIn") Func signIn() Global $oIE = _IECreate("http://192.xxx.xxx.xx:xxx/BOE/BI") Sleep (5000) Local $server = _IEGetObjByName($oIE, "_id0:logon:CMS") Local $username = _IEGetObjByName($oIE, "_id0:logon:USERNAME") Local $password = _IEGetObjByName($oIE, "_id0:logon:PASSWORD") Local $button = _IEGetObjById($oIE, "_id0:logon:logonButton") _IEFormElementSetValue($server, "TestServer:1000") _IEFormElementSetValue($username, "MyUserName") _IEFormElementSetValue($password, "MyPass") ; THIS PART ABOUT BUTTON CLICK I DONT UNDERSTAND AT ALL $sSelector = "body > div:nth-of-type(2) > div > div:nth-of-type(3) > div > table > tbody > tr > td > table > tbody > tr > td > table > tbody > tr:nth-of-type(1) > td > div > div:nth-of-type(1) > form > div:nth-of-type(5) > button" $signInUC = $oIE.document.QuerySelector($sSelector) _IEAction($signInUC, "click") EndFunc ;==>signIn  
      I would be very grateful for any help
    • By adityaparakh
      Hello ,

      A website I am trying to login with my credentials.
      And retrieve the cookie into a text file.
      Unable to do so.
      Is it that certain,  Httponly , type - are not allowed to be fetched.

      Then further ,
      I will be checking every 5 minutes if my session is active , else re-login and re-fetch the cookie.
      For the second part , I will probably fetch some table and see if not in appropriate format do Part 1 : Fetch Cookie - again.
      Any better way , tips would be appreciated.
       
      Thanks
       
    • By FUD
      hello 
      please i need help 
      i need to open link in default browser only one windows without duplicate if i try to open the same link 
       
      thanks 
    • By kingjacob90
      Hi
      So I am trying to click the green button, this button is not always in the same place. So fare I am trying to click it by finding the color but there is also something else with the same color on the screen (circled in yellow) that is causing issues. Is there a way to use the Title and Class of the window (can't be just the window as there are more than one with the same name).
      How does AutoIt Info get this information?

    • By Mariog2000
      I've tried for a few days to simply open a url in IE and click an IE object that I can't "TAB" to and don't want to use a mouse-click if at all possible.  I've read up on things like using IEAction and IETagNameGetCollection to find the object but not smart enough to figure out how that works with my url or how to tell if my url is "basic" or a "form", "frameset", "iframe", etc.
      The other problem is I've tried using the "Run" and "ShellExecute" commands to open the browser, which works, but it opens it in a way that doesn't include my currently logged in user account.  For example, if I just click IE or Chrome for that matter and open my default homepage of google, the page that opens knows I'm logged in.  When I use "Send" "ShellExecute" or "_IE_Create" they always open pages generically which would require a login.
      So questions are, if I have a URL I'm trying to open, that's passes the currently logged on users credentials when opening the page (no clue where that happens)
      1.  Are there any code examples someone is willing to share that opens my IE maximized, with logged in credentials, and
      2.  Once that works, can someone suggest a technique a non-developer can find which IE Objects I need to send a "click" to so it opens the correct menu, pop-up, url, etc., associated with that object.  I've copied what doesn't work and sure I'm way off but it's not for a lack of effort. I'll keep trying and post updates but not looking good 🙂
      #include <IE.au3>
      Call ("selection")
      Func selection ()
      Global $oIE = _IECreate ("https://internal-webpage.aspx")
      Local $selectid = _IEGetObjByName ($oIE, "signageNo")
      Local $button = _IEGetObjByName ($oIE, "GO")

      _IEFormElementOptionSelect ($selectid, "3")
      _IEAction ($button,"click")
      EndFunc
      #include <IE.au3> Call ("selection") Func selection () Global $oIE = _IECreate ("https://internal-webpage.aspx") Local $selectid = _IEGetObjByName ($oIE, "signageNo") Local $button = _IEGetObjByName ($oIE, "GO") _IEFormElementOptionSelect ($selectid, "3") _IEAction ($button,"click") EndFunc 1. 
×
×
  • Create New...