6
votes

I need to set value to primefaces or JSF selectOneMenu using webdriver.

I am able to achieve this using index but could not set value directly.

The following code is working with Index:

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

Could anybody please suggest a way to achieve setting value to selectonemenu using Selenium webdriver?

1

1 Answers

3
votes

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

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