我如何找到这个元素?我在python中使用selenium和编码。
这些是元素细节:
Xpath = //*[@id="545711682"]
CSS-selector = #\35 45711682
这是我到目前为止所尝试的:
driver.find_element_by_xpath('//*[@id="545711682"]')
driver.find_element(By.XPATH, '//*[@id="545711682"]')
当我使用elements
代替element
代码时,代码不会失败,但我假设我找到一堆元素而不是一个,这就是为什么它不可点击。
Here is the link,这些是我想要找到的HTML部分:
选择时:
<a href="#" class="lc_rm_a lc_rm_t" data-seq="33526109" id="545711682" onclick="return showBookingForm(this.id,'4705','12:00pm - 12:30pm, Tuesday, June 13, 2017', '30');" style="width: 30px; float:left; display:block;" title="4705, 12:00pm to 12:30pm, Tuesday, June 13, 2017"> </a>
未选择时:
<a href="#" class="lc_rm_a" data-seq="33526109" id="545711682" onclick="return showBookingForm(this.id,'4705','12:00pm - 12:30pm, Tuesday, June 13, 2017', '30');" style="width: 30px; float:left; display:block;" title="4705, 12:00pm to 12:30pm, Tuesday, June 13, 201
7"> </a>
答案 0 :(得分:1)
问题在于,当我寻找它时,元素不存在
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
这就是完成它的代码:
wait.until(EC.presence_of_element_located((By.XPATH, '//*[@id="545711682"]'))).click()