I am using Java, Selenium Webdriver and Cucumber for my automation.In my feature file I have below statement :
And add a room '<x>'
The XML code for selecting rooms is shown in below image :
And the xpath is :
//div[@class='room-holder col-xs-6']/div[@class='group-of-rooms col-xs-24']/div/div[@class='list-group-item'][2]
How can I pass the parameter in above xpath in order to select the room?
I have tried using
@FindBy(xpath = "//div[@class='group-of-rooms col-xs-24']/div/div[@class='list-group-item']['+x+']")
public WebElement RoomSelection;
And below method
public void addRoom(String x) {
utils.waitForElements(RoomSelection, KnowsTestContext.timeout, KnowsTestContext.driver);
RoomSelection.click();
}
It always selects the first option. Is there any way to pass parameters defined in my step definition ?