Looking for a unique link in a dynamic table
Each row in the table expands to reveal more information when clicked. However, since the rows and IDs are constantly changing, finding a specific link by its text is challenging without using xpath.
Attempts with JavascriptExecutor have been unsuccessful, as clicking on the link by text without xpath or css-selector has proven difficult. Additionally, narrowing down the search to a specific table on the page poses another challenge, especially if there are multiple links with the same name.
One approach involved creating a collection of all rows in the table:
WebElement table = $("table locator");
List<WebElement> allRows = table.findElements(By.tagName("tr"));
for(int i=1;i<allRows.size();i++) {
WebElement table1 = $("table locator");
List<WebElement> allRows1 = table1.findElements(By.tagName("tr"));
allRows1.get(i).findElement(By.linkText("linkText"));
The challenge remains in creating a collection of hidden elements within each row.
Is there a way to find a hidden link strictly by its text without an absolute path? Can the DOM be iterated through by link name alone, or is a loop that clicks through each row until the link is found the only solution?
PS: Apologies for any language barriers.