0

Html select tag contains Id. I have used id in relative path and testing in firepath by clicking evaluate button.firepath returns only one matching node but select box is not highlighted. It clearly says that select box wont be handle. I tried in many ways and not helped me. Please find the html tag on below

<select id="myForm:operatingUnit" class="ef-combo-container" style="display:none;" name="myForm:operatingUnit">
<option value="-1">Please Select</option>
<option value="702">Industrial Casualty</option>
<option value="703">General Casualty</option>
<option value="704">Specialty Primary</option>
</select>
<input id="myForm:operatingUnit_input" class="combo-input ui-autocomplete-input" value="Please Select" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true" title="Please Select"/>

Please find the relative xpath on below:
//select[@id='myForm:operatingUnit']

I have used various explict wait statments as well but not working out to overcome from this issue. Please help me to overcome from this problem

Ashok
  • 115
  • 3
  • 8
  • Have you checked if the element is contained in an iframe? Also you can try with the following css: input[id*=myForm][id*=operatingUnit] – lauda Aug 02 '16 at 15:46
  • it is not inside the frame. size is displaying correctly. system.out.println(weblement.getOptions().size) It returns size as 4 – Ashok Aug 02 '16 at 16:02

1 Answers1

1

How Select is suppose to display? In HTML code I can see the css property as:-

style="display:none;"

Due to this property the element isn't displayed on the webpage. Whats the issue here?

If you remove this CSS property the element would be displayed on the webpage and it would be highlighted using the xpath that you have used.

If you want to still interact with the element, you have to modify the css property of the element, below is the code to modify that:-

WebElement element = driver.findElement(By.id("myForm:operatingUnit"));
((JavascriptExecutor)driver).executeScript("arguments[0].setAttribute('style', arguments[1]);", element, "display:unset;");

Once its modified the Select would be displayed and then you can interact with it.

Paras
  • 3,197
  • 2
  • 20
  • 30