Search in sources :

Example 1 with ApplicationActionFactory

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);
}
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) ReplayBrowser(com.hribol.automation.replay.ReplayBrowser) Test(org.junit.Test)

Example 2 with ApplicationActionFactory

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);
}
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 3 with ApplicationActionFactory

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));
}
Also used : ApplicationAction(com.hribol.automation.core.execution.application.ApplicationAction) TestCaseToApplicationActionConverter(com.hribol.automation.core.execution.application.TestCaseToApplicationActionConverter) ApplicationActionConfiguration(com.hribol.automation.core.config.ApplicationActionConfiguration) HashMap(java.util.HashMap) DefaultApplicationActionFactory(com.hribol.automation.core.execution.application.DefaultApplicationActionFactory) ApplicationActionFactory(com.hribol.automation.core.execution.application.ApplicationActionFactory) ArrayList(java.util.ArrayList) DefaultApplicationActionFactory(com.hribol.automation.core.execution.application.DefaultApplicationActionFactory) ApplicationConfiguration(com.hribol.automation.core.config.ApplicationConfiguration) Test(org.junit.Test)

Example 4 with ApplicationActionFactory

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());
}
Also used : WebDriverActionFactory(com.hribol.automation.core.execution.factory.WebDriverActionFactory) DefaultApplicationActionFactory(com.hribol.automation.core.execution.application.DefaultApplicationActionFactory) ApplicationActionFactory(com.hribol.automation.core.execution.application.ApplicationActionFactory) DefaultApplicationActionFactory(com.hribol.automation.core.execution.application.DefaultApplicationActionFactory) ApplicationConfiguration(com.hribol.automation.core.config.ApplicationConfiguration) Test(org.junit.Test)

Example 5 with ApplicationActionFactory

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());
}
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)

Aggregations

ApplicationActionFactory (com.hribol.automation.core.execution.application.ApplicationActionFactory)7 Test (org.junit.Test)7 TestScenario (com.hribol.automation.core.execution.executor.TestScenario)5 LoadingTimes (com.hribol.automation.core.utils.LoadingTimes)4 ReplayBrowser (com.hribol.automation.replay.ReplayBrowser)4 WebDriverActionExecution (com.hribol.automation.replay.WebDriverActionExecution)4 TestScenarioFactory (com.hribol.automation.core.execution.executor.TestScenarioFactory)3 ApplicationConfiguration (com.hribol.automation.core.config.ApplicationConfiguration)2 ApplicationAction (com.hribol.automation.core.execution.application.ApplicationAction)2 DefaultApplicationActionFactory (com.hribol.automation.core.execution.application.DefaultApplicationActionFactory)2 WebDriverAction (com.hribol.automation.core.actions.WebDriverAction)1 ApplicationActionConfiguration (com.hribol.automation.core.config.ApplicationActionConfiguration)1 TestCaseToApplicationActionConverter (com.hribol.automation.core.execution.application.TestCaseToApplicationActionConverter)1 TestScenarioFactoryImpl (com.hribol.automation.core.execution.executor.TestScenarioFactoryImpl)1 WebDriverActionFactory (com.hribol.automation.core.execution.factory.WebDriverActionFactory)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1