use of com.hribol.automation.core.execution.factory.WebDriverActionFactory in project selenium_java by sergueik.
the class ReplayBrowserConfigurationTest method canCreateConfigurationFromBuilder.
@Test
public void canCreateConfigurationFromBuilder() throws IOException {
WebDriverActionFactory webDriverActionFactory = new PredefinedWebDriverActionFactory();
String url = "http://tenniskafe.com";
String filename = getClass().getResource("/tenniskafe.json").getFile();
ReplayBrowserConfiguration replayBrowserConfiguration = ReplayBrowserConfiguration.builder().url(url).pathToApplicationConfiguration(filename).webdriverActionFactory(webDriverActionFactory).build();
assertNotNull(replayBrowserConfiguration.getReplayBrowser());
}
use of com.hribol.automation.core.execution.factory.WebDriverActionFactory in project selenium_java by sergueik.
the class TestCaseToApplicationActionConverterTest method canCreateCorrectAction.
@Test
public void canCreateCorrectAction() {
String actionType = "CLICK_CLASS_BY_TEXT";
String text = "text";
String ATP = "ATP";
String clickMegaMenu = "clickMegaMenu";
String megaMenuLink = "mega-menu-link";
String initialCollectorClass = "initialCollectorClass";
Map<String, String> testCaseStep = new HashMap<>();
testCaseStep.put(text, ATP);
testCaseStep.put(EVENT, clickMegaMenu);
Map<String, Object> tempMap = new HashMap<>();
tempMap.put(EVENT, clickMegaMenu);
tempMap.put(initialCollectorClass, megaMenuLink);
tempMap.put(EXPECTS_HTTP, false);
tempMap.put(text, ATP);
ParameterConfiguration initialCollectorClassParameterConfiguration = mock(ParameterConfiguration.class);
when(initialCollectorClassParameterConfiguration.getParameterName()).thenReturn(initialCollectorClass);
when(initialCollectorClassParameterConfiguration.isExposed()).thenReturn(false);
when(initialCollectorClassParameterConfiguration.getValue()).thenReturn(megaMenuLink);
ParameterConfiguration textParameterConfiguration = mock(ParameterConfiguration.class);
when(textParameterConfiguration.getParameterName()).thenReturn(text);
when(textParameterConfiguration.isExposed()).thenReturn(true);
when(textParameterConfiguration.getAlias()).thenReturn(text);
WebDriverAction webDriverAction = mock(WebDriverAction.class);
WebDriverActionFactory webDriverActionFactory = mock(WebDriverActionFactory.class);
when(webDriverActionFactory.create(actionType, tempMap)).thenReturn(webDriverAction);
WebDriverActionConfiguration preconditionActionConfiguration = mock(WebDriverActionConfiguration.class);
when(preconditionActionConfiguration.getWebDriverActionType()).thenReturn(NOTHING);
WebDriverActionConfiguration webDriverActionConfiguration = mock(WebDriverActionConfiguration.class);
when(webDriverActionConfiguration.getWebDriverActionType()).thenReturn(actionType);
Map<String, ParameterConfiguration> parameterConfigurationMap = new HashMap<>();
parameterConfigurationMap.put(initialCollectorClass, initialCollectorClassParameterConfiguration);
parameterConfigurationMap.put(text, textParameterConfiguration);
when(webDriverActionConfiguration.getParametersConfiguration()).thenReturn(parameterConfigurationMap);
WebDriverActionConfiguration postconditionActionConfiguration = mock(WebDriverActionConfiguration.class);
when(postconditionActionConfiguration.getWebDriverActionType()).thenReturn(NOTHING);
ApplicationActionConfiguration applicationActionConfiguration = mock(ApplicationActionConfiguration.class);
when(applicationActionConfiguration.getConditionBeforeExecution()).thenReturn(preconditionActionConfiguration);
when(applicationActionConfiguration.getWebDriverAction()).thenReturn(webDriverActionConfiguration);
when(applicationActionConfiguration.getConditionAfterExecution()).thenReturn(postconditionActionConfiguration);
when(applicationActionConfiguration.getName()).thenReturn(clickMegaMenu);
TestCaseToApplicationActionConverter testCaseToApplicationActionConverter = new TestCaseToApplicationActionConverter(webDriverActionFactory);
ApplicationAction applicationAction = testCaseToApplicationActionConverter.convert(applicationActionConfiguration, testCaseStep);
assertFalse(applicationAction.getPrecondition().isPresent());
assertFalse(applicationAction.getPostcondition().isPresent());
assertTrue(applicationAction.getWebdriverAction().isPresent());
assertEquals(webDriverAction, applicationAction.getWebdriverAction().get());
}
use of com.hribol.automation.core.execution.factory.WebDriverActionFactory in project selenium_java by sergueik.
the class DefaultApplicationActionFactoryTest method canCreatePageLoading.
@Test
public void canCreatePageLoading() {
String url = "http://tenniskafe.com";
String applicationName = "tenniskafe";
ApplicationConfiguration applicationConfiguration = mock(ApplicationConfiguration.class);
when(applicationConfiguration.getApplicationName()).thenReturn(applicationName);
WebDriverActionFactory webDriverActionFactory = mock(WebDriverActionFactory.class);
ApplicationActionFactory applicationActionFactory = new DefaultApplicationActionFactory(url, applicationConfiguration, webDriverActionFactory);
assertFalse(applicationActionFactory.getInitialPageLoading().getPrecondition().isPresent());
assertFalse(applicationActionFactory.getInitialPageLoading().getPostcondition().isPresent());
}
use of com.hribol.automation.core.execution.factory.WebDriverActionFactory in project selenium_java by sergueik.
the class PredefinedWebDriverActionFactoryTest method canCreateClickByText.
@Test
public void canCreateClickByText() {
WebDriverActionFactory factory = new PredefinedWebDriverActionFactory();
Map<String, Object> map = new HashMap<>();
map.put("initialCollectorClass", "mega-menu-click");
map.put("text", "ATP");
map.put("event", "clickMegaMenu");
map.put("expectsHttp", true);
WebDriverAction webDriverAction = factory.create("CLICK_CLASS_BY_TEXT", map);
assertEquals("clickMegaMenu", webDriverAction.getName());
}
use of com.hribol.automation.core.execution.factory.WebDriverActionFactory in project selenium_java by sergueik.
the class ReplayCommand method run.
@Override
public void run() {
try {
WebDriverActionFactory factory = new PredefinedWebDriverActionFactory();
WebDriverActionExecutor executor = new WebDriverActionExecutor().pathToDriverExecutable(pathToChromedriver).baseURI("http://www.tenniskafe.com/").timeoutInSeconds(20).measurementsPrecisionInMilliseconds(500);
ReplayBrowserConfiguration replayBrowserConfiguration = ReplayBrowserConfiguration.builder().pathToApplicationConfiguration(pathToApplicationConfiguration).url("http://www.tenniskafe.com/").webdriverActionFactory(factory).build();
WebDriverActionExecution execution = new ChromeDriverActionExecution(executor);
ReplayBrowser replayBrowser = replayBrowserConfiguration.getReplayBrowser();
replayBrowser.replay(pathToSerializedTest, execution);
} catch (IOException | InterruptedException | URISyntaxException e) {
e.printStackTrace();
}
}
Aggregations