org.openqa.selenium.Rotatable Java Examples
The following examples show how to use
org.openqa.selenium.Rotatable.
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: WebDriverManager.java From vividus with Apache License 2.0 | 6 votes |
@Override public boolean isOrientation(ScreenOrientation orientation) { if (!isMobile()) { return false; } ScreenOrientation screenOrientation = webDriverManagerContext.getParameter(WebDriverManagerParameter.ORIENTATION); if (screenOrientation == null) { screenOrientation = webDriverProvider.getUnwrapped(Rotatable.class).getOrientation(); webDriverManagerContext.putParameter(WebDriverManagerParameter.ORIENTATION, screenOrientation); } return orientation == screenOrientation; }
Example #2
Source File: WebDriverManagerTests.java From vividus with Apache License 2.0 | 6 votes |
@ParameterizedTest @MethodSource("nativeApplicationViewportProvider") void testGetScreenSizeForPortraitOrientation(ScreenOrientation orientation, Dimension dimension, Dimension viewport) { lenient().when(webDriverProvider.getUnwrapped(MobileDriver.class)).thenReturn(mobileDriver); lenient().when(webDriverProvider.getUnwrapped(Rotatable.class)).thenReturn(mobileDriver); when(mobileDriver.getOrientation()).thenReturn(orientation); when(mobileDriver.getContext()).thenReturn(NATIVE_APP_CONTEXT); WebDriverManager spy = spyIsMobile(true); Options options = mock(Options.class); when(mobileDriver.manage()).thenReturn(options); Window window = mock(Window.class); when(options.window()).thenReturn(window); when(window.getSize()).thenReturn(dimension); assertEquals(viewport, spy.getSize()); verify(webDriverManagerContext).putParameter(WebDriverManagerParameter.SCREEN_SIZE, dimension); }
Example #3
Source File: DefaultSession.java From selenium with Apache License 2.0 | 6 votes |
private Map<String, Object> getDescription(WebDriver instance, Capabilities capabilities) { DesiredCapabilities caps = new DesiredCapabilities(capabilities.asMap()); caps.setJavascriptEnabled(instance instanceof JavascriptExecutor); if (instance instanceof TakesScreenshot) { caps.setCapability(CapabilityType.TAKES_SCREENSHOT, true); } if (instance instanceof LocationContext) { caps.setCapability(CapabilityType.SUPPORTS_LOCATION_CONTEXT, true); } if (instance instanceof ApplicationCache) { caps.setCapability(CapabilityType.SUPPORTS_APPLICATION_CACHE, true); } if (instance instanceof NetworkConnection) { caps.setCapability(CapabilityType.SUPPORTS_NETWORK_CONNECTION, true); } if (instance instanceof WebStorage) { caps.setCapability(CapabilityType.SUPPORTS_WEB_STORAGE, true); } if (instance instanceof Rotatable) { caps.setCapability(CapabilityType.ROTATABLE, true); } if (instance instanceof HasTouchScreen) { caps.setCapability(CapabilityType.HAS_TOUCHSCREEN, true); } return caps.asMap(); }
Example #4
Source File: WebDriverManagerTests.java From vividus with Apache License 2.0 | 5 votes |
@ParameterizedTest @MethodSource("orientationProvider") void testIsOrientation(ScreenOrientation actualOrientation, ScreenOrientation orientationToCheck, String platform) { when(webDriverProvider.getUnwrapped(Rotatable.class)).thenReturn(mobileDriver); when(webDriverManagerContext.getParameter(WebDriverManagerParameter.ORIENTATION)).thenReturn(null); when(mobileDriver.getOrientation()).thenReturn(actualOrientation); mockWebDriverHavingCapabilities(Map.of(CapabilityType.PLATFORM_NAME, platform)); assertEquals(actualOrientation == orientationToCheck, webDriverManager.isOrientation(orientationToCheck)); verify(webDriverManagerContext).putParameter(WebDriverManagerParameter.ORIENTATION, actualOrientation); }
Example #5
Source File: WebDriverManagerTests.java From vividus with Apache License 2.0 | 5 votes |
@Test void testGetNativeApplicationViewportCached() { mockWebDriverHavingCapabilities(Map.of(CapabilityType.PLATFORM_NAME, MobilePlatform.IOS)); when(webDriverProvider.getUnwrapped(Rotatable.class)).thenReturn(mobileDriver); lenient().when(webDriverManagerContext.getParameter(WebDriverManagerParameter.ORIENTATION)).thenReturn(null); when(mobileDriver.getOrientation()).thenReturn(ScreenOrientation.PORTRAIT); Dimension dimension = new Dimension(375, 667); lenient().when(webDriverManagerContext.getParameter(WebDriverManagerParameter.SCREEN_SIZE)) .thenReturn(dimension); Dimension actualDimension = webDriverManager.getSize(); assertEquals(dimension.getHeight(), actualDimension.getHeight()); assertEquals(dimension.getWidth(), actualDimension.getWidth()); verify(this.mobileDriver, never()).manage(); }
Example #6
Source File: AugmenterTest.java From selenium with Apache License 2.0 | 5 votes |
@Test public void shouldBeAbleToAugmentMultipleTimes() { Capabilities caps = new ImmutableCapabilities("canRotate", true, "magic.numbers", true); StubExecutor stubExecutor = new StubExecutor(caps); stubExecutor.expect(DriverCommand.GET_SCREEN_ORIENTATION, Collections.emptyMap(), ScreenOrientation.PORTRAIT.name()); RemoteWebDriver driver = new RemoteWebDriver(stubExecutor, caps); WebDriver augmented = getAugmenter() .addDriverAugmentation( "canRotate", Rotatable.class, (c, exe) -> new RemoteRotatable(exe)) .augment(driver); assertThat(driver).isNotSameAs(augmented); assertThat(augmented).isInstanceOf(Rotatable.class); assertThat(augmented).isNotInstanceOf(HasMagicNumbers.class); WebDriver augmentedAgain = getAugmenter() .addDriverAugmentation( "magic.numbers", HasMagicNumbers.class, (c, exe) -> () -> 42) .augment(augmented); assertThat(augmented).isNotSameAs(augmentedAgain); assertThat(augmentedAgain).isInstanceOf(Rotatable.class); assertThat(augmentedAgain).isInstanceOf(HasMagicNumbers.class); ((Rotatable) augmentedAgain).getOrientation(); // Should not throw. assertThat(((HasCapabilities) augmentedAgain).getCapabilities()) .isSameAs(driver.getCapabilities()); }
Example #7
Source File: WebDriverWrapper.java From bobcat with Apache License 2.0 | 4 votes |
@Override public ScreenOrientation getOrientation() { return ((Rotatable) super.getWrappedDriver()).getOrientation(); }
Example #8
Source File: WebDriverWrapper.java From bobcat with Apache License 2.0 | 4 votes |
@Override public void rotate(DeviceRotation deviceRotation) { ((Rotatable) super.getWrappedDriver()).rotate(deviceRotation); }
Example #9
Source File: WebDriverWrapper.java From bobcat with Apache License 2.0 | 4 votes |
@Override public DeviceRotation rotation() { return ((Rotatable) super.getWrappedDriver()).rotation(); }
Example #10
Source File: WebDriverWrapper.java From bobcat with Apache License 2.0 | 4 votes |
@Override public void rotate(ScreenOrientation screenOrientation) { ((Rotatable) super.getWrappedDriver()).rotate(screenOrientation); }
Example #11
Source File: AddRotatable.java From selenium with Apache License 2.0 | 4 votes |
@Override public Class<Rotatable> getDescribedInterface() { return Rotatable.class; }
Example #12
Source File: AddRotatable.java From selenium with Apache License 2.0 | 4 votes |
@Override public Rotatable getImplementation(Capabilities capabilities, ExecuteMethod executeMethod) { return new RemoteRotatable(executeMethod); }
Example #13
Source File: Rotate.java From selenium with Apache License 2.0 | 4 votes |
@Override public Void call() { ((Rotatable) getUnwrappedDriver()).rotate(orientation); return null; }
Example #14
Source File: GetScreenOrientation.java From selenium with Apache License 2.0 | 4 votes |
@Override public ScreenOrientation call() { return ((Rotatable) getUnwrappedDriver()).getOrientation(); }