Sign in to follow this  
Followers 0
scamperdog

IEFormElementOptionSelect does not Select Option!

6 posts in this topic

I have recently stumbled across AutoIT as an extremely useful tool to help automate a number of mundane procedures in our business.

One of which is populating an IE form with Customer Details from our Accounts Package.

The form is below:

http://pastebin.com/raw.php?i=cUD7SFUS

I have managed to populate the main fields:

  • billingSurname
  • billingFirstnames
  • billingAddress1
  • billingAddress2
  • billingCity
  • billingPostCode
However, I would like to populate the Select box with "United Kingdom", but I cannot manage to do this.

The code I use is this:

#include <IE.au3>

$hWnd = WinGetHandle("[CLASS:WindowsForms10.Window.208.app.0.378734a]")
$oIE = _IEAttach($hWnd, "embedded")
$oForm = _IEFormGetObjByName($oIE,"customerDetails")

Local $oSelect = _IEFormElementGetObjByName($oForm, "billingCountry")
_IEFormElementOptionSelect($oSelect, "GB", 1, "byValue")

I am not sure if I should be doing something to take care of the Javascript, but I am slightly out of my depth in that area.

Can anyone provide any pointers?!

Many thanks!

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I would use the return values to be sure you're attaching to the objects properly.

Also, do you have any errors that might be displayed in the console?

One more thing, do you have the HTML source for this form? Edit: :oops: You have the link above

Edited by MrMitchell

Share this post


Link to post
Share on other sites

Thanks for the response guys

I would use the return values to be sure you're attaching to the objects properly.

Sorry, very new to this, can you let me know what you mean by this?!

Also, do you have any errors that might be displayed in the console?

There didn't seem to be any errors, and when I viewed the Integer response from the function, it returned 1 which suggests it was successful.

I saved your code from http://pastebin.com/raw.php?i=cUD7SFUS to an HTML file locally, loaded in an IE window object and ran your code and it worked fine for me.

Arrgh - why doesn't it work for me?! My accounts package brings up this IE form when we need to make a credit card payment against an invoice. Could it be that it does it in a different way?

Thanks so much for taking the time to try and help me out - much appreciated!

Share this post


Link to post
Share on other sites

Assuming that it works stand-alone as GMK says and you've made no other mistakes locally, it would likely be some Javascript that is interfering (and didn't get saved when you saved the page source). You'll need to track it down to see what it is doing... possibilites are that it is expecting the OPTION to have focus (_IEAction, focus) or that the mouse be positioned over it or any of many other possibilities.

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

Share this post


Link to post
Share on other sites

Assuming that it works stand-alone as GMK says and you've made no other mistakes locally, it would likely be some Javascript that is interfering (and didn't get saved when you saved the page source). You'll need to track it down to see what it is doing... possibilites are that it is expecting the OPTION to have focus (_IEAction, focus) or that the mouse be positioned over it or any of many other possibilities.

Dale

I am not in front of the machine now to show you a screenshot, but yes, I believe there is some Javascript which is invoked. When you click on the drop down list there is an option to type in characters to perform a search for the Billing Country.

Where would I need to look in this? The HTML file has reference to some of the Javascript, but I guess there are separate Javascript files too.

I'll have a look tonight to see if I can give it focus, and report back should this not work!

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
Sign in to follow this  
Followers 0