unable to get the default selected value of drop down from selenium

Keywords: java html selenium selenium-webdriver testng

Question: 

Scenario1: I have two fields in the screen district and territory. For some user it has default value selected and the drop down is disabled. PFB code for reference.

    <select id="abcd" name="xyz" class="12234" style="ghfhgfhfh">
      <option class="hide" value="4541ghj" selected="">valley 
          none</option>
    </select>.

I am trying to get the "valley none" as the output if the drop down is disabled.

Scenario 2: I have two fields in the screen district and territory. For some user it has default value selected and the drop down is enabled.

At this time I want to select the option from the drop down now.

For this I am trying to make a common code.

What I am doing now:-

I am making a select type element and them I am trying to get the default value by getfirstselectedvalue() and then saving it in the webelement and then I am doing .gettext(). to get the option selected.

other wise if the null is returned from thr firstselectvalue() function then I am trying to select the value by visible text.

Error:-

if the default value is selected and the drop down is disbaled The getfirstselectedvalue() function is returning null ,if the element type is select but if I make it as webelement and then doing gettext it gives me the value in the field but this cannot be done if the drop down is senabled as at that time the type to element should be select to select the value from enabled drop down. At both the scenario the class is select for the fields

Please help....

Answers: