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