Sitemap

Member-only story

Quick Tip: Verify a HyperLink Exists Without Clicking it

How to verify a link without clicking it

2 min readJun 14, 2025

Here is a small test automation task: Verify that the client “Toby Williams” has been soft deleted (i.e. the user has been deleted but it can still be restored).

As a human, we can tell that the client name has a strikethrough (visually) and there is a new blue “Restore” link next to their name.

As part of an automated test, verifying the strikethrough effect (via CSS) might not be the best option. Instead, let’s take a look at how we could verify a soft delete via the Restore link.

Clicking the “Restore” link is not appropriate — we don’t want our test to actually restore the client.

driver.find_element(:id, "restore_client_link").click # no good

Clicking the button might also redirect to another page, breaking out of the testing flow (we might need to continue do something on the same page).

And I don’t want to verify the text ‘Restore’ in the HTML source, which is too generic. The word ‘Restore’ might exist in a paragraph text.

expect(page_source).to include("Restore") # no good

So, how can we verify a hyper link without clicking it? Easy, just check the locator exists.

driver.find_element(:id, "restore_client_link")

--

--

No responses yet