我正在尝试使用 Selenium WebDriver 获取文本,这是我的代码。请注意,我不想使用 XPath,因为在我的情况下,每次重新启动网页时都会更改 ID。
我的代码:
text = driver.find_element_by_class_name("current-stage").getText("my text")
HTML:
<span class="current-text" id="yui_3_7_0_4_1389185744113_384">my text</span>
我怎样才能解决这个问题?
原文由 user3121891 发布,翻译遵循 CC BY-SA 4.0 许可协议
你只想要
.text
。然后你可以在你得到它 之后 验证它,不要试图传递你 期望 它应该有的东西。