Python Selenium将\移动到\元素()。执行()无法移动光标
我想使用selenium向下滚动这个网页,但是该网站被分成两个屏幕,左侧是结果列表,右侧是地图 要从左侧向下滚动到底部,光标必须位于结果区域内 所以我在这里尝试了perform(),xpath指向其中一个结果,但它不起作用:Python Selenium将\移动到\元素()。执行()无法移动光标,python,selenium,Python,Selenium,我想使用selenium向下滚动这个网页,但是该网站被分成两个屏幕,左侧是结果列表,右侧是地图 要从左侧向下滚动到底部,光标必须位于结果区域内 所以我在这里尝试了perform(),xpath指向其中一个结果,但它不起作用: hover = ActionChains(driver); Elem_to_hover = driver.find_element_by_xpath("""//*[@id="js-map-search-result-list"]/li[1]/p/a/img"""); hov
hover = ActionChains(driver);
Elem_to_hover = driver.find_element_by_xpath("""//*[@id="js-map-search-result-list"]/li[1]/p/a/img""");
hover.move_to_element(Elem_to_hover);
hover.perform();
因此,当页面中有多个相同元素时,selenium无法使用perform()
然后我尝试使用指向结果显示区域的xpath,但仍然不起作用
hover = ActionChains(driver);
Elem_to_hover = driver.find_element_by_xpath("""//*[@id="js-map-search-result-list"]""");
hover.move_to_element(Elem_to_hover);
hover.perform();
你可以试试
driver.findElement(By.id("js-item-count-upside")).click();
WebElement element = driver.findElement(By.xpath("//*[@id='js-map-search-result-list']/li[1]/p/a/img"));
driver.executeScript("arguments[0].scrollIntoView()", element);
在调用方法
Elem\u to\u hover=driver之前,确保元素可见。通过\u xpath(“”/*[@id=“js map search result list”]”)查找\u元素代码>尝试过,但仍然没有运气