Jump to content

Name and ID attributes have invalid chars


Recommended Posts

I am trying to automate a commercial software web application. The challenge is that the html appears to use "$" signs in a number of attributes, and when I try the following code it does not find a match (I think that AutoIt may enforce the HTML standard about allowable characters in name and Id attributes?)

$oRecruiter = _IEGetObjById($oForm, "RECRUITER1$W_US_Candidate$W_US_Candidate")

--> IE.au3 V2.4-0 Warning from function _IEGetObjById, $_IEStatus_NoMatch (RECRUITER1$W_US_Candidate$W_US_Candidate)

The snippet of HTML for the text box I am trying to enter data into is below

I believe that the attributes are generated on the fly by the code, I cannot change them

<input type="text" id = "RECRUITER1$W_US_Candidate$W_US_Candidate"

NAME="RECRUITER1$W_US_Candidate$W_US_Candidate"

tabIndex=1

QFATTRIBUTE="141" MANDATORY="false" QFPROPERTY="14" DATATYPE="REFERENCE"

CONTROL_TYPE="DATATYPE_CONTROL"

CONTROL_PATH=RECRUITER1$W_US_Candidate$W_US_Candidate

ACTION_NAME=""

VIEWID="8997989"

CONTROL_ID="10136"

GROUP_ID="RECRUITER1$W_US_Candidate$W_US_Candidate"

value=""

PREVIOUS_CONTROL_ID="ETIME"

NEXT_CONTROL_ID="RECRUITER2"

INFORMATTER="false"

ROLE_IDS="1"

IS_ATTRIBUTE_CONTROL="FALSE"

SPECIAL_DATATYPE="User"

style="height: 20; width: 128px; padding: 0px; border-style:double;border-width:1; FONT-FAMILY:Arial; FONT-WEIGHT:100; FONT-SIZE:10pt; COLOR:#000000; FONT-STYLE:Blank; TEXT-DECORATION:; FONT-VARIANT:No; TEXT-TRANSFORM:None; " onfocusOut="javascript:onfocusLost(this);" ON_FOCUS_OUT_WORKFLOW_CONFIGURED="FALSE"

ON_CHANGE_WORKFLOW_CONFIGURED=FALSE onchange="javascript:onchange(this);" onkeydown="javascript: onkeypress(this);"onclick="javascript:this.createTextRange().select()">

Link to comment
Share on other sites

The _IEGetObjByID() doesn't take a form object as its first parameter. It needs a Application, Window or Frame object. For example, the Help File examples use $oIE to represent their IE object, so give that a try.

If you wish to use the $oForm, then you should use _IEFormElementGetObjByName() but you'd then need to use the text input's name rather than ID as the second parameter, which in this case appears to be the same.

Link to comment
Share on other sites

The _IEGetObjByID() doesn't take a form object as its first parameter. It needs a Application, Window or Frame object. For example, the Help File examples use $oIE to represent their IE object, so give that a try.

If you wish to use the $oForm, then you should use _IEFormElementGetObjByName() but you'd then need to use the text input's name rather than ID as the second parameter, which in this case appears to be the same.

Thanks for the feedback - I dont think thats the issue (the variable $oForm actually refers to the popup that the snippet of HTML I posted came from). I tested this by using the identical _IEGetObjById call to a different ID that doesnt have a "$" sign in its ID, and retrieving its value and displaying it. So I am confident that the variable $oForm refers to the page I am trying to control (but I guess I could have named the variable something like $oPopup <G>)

The root problem appears to be that all of the references to this textbox have illegal names due to $ signs - is there any way to get AutoIt to override the rule and access these items any way?

Link to comment
Share on other sites

The root problem appears to be that all of the references to this textbox have illegal names due to $ signs - is there any way to get AutoIt to override the rule and access these items any way?

Well now I'm just confused... if the above is in fact the case then might be something DaleHolm could help with, he's the IE guy.

Other suggestion: Use _IEFormElementGetCollection() to do 2 different things. 1) Get the reference to the text input based on it's index, which you won't know until you try each one by one or by 2) Using this function to get all elements in the collection then loop through each object in the collection and display the index, name, id, etc...

Hope that makes sense?

Can you give the name of the app you're using, and possibly a test account then steps to re-create where you're at?

Link to comment
Share on other sites

Thanks for the feedback - I dont think thats the issue (the variable $oForm actually refers to the popup that the snippet of HTML I posted came from). I tested this by using the identical _IEGetObjById call to a different ID that doesnt have a "{:content:}quot; sign in its ID, and retrieving its value and displaying it. So I am confident that the variable $oForm refers to the page I am trying to control (but I guess I could have named the variable something like $oPopup <G>)

How are you attaching a variable to the pop-up window?

Link to comment
Share on other sites

  • 3 weeks later...

How are you attaching a variable to the pop-up window?

I used the call

$oForm=_IEAttach("Candidate Search")

and tested that it actually did attach by retrieving the URL and printing it with a msgbox, I also retrieved the value of a field which had a legal name (without the $ signs)

Link to comment
Share on other sites

To try to rule out other possible problems, suggest you examine the output from:

ConsoleWrite(_IEDocReadHTML($oForm) & @CRLF)

BTW, using $oForm to attach to a browser instance will add confusion for anyone trying to help you. That variable is typically used for <form> tags.

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