Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Selenium将\移动到\元素()。执行()无法移动光标_Python_Selenium - Fatal编程技术网

Python Selenium将\移动到\元素()。执行()无法移动光标

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

我想使用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""");
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元素尝试过,但仍然没有运气