use of org.openqa.selenium.interactions.Interaction in project flue2ent by DefinityLabs.
the class ActionsPluginTest method tick_withInteraction_callsTick.
@Test
public void tick_withInteraction_callsTick() throws Exception {
Interaction interaction = mock(Interaction.class);
ActionsPlugin actionsPlugin = new ActionsPlugin(driver);
actionsPlugin.tick(interaction);
verify(actions).tick(interaction);
}
use of org.openqa.selenium.interactions.Interaction 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.Interaction in project seleniumRobot by bhecquet.
the class CompositeActions method updateWindowHandles.
/**
* Analyse action list and determine if a clic action occured. If it's the case, update window handles
* @param actionsList
* @throws NoSuchFieldException
* @throws IllegalAccessException
*/
private void updateWindowHandles(LinkedList<Interaction> actionsList) throws NoSuchFieldException, IllegalAccessException {
Boolean clic = null;
boolean clickRequested = false;
for (Interaction action : actionsList) {
if (action.getClass().getName().contains("PointerInput$PointerPress")) {
Field buttonField = action.getClass().getDeclaredField("button");
buttonField.setAccessible(true);
int button = buttonField.getInt(action);
Field directionField = action.getClass().getDeclaredField("direction");
directionField.setAccessible(true);
String direction = directionField.get(action).toString();
// only left button
if (button != 0) {
clic = null;
continue;
}
// check we have a DOWN -> UP sequence
if ("DOWN".equals(direction) && clic == null) {
clic = true;
} else if (Boolean.TRUE.equals(clic) && "UP".equals(direction)) {
clic = null;
clickRequested = true;
} else {
clic = null;
}
} else {
clic = null;
}
}
if (clickRequested) {
((CustomEventFiringWebDriver) WebUIDriver.getWebDriver(false)).updateWindowsHandles();
}
}
use of org.openqa.selenium.interactions.Interaction in project seleniumRobot by bhecquet.
the class CompositeActions method updateHandlesNewActions.
/**
* Intercept calls to {@link org.openqa.selenium.remote.RemoteWebDriver.perform(Collection<Sequence> actions)} method which handles
* the new way of sending composite actions
* @param joinPoint
* @throws NoSuchFieldException
* @throws SecurityException
* @throws IllegalArgumentException
* @throws IllegalAccessException
*/
@Before("execution(public void org.openqa.selenium.remote.RemoteWebDriver.perform (..))")
public void updateHandlesNewActions(JoinPoint joinPoint) throws NoSuchFieldException, IllegalAccessException {
@SuppressWarnings("unchecked") Collection<Sequence> sequences = (Collection<Sequence>) joinPoint.getArgs()[0];
for (Sequence sequence : sequences) {
Field actionsField = Sequence.class.getDeclaredField("actions");
actionsField.setAccessible(true);
@SuppressWarnings("unchecked") LinkedList<Interaction> actionsList = (LinkedList<Interaction>) actionsField.get(sequence);
updateWindowHandles(actionsList);
}
}
use of org.openqa.selenium.interactions.Interaction 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