gpt4 book ai didi

python - 通过 XPath 选择 h2 元素

转载 作者:行者123 更新时间:2023-12-05 01:06:29 27 4
gpt4 key购买 nike

我需要通过 XPath 访问这个元素:

<section class="section">
<div class="help-info">
<div class="container">
<div class="tile tile--bottom">
<h2 class="force--h4">Sorry, xxx could not be found or reached (error code 404) </h2> ==$0

我试过了

wait.until(EC.visibility_of_element_located((By.XPATH, "//h2[text()='Sorry, xxx could not be found or reached (error code 404)']")))

但实际上它并没有看正确的元素。

最佳答案

我尝试了以下 CSS_SELECTOR :

section.section div.container h2

显式等待,例如:

h_ele = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "section.section div.container h2")))
print(h_ele.text)

关于python - 通过 XPath 选择 h2 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69103497/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com