Sign in to follow this  
Followers 0
Wolfiesaxah

Selecting value in a dropbox

12 posts in this topic

#1 ·  Posted (edited)

Hi guys, this is another complicated scenario for me and I tried looking for answers but nobody seem to have encountered this before.

So I have a script using IE.AU3 to open a page then click a button there. When that button is clicked, it goes to the next page where there's a dropdown list. I need to select one of the entries in that list.

 

I found the code above but it opens a new website then select's the dropdown list on that newly created website. What I need AI to do is select one of the items in the listbox of the currently/previously opened/created IE page. I am using this for a step by step form filling wherein Page 1 has the Sign-up button and Page 2 has the listbox so AI has to:

1. Create the page/site (Already know this)

2. Click the Sign-up button (This switches the page to page 2)

3. Select one of the items in dropdown listbox (This is where the problem is, AI must be able to select without having to create a new page/site)

Edited by Wolfiesaxah

Share this post


Link to post
Share on other sites



You have to know all the elements of each page that you want to interact with, either by their list order, id, classname, name, etc...

Looking at what you've provided and how you've worded things.

1.  Download debugbar so you can inspect the IE dom

2.  Learn how to use the IE functions themselves

3.  Code something of your own

4.  If you run into issues, post your own code


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

What is Debugbar though? I tried searching for that here and on google but nothing comes up where I can download it.

I'm not really skilled with Autoit yet I'm still learning and I just started 3 days ago lol. I'm a VB programmer but I had MSDN to easily pickup and understand the structure of each scripts. This one however, took me more than a day and I still can't figure out. All I know is _IECREATE() opens the url I specify and and I got that part correctly but after filling the form in that first url and having Autoit click next, I'm lost. I can't make a new _IECREATE() that would ruin the 3-page sign-up process. I tried searching the IE.AU3 for scripts that could be what I was looking for but no luck. Does anybody have a sample of IE script that checks (Not create) the currently opened IE page for an element and selects one of the list in the dropdown for that element?

The sample code above is what I found on here as a guide but it's not my own code, I don't have a code for this step yet as I am having trouble learning that on my own.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

s
Edited by Wolfiesaxah

Share this post


Link to post
Share on other sites

http://www.debugbar.com/  <-- 1st link that pops up in google, and exactly what you need to download, read how to use it from their site/help

You need to use the debugbar to find the id/name/classname/etc from the objects you want to control/manipulate.

From your code, $oIE is the main browser object.  That will never change unless you're working in frames or another tab.

So after: _IEImageClick(), you would use something like:

_IELoadWait($oIE); this waits for the new page to load (rather than your sleep(3000)).

From the new page you will have objects you want to work with, but $oIE will always be the "browser" object you pass to get the start of the objects you want.  No need to load another instance.

You'll find the form (refer to _IEFormGetObjByName in the help file) using debug bar (drag the green icon at the top over to the object you want to work with), once you have that, you'll get the "id/name/class/etc" from the actual object, and use either one of the IEForm* functions (again, in the help file) or some other function if it's a unique type of object not listed in the _IEForm* functions.

With what you've provided, this is more than enough for you to do homework on and create a working example.

As a word of advice, post working code.  "Put url here" does nothing to help you to help yourself.  If your project is so secretive that you don't want to share a url, then find an alternate website that shares the same type of setup as you're looking to automate.  I doubt anyone here, especially myself, enjoys a guessing game or wasting our time with "maybe this would work" when the issue could be resolved quickly with actual real data.

MSDN can also be used here, these are objects you're working with, if you know VB, then AutoIt should be a breeze.  VB = createObject, Autoit = ObjCreate, they use dot notation, we use dot notation.  Hand in hand.

Our helpfile is probably one of the best out there, with working examples for each of the functions.  Good luck.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

My apologies with the "Put url here". I was in a hurry and the url I placed there were revealing my client's URL :D Thanks so much for clearing this out. My head was literally shaking as I was under the impression that  $oIE is fixated on the first page that IE opened. You also opened up a new door for me with _IELoadWait($oIE). I thought that code never existed lol, this will ensure the scrip runs only when the page is ready. Thanks so much!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I have another question, please bear with me. I am still not able to make this work but probably because my case is complicated. I took a sample website similar to the one I'm having problems with. Please visit this website:

Edited by Wolfiesaxah

Share this post


Link to post
Share on other sites

I don't know what I just did but I was able to solve it. Kinda got frustrated and mixed them all up lol.

I just referenced the iframe then used _IETagNameGetCollection() to get the first instance of "select". Thanks though

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

From your code, $oIE is the main browser object.  That will never change unless you're working in frames or another tab.

 

;)

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I am having trouble grasping that really. Since the website I am working on makes things difficult form e. The objects I need to work with are usually inside a series of sections like Divs, Tables, iFrames that has no names. When I try making changes to an object like putting a check on a checkbox and following the syntax from the samples, it usually fails. I don't now why it's so hard for IE to locate detect the object after specifying it's ID or NAME. I often get NoMatch when the object or control is just sitting there.:s

Share this post


Link to post
Share on other sites

Please let me know how I can delete this post?

Share this post


Link to post
Share on other sites

You can't. It will stay up for everyone to view and may help the next person with a similar issue..

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