I am trying to locate a buttons element, but every time my test run the element keeps on changing name. The class keeps changing the last digits. For Example, jss2383 to jss4132 as well as all elements within the button class. My alternative solution is by using the xpath to find it by text.
<div class="jss2383">
<button class="MuiButtonBase-root-2225 MuiButton-root-2198 MuiButton-contained-2206 MuiButton-containedPrimary-2207" tabindex="0" type="button">
<span class="MuiButton-label-2199">Refresh</span>
<span class="MuiTouchRipple-root-2395"></span>
</button>
</div>
What I have so far to find the element is the following. The reason I want to locate the element by class name is because the button can either be a refresh or an import.
@FindBy(xpath="//span[text()='Refresh']")
WebElement refreshButton;