我正在尝试制作一个selenium脚本(python)来自动添加东西到购物车。
我在之前的帖子中被告知尝试类似的事情:
什么是"班级"或者本网站上尺寸按钮的元素?
我正在使用chrome dev工具,但显然我无法识别正确的选择器,因此我可以使用selenium自动点击尺寸按钮。
答案 0 :(得分:1)
我会在exp-pdp-size-dropdown
类找到它:
size_button = driver.find_element_by_css_selector(".exp-pdp-size-dropdown")
请注意,要打开尺寸下拉列表,您需要将鼠标悬停在该按钮上。您可以通过"driver action chains":
来完成from selenium.webdriver.common.action_chains import ActionChains
actions = ActionChains(driver)
actions.move_to_element(size_button).perform()