我正在尝试使用selenium webdriver for python在Web容器中显示文本。 这是检查元素-
<div style="overflow-x: hidden;">
<div class="view-container" style="flex-direction: row;
transition: all 0s ease 0s; transform: translate(0%, 0px); direction: ltr;
display: flex; will-change: transform;">
<div aria-hidden="false" data-swipeable="true" style="width: 100%; flex-
shrink: 0; overflow: auto;">
<div>
<div class="qs-text">What is the answer to this question?</div>
我希望它显示“此问题的答案是什么”
我正在尝试使用以下内容,但它不会返回任何内容。 -
element = driver.find_element_by_class_name("qs-text").text
print(element)
我尝试了find_element_by_css_selector("qs-text").text
,但这也没有帮助。
你能告诉我我在做什么错
答案 0 :(得分:0)
如何?
element = driver.find_element_by_xpath("//*[contains(@class, 'qs-text') and contains(text(), 'answer')]")
print(element)