我正在使用Selenium Webdriver检查这个特定段落的文本(这里用蓝色突出显示的那个):
但我如何“质疑”这一段呢?在
这就是我正在尝试的(不起作用):
def test_intro_text(self):
"""Test that intro text is expected text"""
container = self.browser.find_element_by_id('visual-17')
hed_dek_wrapper = container.find_element_by_class_name('hed-dek-wrapper')
intro_text = hed_dek_wrapper.findElement('p:nth-of-type(2)')
self.assertIn(
'Over the past 20 years, we have seen an evolution.',
intro_text.text
)
我得到这个错误:AttributeError:'WebElement' object has no attribute 'findElement'
只需使用此css选择器来执行以下操作:
然后使用css选择器找到元素,它将给您第二个p标记。在
^{pr2}$findElement()
不是Python。请尝试下面的方法:相关问题 更多 >
编程相关推荐