SelectOneMenu surfaces using Selenium Webdriver + Java

I need to set the value for simple or JSF selectOneMenu using webdriver.

I can achieve this using the index, but I cannot set the value directly.

The following code works with an index:

driver.findElement(By.name("LNSYNDGLP0_SL_CCY_editableInput")).click();
driver.findElement(By.xpath("//div[@id='LNSYNDGLP0_SL_CCY_panel']/ul/li[7]")).click();

Can anyone suggest a way to achieve the value of the selectonemenu parameter using a Selenium web receiver?

+5
source share
1 answer

You can use the selector [text()='item value']in XPath to select an element by its node value.

driver.findElement(By.xpath("//div[@id='LNSYNDGLP0_SL_CCY_panel']/ul/li[text()='item value']")).click();
+3
source

All Articles