Java Code Examples for org.openqa.selenium.WebDriver#Options

The following examples show how to use org.openqa.selenium.WebDriver#Options . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebDriverConfigTest.java    From jmeter-plugins-webdriver with Apache License 2.0 5 votes vote down vote up
private WebDriver getBrowserMock() {
    WebDriver.Options manage = mock(WebDriver.Options.class);
    when(manage.window()).thenReturn(mock(WebDriver.Window.class));
    WebDriver browser = mock(WebDriver.class);
    when(browser.manage()).thenReturn(manage);
    return browser;
}
 
Example 2
Source File: ScreenManagerTests.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Tests whether the bView is placed next to the pView when it is at default size.
 */
@Test
public void resizeBview_MinimumPViewSize_AdjacentBView() {
    ScreenManager mockedScreenManager = getMockedScreenManager(200.0, 1600, 1400, 2400);
    WebDriver.Window mockedWindow = mock(WebDriver.Window.class);
    WebDriver.Options mockedManage = getMockedOptions(mockedWindow);

    BrowserComponent testBrowserComponent = new BrowserComponent(null, mockedScreenManager, false);
    testBrowserComponent.setWindowBounds(mockedManage);

    verify(mockedWindow).setPosition(new Point(200, 0));
    verify(mockedWindow).setSize(new Dimension(1400, 2400));
}
 
Example 3
Source File: ScreenManagerTests.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Tests whether the bView is placed next to the pView when the pView is almost at the resize
 * threshold.
 */
@Test
public void resizeBview_MediumPViewSize_AdjacentBView() {
    ScreenManager mockedScreenManager = getMockedScreenManager(1439.0, 1600, 161, 2400);
    WebDriver.Window mockedWindow = mock(WebDriver.Window.class);
    WebDriver.Options mockedManage = getMockedOptions(mockedWindow);

    BrowserComponent testBrowserComponent = new BrowserComponent(null, mockedScreenManager, false);
    testBrowserComponent.setWindowBounds(mockedManage);

    verify(mockedWindow).setPosition(new Point(1439, 0));
    verify(mockedWindow).setSize(new Dimension(161, 2400));
}
 
Example 4
Source File: ScreenManagerTests.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Tests whether the bView is maximised when the pView's size is past the resize threshold.
 */
@Test
public void resizeBview_OversizedPView_MaximiseBView() {
    ScreenManager mockedScreenManager = getMockedScreenManager(1440.0, 1600, 160, 2400);
    WebDriver.Window mockedWindow = mock(WebDriver.Window.class);
    WebDriver.Options mockedManage = getMockedOptions(mockedWindow);

    BrowserComponent testBrowserComponent = new BrowserComponent(null, mockedScreenManager, false);
    testBrowserComponent.setWindowBounds(mockedManage);

    verify(mockedWindow).setPosition(new Point(0, 0));
    verify(mockedWindow).setSize(new Dimension(1600, 2400));
}
 
Example 5
Source File: ScreenManagerTests.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Tests whether the bView is maximised when the pView takes up the entire screen.
 */
@Test
public void resizeBview_FullscreenPView_MaximisedBView() {
    ScreenManager mockedScreenManager = getMockedScreenManager(1600.0, 1600, 0, 2400);
    WebDriver.Window mockedWindow = mock(WebDriver.Window.class);
    WebDriver.Options mockedManage = getMockedOptions(mockedWindow);

    BrowserComponent testBrowserComponent = new BrowserComponent(null, mockedScreenManager, false);
    testBrowserComponent.setWindowBounds(mockedManage);

    verify(mockedWindow).setPosition(new Point(0, 0));
    verify(mockedWindow).setSize(new Dimension(1600, 2400));
}
 
Example 6
Source File: ScreenManagerTests.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Tests whether the bView snaps to the correct position when pView is out of position.
 */
@Test
public void resizeBview_OutOfPositionPView_SnappedBView() {
    ScreenManager mockedScreenManager = getMockedScreenManager(800.0, 1600, 400, 2400);
    WebDriver.Window mockedWindow = mock(WebDriver.Window.class);
    WebDriver.Options mockedManage = getMockedOptions(mockedWindow);

    BrowserComponent testBrowserComponent = new BrowserComponent(null, mockedScreenManager, false);
    testBrowserComponent.setWindowBounds(mockedManage);

    verify(mockedWindow).setPosition(new Point(800, 0));
    verify(mockedWindow).setSize(new Dimension(400, 2400));
}
 
Example 7
Source File: ChromeDriverEx.java    From HubTurbo with GNU Lesser General Public License v3.0 4 votes vote down vote up
public WebDriver.Options manage() {
    return !isTestChromeDriver ? driver.manage() : null;
}
 
Example 8
Source File: ScreenManagerTests.java    From HubTurbo with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Prepares the mocked options object that returns the window object passed in as argument.
 *
 * @param mockedWindow The window object, whose sizes will be set by BrowserComponent.setWindowSize.
 * @return The options object encapsulating the window object to be modified.
 */
private static WebDriver.Options getMockedOptions(WebDriver.Window mockedWindow) {
    WebDriver.Options mockedManage = mock(WebDriver.Options.class);
    when(mockedManage.window()).thenReturn(mockedWindow);
    return mockedManage;
}