-1

How to create Page Object for such element with Reusable Action Method ?

Methods to include:

A method to select an option from list dropdown, example: selectFromList(String option)

enter image description here

enter image description here

0

By looking at the image of markup attached not clears the exact situation, because as per HTML markup it seems an input element and in first image it shows a drop-down. But, you can do something like this as reusable method:

selectFromList(String option) {
   //use xpath or css selector here
   WebElement selectOption = driver.findElement(By.xpath("//table/span/input[@title="+option+"]"))
   selectOption.click()
}
0

You can use the following piece of code.:

 public void selectFromList(String option){
    // Use any locator by which select drop down node could be found
    WebElement element=driver.findElement(By.xpath("//select[@id='select1']"));
    Select select=new Select(element);
    select.selectByVisibleText(option);
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.