Jump to content
ur

How to automate button click in IE

Recommended Posts

ur

For the below form, I am able to automate using below code for textboxes.

1.JPG

#include <IE.au3>

Local $oIE = _IEAttach("http://localhost:18170/MartAdmin/", "url")
_IELoadWait($oIE)

$Search = _IEGetObjById($oIE,"x-auto-16-input")
_IEPropertySet($Search, 'innerText','Uday KIran')

$Search = _IEGetObjById($oIE,"x-auto-18-input")
_IEPropertySet($Search, 'innerText','Uday KIran')

But for the Login button, there is no id or name.

The html code when I click on Inspect element in browser, shown below.

<button tabindex="0" class="x-btn-text" style="width: 64px; position: relative;" type="button">Log In</button>

Please let me know how to click this.?

 

Share this post


Link to post
Share on other sites
ur

when I click on view source, I am getting only below code

 

<!doctype html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">

    <link type="text/css" rel="stylesheet" href="gxt/css/gxt-all.css" />
    <link type="text/css" rel="stylesheet" href="css/ca-all.css" />
    <link type="text/css" rel="stylesheet" href="MartAdminConsole.css">   
     
    <title>erwin Mart Administrator</title>    
   
  </head>

  <body>

    <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>
    
    <div id="loading"> 
        <img src="gxt/images/default/shared/large-loading.gif"  
        width=" 32" height=" 32 " />Loading...<br />
    </div>
    
     <script type="text/javascript" language="javascript" src="MartAdminConsole/MartAdminConsole.nocache.js"></script>
  </body>
</html>

with inspect element I am getting below.

Capture.JPG

 

_IETagNameGetCollection giving empty value with table tag.

Share this post


Link to post
Share on other sites
Danp2

Looks like the site uses frames. Try getting a reference to the frame using either _IEFrameGetObjByName or _IEFrameGetCollection, and then use that instead of $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

  • Similar Content

    • TLAM
      By TLAM
      Hello,
      I am working on an autoIT script for CyberArk which is running Internet Explorer and connecting the user to a web application.
      For an unknown reason (I cannot explain why), IE has some trouble to start, only after a long disconnecting period (morning or after lunch). If he tries again, no problem, IE starts.
      I open a case with CyberArk but I am also searching a workaround, I thought to kill the process directly, or set a timeout with _IELoadWait but the process is not really created..

      May do you have any ideas for helping me ?

      Thanks in advance
       
    • Seminko
      By Seminko
      Wrote a script that grabs all of the IP addresses from Netflix's IP log, checks the IPs and returns suspicious activity.
      Everything works as it should but only when _IECreate is set to visible. When visible is set to false, it fails to login for some reason.
      Any ideas what might cause it and/or how to circumvent that?
    • nooneclose
      By nooneclose
      I need to send a string of text to this popup and click on the ok button to save it.
      Here is the code I have so far:
      ;Start IE Sleep(7000) $oIE = _IECreate("http://www.google.com") Sleep(500) _IELoadWait($oIE) $hIE = _IEPropertyGet($oIE, "hwnd") ; Get Handle of the IE window Sleep(500) WinSetState($hIE, "", @SW_MAXIMIZE) ;Wait for a browser page load to complete Sleep(3000) _IENavigate($oIE, "https://properURL.com") Sleep(8000) _IELoadWait($oIE) ;Attach to a browser control embedded in another window $oIE = _IEAttach("https://"properURL.com", url") ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $oIE = ' & $oIE & @CRLF & '>Error code: ' & @error & ' Extended code: 0x' & Hex(@extended) & @CRLF) ;### Debug Console Sleep(2000) ;Get the title of the webpage ;Local $wTitle = _IEPropertyGet($oIE, "title") ;MsgBox($MB_SYSTEMMODAL, "Webpage title:", $wTitle) ;Clicks the new button Sleep(3000) _IEAction($nWorkOrderB, "focus") _IEAction($nWorkOrderB, "click") Sleep(5000) ;Store the Element names where the important data will be sent ;Store the long description button Local $wLongDButton = _IEGetObjById($oIE, "m65d795a4-img") ;Store the long Description field id Local $wComments = _IEGetObjById($oIE, "ma6499a9c-rte_iframe") ;Store the ok button id that is in the long description Local $wCommOk = _IEGetObjById($oIE, "m74031266-pb") ;******************************************************************************* ; Send the stored data to the proper field ;******************************************************************************* ;Click the long description button Sleep(300) _IEAction($wLongDButton, "focus") _IEAction($wLongDButton, "click") Sleep(300) ;Sends the Comments Sleep(500) _IEAction($wComments, "focus") _IEAction($wComments, "click") Sleep(500) _IEFormElementSetValue($wComments, "hello darkness my old friend") ;Click the ok button Sleep(500) _IEAction($wCommOk, "focus") _IEAction($wCommOk, "click") Sleep(500)  
      Here is the popup:

    • hemichallenger
      By hemichallenger
      Hello,
      If anyone can help, it would be greatly appreciated. The code is just an example and similar to the issue with an internal webpage. I'm trying to autofill than click the submit button. I get the same error running the script.
      _IEFormElementSetValue, $_IESTATUS_InvalidObjectType
      IEGetObjById, $_IESTATUS_NoMatch
      Is it possible to edit the <textarea></textarea>  field with AutoIt?  If anyone could assist me on how. Than I could have a better understanding and chance in figuring it out on my main script. Thank you
      #include <IE.au3> Local $oIE1 = _IECreate ("https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_textarea") _IELoadWait($oIE1) local $oFormCollection = _IEFormGetCollection($oIE1,0) local $oid = _IEGetObjByid($oFormCollection, "iframeResult") _IEFormElementSetValue($oid, "test") sleep (2000) Local $oIE2 = _IECreate ("https://www.w3schools.com/html/tryit.asp?filename=tryhtml_scripts_intro") _IELoadWait($oIE2) $oForm2 = _IEFormGetCollection($oIE2,0) $oClickMe = _IEGetObjById($oForm2, "demo") _IEAction($oClickMe, "focus") _IEAction($oClickMe, "click")
×