0

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.

1
  • Please Keep the complete <a> tag ! Commented May 13, 2016 at 8:52

1 Answer 1

1

Hope this one might help you solve the issue

find_element_by_link_text('Yellow')

Happy Coding :)

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you! I guess I haven't fully understood the find_ methods yet. link_text works perfectly.
Happens Sometimes... Cheers !! :)

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.