简体   繁体   中英

Unable to scroll down the calendar while automate the Yatra.com (Selenium webdriver using python)

I tried to automate the Yatra website but got stuck while selecting the values in the calendar. I am not able to scroll down the calendar.

Website

Image

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM