use of com.hribol.automation.core.execution.application.ApplicationActionFactory in project selenium_java by sergueik.
the class ReplayBrowserTest method replayInvokesExecutionExecuteMethodOnScreen.
@Test
public void replayInvokesExecutionExecuteMethodOnScreen() throws InterruptedException, IOException, URISyntaxException {
ApplicationActionFactory applicationActionFactory = Mockito.mock(ApplicationActionFactory.class);
TestScenario testScenario = Mockito.mock(TestScenario.class);
WebDriverActionExecution webDriverActionExecution = Mockito.mock(WebDriverActionExecution.class);
LoadingTimes loadingTimes = Mockito.mock(LoadingTimes.class);
Mockito.when(webDriverActionExecution.getLoadingTimes()).thenReturn(loadingTimes);
String screen = ":1";
ReplayBrowser replayBrowser = new ReplayBrowser(applicationActionFactory);
replayBrowser.replayOnScreen(testScenario, webDriverActionExecution, screen);
Mockito.verify(webDriverActionExecution).executeOnScreen(testScenario, screen);
}
use of com.hribol.automation.core.execution.application.ApplicationActionFactory in project selenium_java by sergueik.
the class ReplayBrowserTest method replayFromFileOnScreenInvokesExecutionExecuteMethod.
@Test
public void replayFromFileOnScreenInvokesExecutionExecuteMethod() throws InterruptedException, IOException, URISyntaxException {
ApplicationActionFactory applicationActionFactory = Mockito.mock(ApplicationActionFactory.class);
TestScenario testScenario = Mockito.mock(TestScenario.class);
WebDriverActionExecution webDriverActionExecution = Mockito.mock(WebDriverActionExecution.class);
LoadingTimes loadingTimes = Mockito.mock(LoadingTimes.class);
Mockito.when(webDriverActionExecution.getLoadingTimes()).thenReturn(loadingTimes);
TestScenarioFactory testScenarioFactory = Mockito.mock(TestScenarioFactory.class);
String pathToSerializedTest = "testcase.json";
String screen = ":1";
Mockito.when(testScenarioFactory.createFromFile(applicationActionFactory, pathToSerializedTest)).thenReturn(testScenario);
ReplayBrowser replayBrowser = new ReplayBrowser(applicationActionFactory, testScenarioFactory);
replayBrowser.replayOnScreen(pathToSerializedTest, webDriverActionExecution, screen);
Mockito.verify(webDriverActionExecution).executeOnScreen(testScenario, screen);
}
use of com.hribol.automation.core.execution.application.ApplicationActionFactory in project selenium_java by sergueik.
the class DefaultApplicationActionFactoryTest method canCreatePageLoadingAndOtherActions.
@Test
public void canCreatePageLoadingAndOtherActions() {
String url = "http://tenniskafe.com";
String actionName = "actionName";
ApplicationActionConfiguration applicationActionConfiguration = mock(ApplicationActionConfiguration.class);
when(applicationActionConfiguration.getName()).thenReturn(actionName);
List<ApplicationActionConfiguration> applicationActionConfigurationList = new ArrayList<>();
applicationActionConfigurationList.add(applicationActionConfiguration);
ApplicationConfiguration applicationConfiguration = mock(ApplicationConfiguration.class);
when(applicationConfiguration.getApplicationActionConfigurationList()).thenReturn(applicationActionConfigurationList);
TestCaseToApplicationActionConverter testCaseToApplicationActionConverter = mock(TestCaseToApplicationActionConverter.class);
ApplicationAction applicationAction = mock(ApplicationAction.class);
Map<String, String> testCaseStep = new HashMap<>();
testCaseStep.put("event", actionName);
when(testCaseToApplicationActionConverter.convert(applicationActionConfiguration, testCaseStep)).thenReturn(applicationAction);
ApplicationActionFactory applicationActionFactory = new DefaultApplicationActionFactory(url, applicationConfiguration, testCaseToApplicationActionConverter);
ApplicationAction initialPageLoading = applicationActionFactory.getInitialPageLoading();
assertFalse(initialPageLoading.getPrecondition().isPresent());
assertEquals(applicationAction, applicationActionFactory.create(testCaseStep));
}
use of com.hribol.automation.core.execution.application.ApplicationActionFactory 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.application.ApplicationActionFactory in project selenium_java by sergueik.
the class TestScenarioFactoryTest method canCreateScenarioFromFile.
@Test
public void canCreateScenarioFromFile() throws IOException {
String pathToTestCase = getClass().getResource("/testCase.json").getFile();
WebDriverAction pageLoadingWebDriverAction = mock(WebDriverAction.class);
ApplicationAction initialPageLoading = mock(ApplicationAction.class);
when(initialPageLoading.getWebdriverAction()).thenReturn(Optional.of(pageLoadingWebDriverAction));
ApplicationActionFactory applicationActionFactory = mock(ApplicationActionFactory.class);
when(applicationActionFactory.getInitialPageLoading()).thenReturn(initialPageLoading);
List<Map<String, String>> testCaseSteps = ConfigurationUtils.readSteps(pathToTestCase);
for (Map<String, String> testCaseStep : testCaseSteps) {
ApplicationAction domainSpecificAction = mock(ApplicationAction.class);
String something = "something";
WebDriverAction webDriverAction = mock(WebDriverAction.class);
when(webDriverAction.getName()).thenReturn(something);
when(domainSpecificAction.getWebdriverAction()).thenReturn(Optional.of(webDriverAction));
when(applicationActionFactory.create(testCaseStep)).thenReturn(domainSpecificAction);
}
TestScenarioFactory testScenarioFactory = new TestScenarioFactoryImpl();
TestScenario testScenario = testScenarioFactory.createFromFile(applicationActionFactory, pathToTestCase);
assertEquals(testCaseSteps.size() + 1, testScenario.getActions().size());
}
Aggregations