如何向上滚动到一个元素并单击硒?
How to scroll UP to an element and click in selenium?
我有一个场景,系统需要向上滚动到页面左侧面板中的网络元素,然后单击以执行其他 operations.I 已经尝试了以下方法,但 none 其中 working.Please 建议:
1.
WebElement element = driver.findElement(By.xpath("element"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
Thread.sleep(500);
2.
WebElement element = driver.findElement(By.xpath("element"));
Actions actions = new Actions(driver);
actions.moveToElement(ele);
actions.perform();
Up 或 Down 到 scrollIntoView()
一个元素你必须诱导 WebDriverWait 对于 visibilityOfElementLocated()
,您可以使用以下解决方案:
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("element"))));
我有一个场景,系统需要向上滚动到页面左侧面板中的网络元素,然后单击以执行其他 operations.I 已经尝试了以下方法,但 none 其中 working.Please 建议:
1.
WebElement element = driver.findElement(By.xpath("element"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
Thread.sleep(500);
2.
WebElement element = driver.findElement(By.xpath("element"));
Actions actions = new Actions(driver);
actions.moveToElement(ele);
actions.perform();
Up 或 Down 到 scrollIntoView()
一个元素你必须诱导 WebDriverWait 对于 visibilityOfElementLocated()
,您可以使用以下解决方案:
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", new WebDriverWait(driver, 20).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("element"))));