Jump to content

Need help using _IELinkClickByText


Recommended Posts

I am unable to log in this web page using _IELinkClickByText for LOG IN button. It is not "clicking" it. Is there a flaw in this code?

#include <IE.au3>
$oIE = _IECreate("https://my.t-mobile.com/login/MyTmobileLogin.aspx", 0, 1, 0)
_IELoadWait($oIE)

$oUsername = _IEGetObjByName($oIE, "Login1:txtMSISDN")
$oPassword = _IEGetObjByName($oIE, "Login1:txtPassword")
_IEFormElementSetValue($oUsername, "0123456789")
_IEFormElementSetValue($oPassword, "password")
_IELinkClickByText($oIE, "LOG IN")
Link to comment
Share on other sites

I am unable to log in this web page using _IELinkClickByText for LOG IN button. It is not "clicking" it. Is there a flaw in this code?

This is because there is no "link" to click. It is using javascript technique (onclick event) to activate the login using a special HTML tag called a DIV. BTW, DebugBar made it very quick and easy to diagnose this (see my sig).

Here is the important section of code:

<DIV id=enabledbtnLoginClickOnce onmouseover="java script:window.status='LOG IN';" style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px" onclick="java script: { if (typeof(Page_ClientValidate) != 'function' || Page_ClientValidate()) __doPostBack('Login1$btnLoginClickOnce','') };{ if (Page_IsValid)  PleaseWait('enabledbtnLoginClickOnce', 'disabledbtnLoginClickOnce', ''); }" onmouseout="window.status='';"><TABLE class=buttontable style="CURSOR: pointer; MARGIN-RIGHT: 15px" cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD class=buttoncell><IMG src="/images/mytmobile/ph/buttons/leftp.gif" border=0></TD>
<TD class=buttoncontainerp noWrap>
<TD class=buttontextp style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BACKGROUND: url(/images/mytmobile/ph/buttons/midp.gif) #fff repeat-x left top; PADDING-BOTTOM: 0px; PADDING-TOP: 0px">LOG IN</TD></TD>
<TD class=buttoncell><IMG src="/images/mytmobile/ph/buttons/rightp.gif" border=0></TD></TR></TBODY></TABLE></DIV>

Stody this and you'll see that a DIV with an ID of enabledbtnLoginClickOnce has an onclick action that initiates the login. So, replace your LinkClick with:

$oDiv = _IEGetObjByID($oIE, "enabledbtnLoginClickOnce")
_IEAction($oDiv, "click")

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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