Created
July 1, 2014 12:20
-
-
Save dredei/69af2f47b6c36a48fc70 to your computer and use it in GitHub Desktop.
Choose option in select [GeckoFX]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* К примеру, есть такой select | |
<select id="term_id" size="1" name="p_term_in"> | |
<option value="">Select Another Term | |
<option value="201050">Summer 2010 | |
<option value="201010">Spring 2010 | |
<option value="200980">Fall 2009 | |
</select> | |
*/ | |
var options = this._webBrowser.Document.GetNodes( "//select[@id='term_id']//option" ); // выбрали все option select'a с id=term_id | |
var option = options.FirstOrDefault( o => o.TextContent.StartsWith( "Summer 2010" ) ); // ищем первый option, который содержит в себе текст, начинающийся с Summer 2010 | |
if ( option == null ) | |
{ | |
return; | |
} | |
var optionHtml = option as GeckoHtmlElement; | |
if ( optionHtml == null ) | |
{ | |
return; | |
} | |
optionHtml.SetAttribute( "selected", "" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment