gpt4 book ai didi

python - 无法使用 selenium 单击父级

转载 作者:太空宇宙 更新时间:2023-11-03 14:08:08 27 4
gpt4 key购买 nike

我需要使用 单击此 HTML :

<span title="Klik for at oprette booking" onclick="sende('proc_straks.asp','opret','11-02-2018;1;18;20:00;20:45;0;','','', '046009a83941f411fb90c9790a0c92a8')" style='height:52px;' class='banefelt btn_ledig link '>
<div class='padding5'>
<div>20:00 - 20:45</div>
<div class='clearfix'>
</div>
</div>
</span>

所以我尝试了这个代码:

for i in range(1500):
if driver.find_elements_by_tag_name("div")[i].text == '20:00 - 20:45':
diven = driver.find_elements_by_tag_name("div")[i]
diven.find_element_by_xpath('..').click()

我得到了这个错误:

selenium.common.exceptions.WebDriverException: Message: 
unknown error: Element <span title="Klik for at oprette booking"
onclick="sende('proc_straks.asp','opret',
'10-02-2018;1;18;20:00;20:45;0;','','',
'2e24985c6c1be987e1ab481b1588c28a')" style="height:52px;"
class="banefelt btn_ledig link ">...</span>
is not clickable at point (172, 611).
Other element would receive the click: <p class="cc_message">...</p>e click:

最佳答案

我假设您想单击 span 元素,那么这样做怎么样:

span_list = driver.find_elements_by_tag_name("span")

for span in span_list:

iterate_through_span_list = True

div_list = span.find_elements_by_tag_name("div")

for div in div_list:

if div.text == '20:00 - 20:45':

span.click()

iterate_through_span_list = False

break

if iterate_through_span_list == False:

break

关于python - 无法使用 selenium 单击父级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48714422/

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