I cant locate a button with Selenium

I have tried driver.find_element_by_class/css_selector/x_path, but nothing can locate the button, the button is not in a iframe. URL is this.

I'm trying to click the button that shows more Comments.

Button HTML looks like this:

<button role="button" tabindex="0" class="j9NixHqtN2j8SKHcdJ0om _3t7aUZU2b2KWwDQkfT2eHl _10BQ7pjWbeYP63SAPNS8Ts HNozj_dKjQZ59ZsfEegz8 _2nelDm85zKKmuD94NequP0">View Entire Discussion (5.7k Comments)</button>

Upvotes: 0

Views: 46

Answers (1)

HedgeHog
HedgeHog

Reputation: 25231

To select this buttonby xpath set it to:

//*[text()[contains(.,'View Entire Discussion')]]

It is looking for text that contains View Entire Discussion or more specific:

//button[text()[contains(.,'View Entire Discussion')]]

driver.find_element_by_xpath('//button[text()[contains(.,'View Entire Discussion')]]').click()

Upvotes: 1

Related Questions