We are using Selenium to test our UI and need to be able to find a reliable way to identify the elements of the page we are working with. I am working with a button and have defined an id to be able to reference it in my tests.
<apex:commandbutton id="new" styleclass="kbutton-white" value="New" action="{!togglePopup}"/>
However, when I load the page and inspect elements on it, I notice the id is shown as something like below:
id="j_id0:SiteTemplate:j_id255:new"
Is there a way to reliably use id to find elements? If not, what other way can I use to reliably find elements on the page UI testing?
I have looked at finding by class but I may have multiple buttons with the same class and different texts and functionalities and I will need to use different class names to identify the buttons which is not good practice.
P.S.: We are testing a managed package and the development org, packaging org, and the test orgs will be different. Not sure if this is relevant.