'How to fix this HtmlUnit test giving errors

I have a HtmlUnit test on the attached code. When I run the code I get the following error:



Solution 1:[1]

getByXPath

returns a list - you can't cast this to a button. You have to take one element from the list (e.g. the first one) for casting.

Or use

getFirstByXPath

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RBRi