I am trying to use Selenium WebDriver to click a button that has the following HTML code:
<a class="uir-item-edit" href="/app/accounting/transactions/transaction.nl?id=400000&e=T"
id="edit_/app/accounting/transactions/transaction.nl?id=400000"
aria-label="Edit Sales Order:300000 / 400000 ">Edit</a>
My code:
driver.findElement(By.cssSelector("a[aria-label *= 'Edit Sales Order']")).click();
I need to identify by the Aria Label as all the other components either have duplicates or change w/ the number.
There must be something wrong with my CSS selector, but I can't figure it out.
Let me know if I should include the error codes, more info, or if I did something incorrect w/ the post. Thanks!
Edit: the aria label also changes and the location on the HTML also changes so I can't use xpath. DebanJanB's answer below clicks the element, but only when I manually hover over.
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("a.uir-item-edit[aria-label^='Edit Sales Order'][id*='transactions']"))).click();