com.version1.webdriver.utils.WindowUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of selenium-java-test-automation Show documentation
Show all versions of selenium-java-test-automation Show documentation
A simple Selenium framework offering externalised configuration, a good selection of libraries for supporting
test data, simple WebDriver browser binary resolution and an opinionated approach for WebDriver test design.
The newest version!
package com.version1.webdriver.utils;
import com.codahale.metrics.Timer;
import com.version1.metrics.MetricRegistryHelper;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import static com.codahale.metrics.MetricRegistry.name;
/**
* Handles window utilities (like scrolling etc)
*/
public final class WindowUtils {
private static final Timer scrollIntoViewAction = MetricRegistryHelper.get().timer(name("WindowUtils.scrollIntoView"));
private WindowUtils() {
throw new IllegalStateException("Utility class");
}
/**
* Scrolls a given element into the Viewport view
* @param webDriver active WebDriver instance
* @param webElement active WebElement, already located
*/
public static void scrollIntoView(WebDriver webDriver, WebElement webElement) {
try(final Timer.Context ignored = scrollIntoViewAction.time()) {
JavaScriptUtils.executeString(webDriver, webElement, "arguments[0].scrollIntoView(true);");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy