Search in sources :

Example 1 with LoadingTimes

use of com.hribol.automation.core.utils.LoadingTimes 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 LoadingTimes

use of com.hribol.automation.core.utils.LoadingTimes 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 LoadingTimes

use of com.hribol.automation.core.utils.LoadingTimes in project selenium_java by sergueik.

the class LoadingTimesTest method loadingTimesDumpsFile.

@Test
public void loadingTimesDumpsFile() throws UnsupportedEncodingException, FileNotFoundException {
    List<Long> loadingMeasurements = new ArrayList<>();
    List<String> actions = new ArrayList<>();
    actions.add("INITIAL_LOADING");
    loadingMeasurements.add(756661733L);
    actions.add("CLICK_ON_BUTTON");
    loadingMeasurements.add(750434651L);
    LoadingTimes loadingTimes = new LoadingTimes(loadingMeasurements, actions);
    String pathname = "loadingTimes.csv";
    File file = new File(pathname);
    loadingTimes.dump(file);
    Assert.assertTrue(file.exists());
    Assert.assertTrue(file.delete());
    loadingTimes.dump(pathname);
    Assert.assertTrue(file.exists());
    Assert.assertTrue(file.delete());
}
Also used : ArrayList(java.util.ArrayList) LoadingTimes(com.hribol.automation.core.utils.LoadingTimes) File(java.io.File) Test(org.junit.Test)

Example 4 with LoadingTimes

use of com.hribol.automation.core.utils.LoadingTimes in project selenium_java by sergueik.

the class ReplayBrowser method replay.

public AutomationResult replay(TestScenario testScenario, WebDriverActionExecution webDriverActionExecution) throws IOException, InterruptedException, URISyntaxException {
    webDriverActionExecution.execute(testScenario);
    LoadingTimes loadingTimes = webDriverActionExecution.getLoadingTimes();
    loadingTimes.dump("example.csv");
    return webDriverActionExecution.getAutomationResult();
}
Also used : LoadingTimes(com.hribol.automation.core.utils.LoadingTimes)

Example 5 with LoadingTimes

use of com.hribol.automation.core.utils.LoadingTimes in project selenium_java by sergueik.

the class WebDriverActionExecutionBase method execute.

@Override
public void execute(TestScenario testScenario) throws InterruptedException, IOException, URISyntaxException {
    prepare();
    long elapsedTime = System.nanoTime();
    try {
        this.automationResult = AutomationResult.EXECUTING;
        while (testScenario.hasMoreSteps()) {
            if (ConfigurationUtils.toSeconds(System.nanoTime() - elapsedTime) > timeout) {
                this.automationResult = AutomationResult.TIMEOUT;
                throw new TimeoutException("Could not execute the action! Waited " + String.valueOf(System.nanoTime() - elapsedTime) + " to do " + testScenario.nextActionName() + " http queries in queue: " + httpRequestQueue.size());
            }
            if (httpRequestQueue.isEmpty() && !lock) {
                lock = testScenario.nextActionExpectsHttpRequest();
                WebDriverAction webDriverAction = testScenario.pollWebdriverAction();
                executeIgnoringExceptions(webDriverAction);
                waitingTimes.add(System.nanoTime() - elapsedTime);
                elapsedTime = System.nanoTime();
            }
        }
        this.automationResult = AutomationResult.SUCCESS;
    } catch (AssertionError e) {
        e.printStackTrace();
        this.automationResult = AutomationResult.ASSERTION_ERROR;
    } finally {
        replaySettings.cleanUpReplay();
    }
    this.loadingTimes = new LoadingTimes(waitingTimes, testScenario.getActions());
}
Also used : LoadingTimes(com.hribol.automation.core.utils.LoadingTimes) TimeoutException(org.openqa.selenium.TimeoutException) WebDriverAction(com.hribol.automation.core.actions.WebDriverAction)

Aggregations

LoadingTimes (com.hribol.automation.core.utils.LoadingTimes)7 Test (org.junit.Test)5 ApplicationActionFactory (com.hribol.automation.core.execution.application.ApplicationActionFactory)4 TestScenario (com.hribol.automation.core.execution.executor.TestScenario)4 ReplayBrowser (com.hribol.automation.replay.ReplayBrowser)4 WebDriverActionExecution (com.hribol.automation.replay.WebDriverActionExecution)4 TestScenarioFactory (com.hribol.automation.core.execution.executor.TestScenarioFactory)2 WebDriverAction (com.hribol.automation.core.actions.WebDriverAction)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 TimeoutException (org.openqa.selenium.TimeoutException)1