How can we store List in a Hashmap in page factory model?

I am using Selenium and java for Automating some features on my website page. I came across a situation where I need to store List in a hashmap so that can be used for assertion further.

@FindBy(xpath="//img[@class='img']")

public WebElement alertBadge;

public WebElement alertBadge() {

try {

elementDetails.put(alertBadge, "Check alert badge visible");

} catch (Exception e) {

}

return alertBadge;

}

The above code works fine when there is only one WebElement. But when there are List of WebElements, I tried using below code which isn't working:

@FindBy(xpath="//img[@class='img']")

public List alertBadge;

public List alertBadge() {

try {

elementDetails.put(alertBadge, "Alert Badge");

} catch (Exception e) {

}

return alertBadge;

}

I am...

Read More »

By: StackOverFlow - Friday, 9 November

Related Posts