Sign in to follow this  
Followers 0
john_qa

Get the innertext of an option from a select control in IE

7 posts in this topic

Hello,

I'm trying to develop a script that records the actions made in a web page and I have problems in getting the innertext of the selected option from a SELECT tag.

Example source code from the Preferences page of Google:

<select name=hl><option value=af>Afrikaans <option value=sq>Albanian <option value=am>Amharic.....

For this code I'am trying to retriev if I select "Afrikaans" from the list, a line like this:

Browser('title:=Google.....').Select('name:=hl').Set 'Afrikaans'

I can't retrieve the 'Afrikaans' text, but i can retrieve the value of the option(in this case 'af')

My source code looks like this:

Browser('title:=$oie.document.title').Select('name:=$oElement.name').Set $oElement.value

$oElement.innertext returns nothing

Do you have any ideeas of how can I get the required text?

Thanks


Don't be afraid of tomorrow, because today is the day you were afraid yesterday.

Share this post


Link to post
Share on other sites



I do hope you have used $oElement.innerText

Well my first post contained an error: $oElement.innerText didn't returned nothing. In fact it returned the list of all options, like this: AfrikaansAlbanianAmharicArabicArmenianAzerbaijaniBasqueBelarusianBengaliBihariBork, bork, bork!BosnianBretonBulgarianCambodianCatalanChinese (Simplified)Chinese (Traditional)CorsicanCroatianCzechDanishDutchElmer FuddEnglishEsperantoEstonianFaroeseFilipinoFinnishFrenchFrisianGalicianGeorgianGermanGreekGuaraniGuj

arati.....


Don't be afraid of tomorrow, because today is the day you were afraid yesterday.

Share this post


Link to post
Share on other sites

Can you use more words to explain what you are trying to do and show some example code how you are trying to accomplish it?

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

Can you use more words to explain what you are trying to do and show some example code how you are trying to accomplish it?

Dale

My script starts from another one, from this forum(I don't remember who post it, or the title of the post)..

ie_events.au3


Don't be afraid of tomorrow, because today is the day you were afraid yesterday.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

You need the text of the selected option: $oElement.options($oElement.selectedIndex).text

Dale

Edit: Note, if the select object allow multiple selections, this method will only return the first item. To get multiple items you must iterate through the options collection items and check the "selected" property of each.

P.S. I spent about 15 minutes downloading and pouring through your code to to figure out it's flow and about 30 seconds providing the answer. I truely would have appreciated a more focused descriiption and code snippet.

Edited by DaleHohm

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

Thank you very much for the provided solution, and I'm sorry I wasn't able to provide focused description.


Don't be afraid of tomorrow, because today is the day you were afraid yesterday.

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