As per the HTML
you have shared you may/maynot have been able to get the Apple text within the span element with :
@FindBy(className = "ui-cell-data")
WebElement customerName;
Your code was nearly perfect but the trailing part in the className
as :Samsung
was unnecessary.
But again, looking at the class
attribute it is expected that a couple of more <span>
tags will have the same class
. So to uniquely identify the intended WebElement
we need to refer to a parent node and follow its decendents to reach this particular node.
Finally, with the given HTML
the following code block will be much cleaner :