我想刮:
我的Selenium代码点击“发现我的尺寸”,然后进入身高和体重点击下一步按钮移动到下一页。然后点击腹部形状和臀部形状的框架出现。它需要单击相关的范围,然后移到下一步。我无法使用以下代码单击它:
if "straighter" in str(df_temp['hshape']):
print("here hshapeeeeeeeeee")
xpath="/html/body/div[9]/div[3]/div/div[2]/div[1]/div/div/div[3]/div/div/ul/li[1]/span/img"
straighter = WebDriverWait(driver, 30).until(EC.element_to_be_clickable((By.XPATH, xpath))).click()
与此类似的是,我的代码单击肚皮形状,效果很好:
if "flatter" in str(df_temp['bshape']):
xpath="/html/body/div[9]/div[3]/div/div[2]/div[1]/div/div/div[3]/div/div/ul/li[1]/span"
flatter = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, xpath)))
driver.execute_script("arguments[0].click();", flatter)
也不会引发任何异常。只有出口
编辑:演练:
如果您想快速解决问题,请尝试:
我建议使用xpath,它不依赖于确切的位置,而是通过特定的元素属性来标识其目标。在本例中,它将使用元素的文本。你知道吗
然而,文本并不总是一个可靠的因素,尤其是在多语言网站上。或者,您可以尝试以下方法:
相关问题 更多 >
编程相关推荐