Get all options of a select Tag

Ask general questions here.
riccardo77
Posts: 4
Joined: Mon Aug 13, 2018 8:01 am

Get all options of a select Tag

Post by riccardo77 » Mon Aug 13, 2018 8:03 am

I struggle with a select tag

The amount of options is not fix and I would like to read out all possible options (TagValue) into an Array. Any ideas how to do that?

McTurtle
Posts: 191
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: Get all options of a select Tag

Post by McTurtle » Mon Aug 13, 2018 1:27 pm

Hi riccardo77,

Would the followign approach work for you?
         //Gets SelectTag
         SelectTag tag = (SelectTag)Element.FromPath("/dom//iframe[#'iframeResult']/?/?/select");   	
        	tag.Click(); 																				//Open SelectTag by cilcking on it
        	var all_options = tag.FindChildren<OptionTag>();											//Gets all children
        		
        	foreach (var option in all_options)															//Do something for each of them
        	{
        		option.MoveTo();
        	}
Change RanoreXPath ofc... Or better even, use an element form the repository.

Regards,
McTurtle

riccardo77
Posts: 4
Joined: Mon Aug 13, 2018 8:01 am

Re: Get all options of a select Tag

Post by riccardo77 » Thu Aug 16, 2018 12:46 pm

Thanks for your answer, works perfect