Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/289.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
自动运行Yatra.com时无法向下滚动日历(Selenium webdriver使用python)_Python_Selenium_Selenium Webdriver_Webdriver - Fatal编程技术网

自动运行Yatra.com时无法向下滚动日历(Selenium webdriver使用python)

自动运行Yatra.com时无法向下滚动日历(Selenium webdriver使用python),python,selenium,selenium-webdriver,webdriver,Python,Selenium,Selenium Webdriver,Webdriver,我试图自动化Yatra网站,但在选择日历中的值时遇到了问题。我无法向下滚动日历 如果您试图通过向下滚动来定位某个元素,则以下代码将滚动,直到该元素出现在视图中 WebElement element = driver.findElement(By.xpath("//div[@id='PegasusCal-0']//div[@class='cal-body']")); ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIn

我试图自动化Yatra网站,但在选择日历中的值时遇到了问题。我无法向下滚动日历


如果您试图通过向下滚动来定位某个元素,则以下代码将滚动,直到该元素出现在视图中

WebElement element = driver.findElement(By.xpath("//div[@id='PegasusCal-0']//div[@class='cal-body']"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
Thread.sleep(500); 

//do anything you want with the element

您可以在python中这样使用:

element = driver.find_element_by_xpath("your xpath")
driver.execute_script("arguments[0].scrollIntoView();", element)

向他人索要代码时要更加尊重@SaniketA.soni请仔细阅读,写出所需信息,以便他人能够帮助您