[英]Unable to scroll down the calendar while automate the Yatra.com (Selenium webdriver using python)
If you are trying to locate some element by scrolling down, the following code will scroll until the element is in view.如果您试图通过向下滚动来定位某个元素,以下代码将滚动直到该元素出现在视图中。
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
You can use like this in python:你可以在 python 中这样使用:
element = driver.find_element_by_xpath("your xpath")
driver.execute_script("arguments[0].scrollIntoView();", element)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.