python - 如何用硒单击表格中的元素?
问题描述
我想选择可用的约会
from selenium import webdriver
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.get("https://vadmvappointments.as.me/schedule.php?calendarID=5322490")
element = driver.find_elements_by_xpath(//*[@id="step-pick-appointment"]/div[2]/div[4]/div[1]/table[2]/tbody/tr[4]/td[2])
element.click()
解决方案
cp的东西...
您的 xpath 缺少将其括起来的双引号...
所以代替这个:
element = driver.find_elements_by_xpath(//*[@id="step-pick-appointment"]/div[2]/div[4]/div[1]/table[2]/tbody/tr[4]/td[2])
用这个:
element = driver.find_elements_by_xpath("//*[@id='step-pick-appointment']/div[2]/div[4]/div[1]/table[2]/tbody/tr[4]/td[2]")
请注意我也更改find_elements_by_xpath
为find_element_by_xpath
,它是单个元素。
但是,您发送的那个链接返回“没有可用的约会”,所以即使xpath
是正确的,它也不会工作
推荐阅读
- google-cloud-platform - 将 PubSub 确认时间增加到 600 秒以上,或者在 pub-sub 中设置火灾并忘记长时间运行的云运行作业
- php - Laravel Validator - 检查是否包含错误键?
- css - 为什么 html_nodes 给出 {xml_nodeset (0)}
- amazon-s3 - 如何使用 Flink 在 EMR 上使用 s3a 文件系统?
- html - 为什么我的导航栏和搜索栏在保持 50% 后不在同一行
- excel - Shape.OnAction 在工作表名称中不包含下划线导致复制工作簿后出错
- java - 实时数据库的 4.7 GB 下载使用量,我在整个数据库中只有 2 个要查询的数字,我做错了什么?
- css - 如何在没有复选框的情况下将 svg 组转换为可单击的复选框(单击时反转颜色以显示选中)
- html - 通过 JSON 发送 base64 音频,如何使用
- python - Can I save the coordinates for a UMAP embedding?