答案 0 :(得分:0)
如果您尝试通过向下滚动来查找某个元素,则以下代码将滚动,直到该元素处于视图中。
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
答案 1 :(得分:0)
You can use like this in python:
element = driver.find_element_by_xpath("your xpath")
driver.execute_script("arguments[0].scrollIntoView();", element)