Search in sources :

Example 1 with TestScenarioFactory

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);
}
Also used : ApplicationActionFactory(com.hribol.automation.core.execution.application.ApplicationActionFactory) TestScenario(com.hribol.automation.core.execution.executor.TestScenario) WebDriverActionExecution(com.hribol.automation.replay.WebDriverActionExecution) LoadingTimes(com.hribol.automation.core.utils.LoadingTimes) TestScenarioFactory(com.hribol.automation.core.execution.executor.TestScenarioFactory) ReplayBrowser(com.hribol.automation.replay.ReplayBrowser) Test(org.junit.Test)

Example 2 with TestScenarioFactory

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());
}
Also used : ApplicationAction(com.hribol.automation.core.execution.application.ApplicationAction) TestScenarioFactoryImpl(com.hribol.automation.core.execution.executor.TestScenarioFactoryImpl) ApplicationActionFactory(com.hribol.automation.core.execution.application.ApplicationActionFactory) TestScenario(com.hribol.automation.core.execution.executor.TestScenario) TestScenarioFactory(com.hribol.automation.core.execution.executor.TestScenarioFactory) Map(java.util.Map) WebDriverAction(com.hribol.automation.core.actions.WebDriverAction) Test(org.junit.Test)

Example 3 with TestScenarioFactory

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);
}
Also used : ApplicationActionFactory(com.hribol.automation.core.execution.application.ApplicationActionFactory) TestScenario(com.hribol.automation.core.execution.executor.TestScenario) WebDriverActionExecution(com.hribol.automation.replay.WebDriverActionExecution) LoadingTimes(com.hribol.automation.core.utils.LoadingTimes) TestScenarioFactory(com.hribol.automation.core.execution.executor.TestScenarioFactory) ReplayBrowser(com.hribol.automation.replay.ReplayBrowser) Test(org.junit.Test)

Aggregations

ApplicationActionFactory (com.hribol.automation.core.execution.application.ApplicationActionFactory)3 TestScenario (com.hribol.automation.core.execution.executor.TestScenario)3 TestScenarioFactory (com.hribol.automation.core.execution.executor.TestScenarioFactory)3 Test (org.junit.Test)3 LoadingTimes (com.hribol.automation.core.utils.LoadingTimes)2 ReplayBrowser (com.hribol.automation.replay.ReplayBrowser)2 WebDriverActionExecution (com.hribol.automation.replay.WebDriverActionExecution)2 WebDriverAction (com.hribol.automation.core.actions.WebDriverAction)1 ApplicationAction (com.hribol.automation.core.execution.application.ApplicationAction)1 TestScenarioFactoryImpl (com.hribol.automation.core.execution.executor.TestScenarioFactoryImpl)1 Map (java.util.Map)1