CHAPTER 3

image

Hyperlink

Hyperlinks (or links) are fundamental elements of web pages. As a matter of fact, it is hyperlinks that make the World Wide Web possible. A sample link is shown in Figure 3-1 provided, followed by the HTML source.

9781484217412_Fig03-01.jpg

Figure 3-1. An example of a hyperlink

Click a link by text

Using text is probably the most direct way to click a link in Selenium, as it is what we see on the page.

driver.FindElement(By.LinkText("Recommend ...

Get Selenium WebDriver Recipes in C#, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.