1

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?

0

2 Answers 2

2

Use this code:

driver.find_element(:class, "view-link").click
Sign up to request clarification or add additional context in comments.

6 Comments

Thanks, is there anyway to click the first or second or any nth link ? Thanks,
@akram, if you have several links with the same class name -- you should use lists and find_elements-method. After that get the appropriate link by using the index in the list.
did you mean : driver.find_element(:class, "view-link")[0].click
@akram, yes, but you should use find_elements-method for that.
Thanks, it's working, I have another question, for the login script I am hard coding the username and password, is there any way to read them from a file instead ? Thanks.
|
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.