akram
akram

Reputation: 517

How to click a link in Selenium using Ruby?

I have some links that are not buttons, each row of the table result has one link called View :

<a class="view-link" aria-label="View" href="/applicant_submissions/8">
                <i aria-hidden="true" title="View" class="glyphicon glyphicon-folder-open icon-spacing"></i>

Can you please show me how to use Selenium using Ruby to click on this link?

Upvotes: 1

Views: 1377

Answers (2)

Ratmir Asanov
Ratmir Asanov

Reputation: 6459

Use this code:

driver.find_element(:class, "view-link").click

Upvotes: 2

iamsankalp89
iamsankalp89

Reputation: 4739

I don't know Ruby so, please, find my solution in Python.

You can use these locators:

Using class name:

driver.find_element_by_class_name('view-link').click

Or

Using XPath:

 driver.find_element_by_xpath("//a[@href="/applicant_submissions/8']").click

Upvotes: 0

Related Questions