简体   繁体   English

我找不到带有 Selenium 的按钮

[英]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.我试过driver.find_element_by_class/css_selector/x_path ,但没有什么可以找到按钮,该按钮不在 iframe 中。 URL is this . URL 就是这个

I'm trying to click the button that shows more Comments.我正在尝试单击显示更多评论的按钮。

Button HTML looks like this:按钮 HTML 如下所示:

<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: select 这个buttonxpath设置为:

//*[text()[contains(.,'View Entire Discussion')]] //*[text()[contains(.,'查看整个讨论')]]

It is looking for text that contains View Entire Discussion or more specific:它正在寻找包含查看整个讨论或更具体的文本:

//button[text()[contains(.,'View Entire Discussion')]] //button[text()[contains(.,'查看整个讨论')]]

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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