Search in sources :

Example 1 with WebDriverActionFactory

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());
}
Also used : WebDriverActionFactory(com.hribol.automation.core.execution.factory.WebDriverActionFactory) PredefinedWebDriverActionFactory(com.hribol.automation.core.execution.factory.PredefinedWebDriverActionFactory) PredefinedWebDriverActionFactory(com.hribol.automation.core.execution.factory.PredefinedWebDriverActionFactory) ReplayBrowserConfiguration(com.hribol.automation.replay.ReplayBrowserConfiguration) Test(org.junit.Test)

Example 2 with WebDriverActionFactory

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());
}
Also used : TestCaseToApplicationActionConverter(com.hribol.automation.core.execution.application.TestCaseToApplicationActionConverter) HashMap(java.util.HashMap) WebDriverActionFactory(com.hribol.automation.core.execution.factory.WebDriverActionFactory) ParameterConfiguration(com.hribol.automation.core.config.ParameterConfiguration) WebDriverAction(com.hribol.automation.core.actions.WebDriverAction) ApplicationAction(com.hribol.automation.core.execution.application.ApplicationAction) ApplicationActionConfiguration(com.hribol.automation.core.config.ApplicationActionConfiguration) WebDriverActionConfiguration(com.hribol.automation.core.config.WebDriverActionConfiguration) Test(org.junit.Test)

Example 3 with WebDriverActionFactory

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

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());
}
Also used : HashMap(java.util.HashMap) WebDriverActionFactory(com.hribol.automation.core.execution.factory.WebDriverActionFactory) PredefinedWebDriverActionFactory(com.hribol.automation.core.execution.factory.PredefinedWebDriverActionFactory) PredefinedWebDriverActionFactory(com.hribol.automation.core.execution.factory.PredefinedWebDriverActionFactory) WebDriverAction(com.hribol.automation.core.actions.WebDriverAction) Test(org.junit.Test)

Example 5 with WebDriverActionFactory

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();
    }
}
Also used : WebDriverActionFactory(com.hribol.automation.core.execution.factory.WebDriverActionFactory) PredefinedWebDriverActionFactory(com.hribol.automation.core.execution.factory.PredefinedWebDriverActionFactory) PredefinedWebDriverActionFactory(com.hribol.automation.core.execution.factory.PredefinedWebDriverActionFactory) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException)

Aggregations

WebDriverActionFactory (com.hribol.automation.core.execution.factory.WebDriverActionFactory)5 Test (org.junit.Test)4 PredefinedWebDriverActionFactory (com.hribol.automation.core.execution.factory.PredefinedWebDriverActionFactory)3 WebDriverAction (com.hribol.automation.core.actions.WebDriverAction)2 HashMap (java.util.HashMap)2 ApplicationActionConfiguration (com.hribol.automation.core.config.ApplicationActionConfiguration)1 ApplicationConfiguration (com.hribol.automation.core.config.ApplicationConfiguration)1 ParameterConfiguration (com.hribol.automation.core.config.ParameterConfiguration)1 WebDriverActionConfiguration (com.hribol.automation.core.config.WebDriverActionConfiguration)1 ApplicationAction (com.hribol.automation.core.execution.application.ApplicationAction)1 ApplicationActionFactory (com.hribol.automation.core.execution.application.ApplicationActionFactory)1 DefaultApplicationActionFactory (com.hribol.automation.core.execution.application.DefaultApplicationActionFactory)1 TestCaseToApplicationActionConverter (com.hribol.automation.core.execution.application.TestCaseToApplicationActionConverter)1 ReplayBrowserConfiguration (com.hribol.automation.replay.ReplayBrowserConfiguration)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1