use of com.hribol.automation.core.execution.executor.TestScenarioFactory 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.executor.TestScenarioFactory 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());
}
use of com.hribol.automation.core.execution.executor.TestScenarioFactory in project selenium_java by sergueik.
the class ReplayBrowserTest method replayFromFileInvokesExecutionExecuteMethod.
@Test
public void replayFromFileInvokesExecutionExecuteMethod() 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";
Mockito.when(testScenarioFactory.createFromFile(applicationActionFactory, pathToSerializedTest)).thenReturn(testScenario);
ReplayBrowser replayBrowser = new ReplayBrowser(applicationActionFactory, testScenarioFactory);
replayBrowser.replay(pathToSerializedTest, webDriverActionExecution);
Mockito.verify(webDriverActionExecution).execute(testScenario);
}
Aggregations