类org.openqa.selenium.Rotatable源码实例Demo

下面列出了怎么用org.openqa.selenium.Rotatable的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: vividus   文件: WebDriverManager.java
@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;
}
 
源代码2 项目: vividus   文件: WebDriverManagerTests.java
@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);
}
 
源代码3 项目: selenium   文件: DefaultSession.java
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();
}
 
源代码4 项目: vividus   文件: WebDriverManagerTests.java
@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);
}
 
源代码5 项目: vividus   文件: WebDriverManagerTests.java
@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();
}
 
源代码6 项目: selenium   文件: AugmenterTest.java
@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());
}
 
源代码7 项目: bobcat   文件: WebDriverWrapper.java
@Override
public ScreenOrientation getOrientation() {
  return ((Rotatable) super.getWrappedDriver()).getOrientation();
}
 
源代码8 项目: bobcat   文件: WebDriverWrapper.java
@Override
public void rotate(DeviceRotation deviceRotation) {
  ((Rotatable) super.getWrappedDriver()).rotate(deviceRotation);
}
 
源代码9 项目: bobcat   文件: WebDriverWrapper.java
@Override
public DeviceRotation rotation() {
  return ((Rotatable) super.getWrappedDriver()).rotation();
}
 
源代码10 项目: bobcat   文件: WebDriverWrapper.java
@Override
public void rotate(ScreenOrientation screenOrientation) {
  ((Rotatable) super.getWrappedDriver()).rotate(screenOrientation);
}
 
源代码11 项目: selenium   文件: AddRotatable.java
@Override
public Class<Rotatable> getDescribedInterface() {
  return Rotatable.class;
}
 
源代码12 项目: selenium   文件: AddRotatable.java
@Override
public Rotatable getImplementation(Capabilities capabilities, ExecuteMethod executeMethod) {
  return new RemoteRotatable(executeMethod);
}
 
源代码13 项目: selenium   文件: Rotate.java
@Override
public Void call() {
  ((Rotatable) getUnwrappedDriver()).rotate(orientation);
  return null;
}
 
源代码14 项目: selenium   文件: GetScreenOrientation.java
@Override
public ScreenOrientation call() {
  return ((Rotatable) getUnwrappedDriver()).getOrientation();
}
 
 类所在包
 同包方法