Jeremy
Jeremy

Reputation: 2044

Selecting html element tag(?) name selenium python

I am writing a function in python3 using selenium that will click a link given that it matches a provided text, but having trouble figuring out how to do so. The html is as follows:

<a class="name-link" href="/colors/thisOne" </a>

Yellow

I do know how to select the class name "find_element_by_class_name("name-link") but how would I also include the text Yellow as an option as well, so that my if statement would be like:

if 'Yellow' == (variable):
    .click() 

Thank you in advance.

Upvotes: 0

Views: 266

Answers (1)

Strik3r
Strik3r

Reputation: 1057

Hope this one might help you solve the issue

find_element_by_link_text('Yellow')

Happy Coding :)

Upvotes: 1

Related Questions