在python中找到Selenium Automation的按钮元素 [英] Find the button element for selenium Automation in python
本文介绍了在python中找到Selenium Automation的按钮元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经检查了元素并获得了以下代码.
此按钮激活"(Activate).每4小时仅出现一次.要运行该过程,我需要找到此元素.
I have inspected the element and got the following code.
This button "Activate" appears only once in 4 hours. To run the process I need to find this element.
我尝试使用:
-
find_element_by_class_name
-
find_element_by_link_text
<div class="wrapper">
<button class="w-full h-14 pt-2 pb-1 px-3 bg-accent text-dark-1 rounded-full md:rounded select-none cursor-pointer md:hover:shadow-big focus:outline-none md:focus:bg-accent-2 md:focus:shadow-small ">
<div class="font-medium">
<div class="text-17 md:text-18 md:font-bold leading-18">Activate</div>
<div class="text-13 md:text-12 font-normal md:font-medium leading-normal">to run process</div></div>
</button>
</div>
推荐答案
这应该搜索并刷新页面,直到弹出一个元素.
This should search and refresh a page until an element popsup.
wait = WebDriverWait(driver, 30)
while True:
try:
wait.until(EC.presence_of_element_located((By.XPATH,"//div[@class='wrapper']/div[.='Activate']")))
break
except:
driver.refresh()
导入
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
这篇关于在python中找到Selenium Automation的按钮元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文