Jump to content

Set Value to an IE input box with hidden properties.


 Share

Recommended Posts

I am fairly new to autoit and dont know all the ins and outs, but I have been able to figure out a lot of it on my own. However, I have encountered a problem.

I am trying to automate filling out forms for my work. I have used _IEFormElementSetValue for most of entering the data. But this one box where I am trying to enter a numerical value isn't working for some reason. I know I have the right Form because the value is entered but when every I try to press continue it still recognizes the value as being "0".

here is the section of my code

$oForm4 = _IEFormGetObjByName($oIE, "aspnetform")
$test = "500"
$fland = _IEFormElementGetObjByName($oForm4, "ctl00$ContentPlaceHolder1$rntxtLandOpinion")
_IEFormElementSetValue ($fland,$test)

and the source html.

<span id="ctl00_ContentPlaceHolder1_rntxtLandOpinion_wrapper" class="riSingle RadInput RadInput_Default" style="width: 125px;"><input id="ctl00_ContentPlaceHolder1_rntxtLandOpinion" name="ctl00$ContentPlaceHolder1$rntxtLandOpinion" class="riTextBox riEnabled numerictextboxstyle" value="$0" type="text">

<input value="{&quot;enabled&quot;:true,&quot;emptyMessage&quot;:&quot;&quot;,&quot;validationText&quot;:&quot;0&quot;,&quot;valueAsString&quot;:&quot;0&quot;,&quot;minValue&quot;:0,&quot;maxValue&quot;:100000000}" autocomplete="off" id="ctl00_ContentPlaceHolder1_rntxtLandOpinion_ClientState" name="ctl00_ContentPlaceHolder1_rntxtLandOpinion_ClientState" type="hidden"></span>

One thing I have noticed is that there are two parts to the source. The second part is hidden. Whenever I enter a value manually I noticed that the validationText and the ValueAsString values change but nothing else. for example if I typed in 500, that 0 marked in red above would change to 500. So I thought of using possibly something like _iepropertyset(not sure if this would work) or like a bodywritehtml kind of thing to alter that 0 to a 500. but cannot seem to figure out how to acheive the right results. I have tried messing around with a bunch of different variations of code, but due to my lack of knowledge of autoit i cannot seem to figure this one out on my own. Any insight would be helpful.

Edited by blkshadow82
Link to comment
Share on other sites

Try doing a GetValue right after the SetValue to see if the field contains what you think it should. If not, event-triggered Javascript is messing with your value change. If it is what you expect, then whatever is processing your values doesn't like something in the string you've entered there.

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

Yea it still came back as the default value of 0. Like I said if I were to manually key in a value of 500 the html would change as follows.

from default:

<span id="ctl00_ContentPlaceHolder1_rntxtLandOpinion_wrapper" class="riSingle RadInput RadInput_Default" style="width: 125px;"><input id="ctl00_ContentPlaceHolder1_rntxtLandOpinion" name="ctl00$ContentPlaceHolder1$rntxtLandOpinion" class="riTextBox riEnabled numerictextboxstyle" value="$0" type="text">

<input value="{&quot;enabled&quot;:true,&quot;emptyMessage&quot;:&quot;&quot;,&quot;validationText&quot;:&quot;0&quot;,&quot;valueAsString&quot;:&quot;0&quot;,&quot;minValue&quot;:0,&quot;maxValue&quot;:100000000}" autocomplete="off" id="ctl00_ContentPlaceHolder1_rntxtLandOpinion_ClientState" name="ctl00_ContentPlaceHolder1_rntxtLandOpinion_ClientState" type="hidden"></span>

After keying in the value of 500:

<span id="ctl00_ContentPlaceHolder1_rntxtLandOpinion_wrapper" class="riSingle RadInput RadInput_Default" style="width: 125px;"><input id="ctl00_ContentPlaceHolder1_rntxtLandOpinion" name="ctl00$ContentPlaceHolder1$rntxtLandOpinion" class="riTextBox riEnabled numerictextboxstyle" value="$0" type="text">

