Search in sources :

Example 66 with CustomEventFiringWebDriver

use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.

the class TestWebUIDriver method testDriverCreationWithVideo.

@Test(groups = { "ut" })
public void testDriverCreationWithVideo() throws Exception {
    SeleniumTestsContextManager.getThreadContext().setVideoCapture("true");
    SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
    PowerMockito.mockStatic(CustomEventFiringWebDriver.class);
    PowerMockito.doReturn(videoRecorder).when(CustomEventFiringWebDriver.class, "startVideoCapture", eq(DriverMode.LOCAL), eq(null), any(File.class), eq("videoCapture.avi"));
    WebDriver driver = WebUIDriver.getWebDriver(true);
    Assert.assertTrue(driver instanceof CustomEventFiringWebDriver);
    Assert.assertNotNull(WebUIDriver.getVideoRecorder().get());
}
Also used : NLWebDriver(com.neotys.selenium.proxies.NLWebDriver) WebDriver(org.openqa.selenium.WebDriver) CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) File(java.io.File) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 67 with CustomEventFiringWebDriver

use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.

the class TestWebUIDriver method testDriverCreationInGrid.

/**
 * issue #280: check that selectedBrowserInfo is available in grid mode
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testDriverCreationInGrid() throws Exception {
    SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
    SeleniumTestsContextManager.getThreadContext().setWebDriverGrid("http://localhost:4444/wd/hub");
    SeleniumTestsContextManager.getThreadContext().setRunMode("grid");
    // set connector to simulate the driver creation on grid
    SeleniumTestsContextManager.getThreadContext().setSeleniumGridConnectors(Arrays.asList(gridConnector));
    when(gridConnector.getNodeUrl()).thenReturn("http://localhost:5555/");
    whenNew(SeleniumGridDriverFactory.class).withAnyArguments().thenReturn(gridDriverFactory);
    when(gridDriverFactory.createWebDriver()).thenReturn(drv1);
    when(gridDriverFactory.getSelectedBrowserInfo()).thenReturn(new BrowserInfo(BrowserType.HTMLUNIT, "1.1"));
    CustomEventFiringWebDriver ceDriver = (CustomEventFiringWebDriver) WebUIDriver.getWebDriver(true);
    Assert.assertNotNull(ceDriver.getBrowserInfo());
    Assert.assertEquals(ceDriver.getBrowserInfo().getVersion(), "1.1");
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 68 with CustomEventFiringWebDriver

use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.

the class TestWebUIDriver method testCapsOnDriverQuit.

/**
 * Check that usage duration is added on driver quit
 */
@Test(groups = { "ut" })
public void testCapsOnDriverQuit() {
    SeleniumTestsContextManager.getThreadContext().setBrowser("htmlunit");
    CustomEventFiringWebDriver driver = (CustomEventFiringWebDriver) WebUIDriver.getWebDriver(true);
    driver.quit();
    List<DriverUsage> driverUsages = StatisticsStorage.getDriverUsage();
    Assert.assertEquals(driverUsages.size(), 1);
    Assert.assertEquals(driverUsages.get(0).getBrowserName(), "htmlunit");
    Assert.assertTrue(driverUsages.get(0).getDuration() > 0.0);
    Assert.assertNull(driverUsages.get(0).getGridHub());
    Assert.assertNull(driverUsages.get(0).getGridNode());
    Assert.assertTrue(driverUsages.get(0).getStartTime() > 0);
    Assert.assertEquals(driverUsages.get(0).getTestName(), "testCapsOnDriverQuit");
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) DriverUsage(com.seleniumtests.core.StatisticsStorage.DriverUsage) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 69 with CustomEventFiringWebDriver

use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.

the class TestFrameElement method init.

@BeforeMethod(groups = { "ut" })
private void init() {
    SeleniumTestsContextManager.getThreadContext().setBrowser("firefox");
    eventDriver = spy(new CustomEventFiringWebDriver(driver));
    PowerMockito.mockStatic(WebUIDriver.class);
    when(WebUIDriver.getWebDriver(anyBoolean())).thenReturn(eventDriver);
    when(driver.findElement(By.id("el"))).thenReturn(element);
    when(element.findElement(By.id("link"))).thenReturn(link);
    when(element.findElements(By.tagName("tr"))).thenReturn(Arrays.asList(row));
    when(row.findElements(any(By.class))).thenReturn(Arrays.asList(cell));
    when(driver.findElements(By.id("frameId"))).thenReturn(Arrays.asList(frameEl));
    when(driver.findElements(By.id("frameId2"))).thenReturn(Arrays.asList(subFrameEl));
    when(driver.findElements(By.tagName("iframe"))).thenReturn(Arrays.asList(frameEl));
    when(driver.findElements(By.tagName("iframe"))).thenReturn(Arrays.asList(frameEl, frameEl2));
    when(driver.switchTo()).thenReturn(locator);
    doNothing().when(eventDriver).scrollToElement(any(WebElement.class), anyInt());
    when(frameEl.getText()).thenReturn("111");
    when(frameEl2.getText()).thenReturn("222");
    when(element.getSize()).thenReturn(new Dimension(1, 1));
    when(element.isDisplayed()).thenReturn(true);
    when(link.isDisplayed()).thenReturn(true);
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) By(org.openqa.selenium.By) Dimension(org.openqa.selenium.Dimension) WebElement(org.openqa.selenium.WebElement) RemoteWebElement(org.openqa.selenium.remote.RemoteWebElement) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 70 with CustomEventFiringWebDriver

use of com.seleniumtests.driver.CustomEventFiringWebDriver in project seleniumRobot by bhecquet.

the class TestHtmlElement method testPinch.

@Test(groups = { "ut" })
public void testPinch() throws Exception {
    SeleniumTestsContextManager.getThreadContext().setTestType(TestType.APPIUM_WEB_ANDROID);
    SeleniumTestsContextManager.getThreadContext().setPlatform("android");
    when(WebUIDriver.getWebDriver(anyBoolean())).thenReturn(new CustomEventFiringWebDriver(mobileDriver));
    doNothing().when(el).findElement(anyBoolean(), anyBoolean());
    el.setElement(mobileElement);
    el.pinch();
    PowerMockito.verifyPrivate(el, atLeastOnce()).invoke("checkForMobile");
}
Also used : CustomEventFiringWebDriver(com.seleniumtests.driver.CustomEventFiringWebDriver) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

CustomEventFiringWebDriver (com.seleniumtests.driver.CustomEventFiringWebDriver)77 Test (org.testng.annotations.Test)53 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)36 MockitoTest (com.seleniumtests.MockitoTest)35 Dimension (org.openqa.selenium.Dimension)26 WebDriver (org.openqa.selenium.WebDriver)14 GenericDriverTest (com.seleniumtests.GenericDriverTest)12 Point (org.openqa.selenium.Point)12 GenericTest (com.seleniumtests.GenericTest)10 ScenarioException (com.seleniumtests.customexception.ScenarioException)9 WebDriverException (org.openqa.selenium.WebDriverException)7 BeforeMethod (org.testng.annotations.BeforeMethod)7 DriverExceptionListener (com.seleniumtests.driver.DriverExceptionListener)6 SkipException (org.testng.SkipException)6 NLWebDriver (com.neotys.selenium.proxies.NLWebDriver)5 File (java.io.File)5 IOException (java.io.IOException)5 Rectangle (org.openqa.selenium.Rectangle)5 WebElement (org.openqa.selenium.WebElement)5 BrowserInfo (com.seleniumtests.browserfactory.BrowserInfo)4