Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

primefaces selectOneMenu value using Selenium Webdriver+Java

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?

like image 836
Naresh Kavala Avatar asked Sep 10 '12 10:09

Naresh Kavala


1 Answers

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();
like image 89
BalusC Avatar answered Dec 05 '22 23:12

BalusC