Selenium WebDriver - hidden select and anchor [duplicate]


Possible Duplicate:

Selenium WebDriver – get options from hidden select

I’m having a big problem with select on one page.


<select name="fw3k_ad_input_et_type_group" class="" 
onchange=" eurotax.change_type_group( this.value ); "
style="display: none; ">
<option value="0"> --- odaberite tip --- </option>
<option value="-1" class="special">> nema mog tipa </option>
<option value="16390">CD</option>
<option value="17605">S</option>
<option value="17636">SE</option>
<a href="" class="fs_item" id="fs_item_0" style=""> --- odaberite tip --- </a>


Select is hidden and a href=”” is visible part that changes its text depending on a selected option.

I really dont know how to manage that. I can get all options with JavascriptExecutor and I can use to view dropdown box but I dont know how to click on some option.

I have tried to use Select class and .getOptions() method but it doesn’t work with hidden select and I cannot change a href=”” text.


Please help me with some example.

  • You must to post comments

1st way:
it is not the problem to click any element using the same js. As you know how to get any option the last actions remaning is to perform a click.
This should work for you:

WebElement hiddenWebElement =driver.findElement(By(..selector of the element....));

2nd way:

String cssSelector= ...//i gave them in your previous question
JavascriptExecutor js = (JavascriptExecutor) driver;
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("var x = $(\'"+cssSelector+"\');");

3rd way:
using actions builder, advanced user actions API. You can read about it here
And code will be smth like that:

WebElement mnuElement;
WebElement submnuElement;
mnEle = driver.findElement(By.Id("mnEle")).click();
sbEle = driver.findElement(By.Id("sbEle")).click();
Actions builder = new Actions(driver);
// Move cursor to the Main Menu Element
// Giving 5 Secs for submenu to be displayed
// Clicking on the Hidden SubMenu

You can also some additional info here
Hope this somehow helps you)

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.