我正在尝试在不同的div类TopBox上执行单击。我尝试了以下代码,但没有执行单击:
driver.find_element_by_css_selector('#home > div > div.row.topBoxs > div.col-xs-12.col-lg-10 > div > div:nth-child(1) > div').click()
而且:
driver.find_element_by_xpath('//*[@id="home"]/div/div[2]/div[1]/div/div[1]').click()
这是你必须做的
首先,检查您是否能够找到元素。如果不是,则以下行应为抛出错误:
或者,也请尝试使用此xpath
等待该元素,直到其可单击为止
然后尝试使用单击元素。单击()
请让我知道您的观察结果,这将有助于排除故障
尝试使用
xpath
而不是css_selector
相关问题 更多 >
编程相关推荐