I have this code as a part of a program to practice Cucumber, Xpath and Selenium:
@When("^I select Divany i Kresla from left vertical menu$")
public void i_choose_Divany_i_Kresla_from_left_vertical_menu() {
driver.findElement(By.xpath("//div[@class='top-left-menu']/ul/li/a")).click();
driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
}
It's pretty repetitive in every scenario, everything that actually changes is data I select (which I can move to Examples in .feature file) and xpath which I use to access elements on the page. Is there a way to somehow move this step to a generalized class and set it's xpath from inherited classes?