use of org.openqa.selenium.interactions.PointerInput in project myfaces-tobago by apache.
the class FrontendTest method frontendTest.
/**
* Call every page with a specific *.test.js.
*/
@ParameterizedTest
@MethodSource("standardTestProvider")
void frontendTest(String path, int testNumber, int testSize) throws MalformedURLException, UnknownHostException, UnsupportedEncodingException {
final String timeLeft = getTimeLeft(FrontendTest.startTime, testSize, testNumber);
LOG.info("(" + testNumber + "/" + testSize + " | time left: " + timeLeft + ") - path: " + path);
final String base = path.substring(0, path.length() - 6);
final String url = getTomcatUrl() + "/test.xhtml?base=" + URLEncoder.encode(base, "UTF-8");
WebDriver webDriver = getWebDriver();
webDriver.get(url);
// move the mouse cursor away to avoid issues with CSS :hover event
Actions actions = new Actions(webDriver);
PointerInput pointerInput = new PointerInput(PointerInput.Kind.MOUSE, "default mouse");
Interaction interaction = pointerInput.createPointerMove(Duration.ZERO, PointerInput.Origin.pointer(), 1, 1);
actions.tick(interaction).build().perform();
List<WebElement> results = getJasmineResults(webDriver, path);
parseJasmineResults(results, path);
}
use of org.openqa.selenium.interactions.PointerInput in project seleniumRobot by bhecquet.
the class ReplayAction method updateScrollFlagForElement.
/**
* Updates the scrollToelementBeforeAction flag of HtmlElement for CompositeActions
* Therefore, it looks at origin field of PointerInput$Move CompositeAction and update the flag
* @throws SecurityException
* @throws NoSuchFieldException
* @throws IllegalAccessException
* @throws IllegalArgumentException
*/
private void updateScrollFlagForElement(ProceedingJoinPoint joinPoint, Boolean forcedValue, WebDriverException parentException) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException {
Object actions = joinPoint.getTarget();
// Only the later case is covered here
if (!actions.getClass().toString().contains("BuiltAction")) {
return;
}
Field sequencesField = actions.getClass().getDeclaredField("sequences");
sequencesField.setAccessible(true);
Map<InputSource, Sequence> sequences = (Map<InputSource, Sequence>) sequencesField.get(actions);
for (Sequence sequence : sequences.values()) {
Field actionsField = Sequence.class.getDeclaredField("actions");
actionsField.setAccessible(true);
LinkedList<Interaction> actionsList = (LinkedList<Interaction>) actionsField.get(sequence);
for (Interaction action : actionsList) {
if (action.getClass().getName().contains("PointerInput$Move")) {
Field originField = action.getClass().getDeclaredField("origin");
originField.setAccessible(true);
try {
PointerInput.Origin origin = (PointerInput.Origin) originField.get(action);
// so that it can be treated elsewhere (mainly inside replayHtmlElement())
if (origin.asArg() instanceof HtmlElement) {
HtmlElement element = (HtmlElement) origin.asArg();
if (forcedValue == null) {
if (element.isScrollToElementBeforeAction()) {
element.setScrollToElementBeforeAction(false);
} else {
element.setScrollToElementBeforeAction(true);
}
} else {
element.setScrollToElementBeforeAction(forcedValue);
}
} else if (origin.asArg() instanceof RemoteWebElement && parentException != null) {
throw parentException;
}
} catch (ClassCastException e1) {
// nothing
}
}
}
}
}
Aggregations