<input value="{&quot;enabled&quot;:true,&quot;emptyMessage&quot;:&quot;&quot;,&quot;validationText&quot;:&quot;500&quot;,&quot;valueAsString&quot;:&quot;500&quot;,&quot;minValue&quot;:0,&quot;maxValue&quot;:100000000}" autocomplete="off" id="ctl00_ContentPlaceHolder1_rntxtLandOpinion_ClientState" name="ctl00_ContentPlaceHolder1_rntxtLandOpinion_ClientState" type="hidden"></span>

notice how the value stays static.

The box has a forced format. For example if the user keys in 5000 to the box it changes it to $5,000. So I think I have to find some way of changing the validation text and valueasstring values somehow.

Link to comment
Share on other sites

It's not clear to me the results of doing the GetValue, but in any case, your issues are in the Javascript and there is no way for us to know what it is or what it is doing.

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

Looking at your HTML, shouldn't $test be "$500" rather than 500?

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

I've tried both ways. Still nothing. I am not sure if _IEFormElementSetValue is going to work. If you look at the 2 html examples I gave, you can see the value never changes even if there is a value typed in the input box. So its really not the value that I am trying to change, its the "validationText" and "ValueasString" that need to be changed.

The second HTML example is what we are trying to get the autoit code to acheive.

Link to comment
Share on other sites

OK, looking at this again, I think you are really just going about this wrong. I don't think that the HTML you have posted is part of the active DOM on the page at all, but is rather part of a script used in the background to generate active content.

I'd suggest you use something like the following to examine the INPUT tags on the page and see if you can find what you are really after:

$oInputs = _IETagnameGetCollection($oIE, "input")
For $oInput in $oInputs
    ConsoleWrite(_IEPropertyGet($oInput, "outerhtml) & @CRLF & "*****************" & @CRLF)
Next

Also, suggest using DebugBar if you are not doing so already.

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

Oh my... Wow debug bar is gunna make life soooo much easier. Thank you for that tip. I'm going to play around with a few things on this and try to figure it out now. I was using mozilla to inspect the elements.

I have been trying to figure out Consolewrite and I am not clear on what it does. I have read through the function page and still cant seem to figure it out. Does it write information to like a note pad? because when ever I use it nothing comes up. also what is supposed to go in "*****************" this section of your code?

I apologize for my noobishness haha. I have only been using Autoit for a few weeks.

also i have zero knowledge of html. Everything I was going off of was just theory haha.

I will play around with the debug bar try to figure it out myself and if I have any more questions or find the solution I will post back.

Edited by blkshadow82
Link to comment
Share on other sites

Run your script from inside SciTe, the editor provided with AutoIt, and use F5. The console is the window at the bottom of the editor.

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

Alright I will try that. Thanks.

Got it working!

Here's what I got

$oForm4 = _IEFormGetObjByName($oIE, "aspnetform")
$test = "500"
$test2 = "$500"

$fland = _IEFormElementGetObjByName($oForm4, "ctl00_ContentPlaceHolder1_rntxtLandOpinion")
_IEFormElementSetValue ($fland, $test2)
$fland2 = _IEFormElementGetObjByName($oForm4, "ctl00_ContentPlaceHolder1_rntxtLandOpinion_ClientState")
_IEFormElementSetValue ($fland2, '{"enabled":true,"emptyMessage":"","validationText":"'& $test & '","valueAsString":"'& $test &'","minValue":0,"maxValue":100000000}')
$totalval = _IEFormElementGetObjByName($oForm4, "ctl00_ContentPlaceHolder1_rntxtOpinionTotal")
_IEFormElementSetValue ($totalval, $test2)
$totalval2 = _IEFormElementGetObjByName($oForm4,"ctl00_ContentPlaceHolder1_rntxtOpinionTotal_ClientState")
_IEFormElementSetValue ($totalval2, '{"enabled":true,"emptyMessage":"","validationText":"'& $test &'","valueAsString":"'& $test &'","minValue":0,"maxValue":70368744177664}')

thanks for the help.

Link to comment
Share on other sites

Congrats!

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