use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestWebUIDriver method testDriverCreationWithBrowserMob.
@Test(groups = { "ut" })
public void testDriverCreationWithBrowserMob() {
SeleniumTestsContextManager.getThreadContext().setCaptureNetwork(true);
SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
WebDriver driver = WebUIDriver.getWebDriver(true);
Assert.assertTrue(driver instanceof CustomEventFiringWebDriver);
WebUIDriver uiDriver = WebUIDriver.getWebUIDriver(false);
Assert.assertNotNull(uiDriver.getConfig().getBrowserMobProxy());
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestWebUIDriver method testDriverCreation.
/**
* When driver is created, no Neoload driver is instanciated if neoload parameters are not set
*/
@Test(groups = { "ut" })
public void testDriverCreation() {
SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
WebDriver driver = WebUIDriver.getWebDriver(true);
Assert.assertTrue(driver instanceof CustomEventFiringWebDriver);
Assert.assertNull(((CustomEventFiringWebDriver) driver).getNeoloadDriver());
Capabilities caps = ((CustomEventFiringWebDriver) driver).getInternalCapabilities();
Assert.assertNotNull(caps.getCapability(DriverUsage.START_TIME));
Assert.assertNotNull(caps.getCapability(DriverUsage.STARTUP_DURATION));
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class TestActions method init.
@BeforeMethod(groups = { "ut" })
private void init() throws WebDriverException, IOException {
SeleniumTestsContextManager.getGlobalContext().setCucumberImplementationPackage("com.seleniumtests.ut.core.runner.cucumber");
// mimic sub elements of the HtmlElement
List<WebElement> subElList = new ArrayList<WebElement>();
subElList.add(subElement1);
subElList.add(subElement2);
// list of elements correspond
List<WebElement> elList = new ArrayList<WebElement>();
elList.add(element);
// add DriverExceptionListener to reproduce driver behavior
eventDriver = spy(new CustomEventFiringWebDriver(driver).register(new DriverExceptionListener()));
PowerMockito.mockStatic(WebUIDriver.class);
when(WebUIDriver.getWebDriver(anyBoolean())).thenReturn(eventDriver);
when(WebUIDriver.getWebDriver(anyBoolean(), any(BrowserType.class), isNull(), isNull())).thenReturn(eventDriver);
when(WebUIDriver.getWebUIDriver(anyBoolean())).thenReturn(uiDriver);
when(driver.navigate()).thenReturn(navigation);
when(driver.switchTo()).thenReturn(locator);
when(eventDriver.switchTo()).thenReturn(locator);
SeleniumTestsContextManager.getThreadContext().setTestType(TestType.WEB);
SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class HtmlElement method enterFrame.
/**
* Method for going into the right frame before doing anything else this method
* should be called each time we need to get an element Therefore, it's used
* inside findElement() method
*/
private void enterFrame() {
List<FrameElement> frameTree = new ArrayList<>();
FrameElement frame = getFrameElement();
while (frame != null) {
frameTree.add(0, frame);
frame = frame.getFrameElement();
}
for (FrameElement frameEl : frameTree) {
Integer idx = frameEl.getElementIndex() == null ? 0 : frameEl.getElementIndex();
WebElement frameWebElement;
try {
frameWebElement = getDriver().findElements(frameEl.getBy()).get(idx);
} catch (IndexOutOfBoundsException e) {
throw new NoSuchFrameException(String.format("Frame %s with index %d has not been found", frameEl, idx));
}
((CustomEventFiringWebDriver) getDriver()).scrollToElement(frameWebElement, -20);
getDriver().switchTo().frame(frameWebElement);
}
}
use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.
the class PictureElement method isDriverCreated.
private WebUIDriver isDriverCreated() {
WebUIDriver uiDriver = WebUIDriver.getWebUIDriver(false);
if (uiDriver == null) {
throw new ScenarioException("Driver has not already been created");
}
CustomEventFiringWebDriver driver = (CustomEventFiringWebDriver) uiDriver.getDriver();
if (driver == null) {
throw new ScenarioException("Driver has not already been created");
}
return uiDriver;
}
Aggregations