简体   繁体   中英

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>

To select this button by 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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM