org.mozilla.zest.core.v1.ZestClientScreenshot类的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中org.mozilla.zest.core.v1.ZestClientScreenshot类的一些代码示例,展示了ZestClientScreenshot类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZestClientScreenshot类的具体详情如下:
包路径:org.mozilla.zest.core.v1.ZestClientScreenshot
类名称:ZestClientScreenshot

ZestClientScreenshot介绍

[英]A ZestClient action that takes a screenshot.

The screenshot can be saved to a file and/or to a variable (for the latter Base64 encoded).
[中]一个带有屏幕截图的ZestClient动作。
屏幕截图可以保存到文件和/或变量中(对于后者为Base64编码)。

代码示例

代码示例来源:origin: mozilla/zest

@Override
public ZestClientScreenshot deepCopy() {
  ZestClientScreenshot copy =
      new ZestClientScreenshot(getWindowHandle(), getFilePath(), getVariableName());
  copy.setEnabled(isEnabled());
  return copy;
}

代码示例来源:origin: mozilla/zest

@Test(expected = NullPointerException.class)
public void shouldFailWhenInvokingWithNullRuntime() throws Exception {
  // Given
  ZestClientScreenshot clientScreenshot =
      new ZestClientScreenshot("handle", "/path", "variableName");
  ZestRuntime runtime = null;
  // When
  clientScreenshot.invoke(runtime);
  // Then = NullPointerException
}

代码示例来源:origin: mozilla/zest

@Test
public void shouldSetEnabled() {
  // Given
  boolean enabled = false;
  ZestClientScreenshot clientScreenshot = new ZestClientScreenshot();
  // When
  clientScreenshot.setEnabled(enabled);
  // Then
  assertEquals(enabled, clientScreenshot.isEnabled());
}

代码示例来源:origin: mozilla/zest

@Test
public void shouldConstructWithFilePathAndVariableName() {
  // Given
  String windowHandle = "windowHandle";
  String filePath = "/path";
  String variableName = "variableName";
  // When
  ZestClientScreenshot clientScreenshot =
      new ZestClientScreenshot(windowHandle, filePath, variableName);
  // Then
  assertEquals(windowHandle, clientScreenshot.getWindowHandle());
  assertEquals(filePath, clientScreenshot.getFilePath());
  assertEquals(variableName, clientScreenshot.getVariableName());
}

代码示例来源:origin: mozilla/zest

@Test
public void shouldSetVariableName() {
  // Given
  String variableName = "variableName";
  ZestClientScreenshot clientScreenshot = new ZestClientScreenshot();
  // When
  clientScreenshot.setVariableName("variableName");
  // Then
  assertEquals(variableName, clientScreenshot.getVariableName());
}

代码示例来源:origin: mozilla/zest

@Test
public void shouldSetWindowHandle() {
  // Given
  String windowHandle = "windowHandle";
  ZestClientScreenshot clientScreenshot = new ZestClientScreenshot();
  // When
  clientScreenshot.setWindowHandle(windowHandle);
  // Then
  assertEquals(windowHandle, clientScreenshot.getWindowHandle());
}

代码示例来源:origin: mozilla/zest

@Test
public void shouldSetFilePath() {
  // Given
  String filePath = "/path";
  ZestClientScreenshot clientScreenshot = new ZestClientScreenshot();
  // When
  clientScreenshot.setFilePath(filePath);
  // Then
  assertEquals(filePath, clientScreenshot.getFilePath());
}

代码示例来源:origin: mozilla/zest

@Test
public void shouldNotHaveWindowHandleByDefault() {
  // Given / When
  ZestClientScreenshot clientScreenshot = new ZestClientScreenshot();
  // Then
  assertEquals(null, clientScreenshot.getWindowHandle());
}

代码示例来源:origin: mozilla/zest

@Test
public void shouldNotHaveVariableNameByDefault() {
  // Given / When
  ZestClientScreenshot clientScreenshot = new ZestClientScreenshot();
  // Then
  assertEquals(null, clientScreenshot.getVariableName());
}

代码示例来源:origin: mozilla/zest

@Test
public void shouldBeEnabledByDefault() {
  // Given / When
  ZestClientScreenshot clientScreenshot = new ZestClientScreenshot();
  // Then
  assertEquals(true, clientScreenshot.isEnabled());
}

代码示例来源:origin: mozilla/zest

@Test
public void shouldNotHaveFilePathByDefault() {
  // Given / When
  ZestClientScreenshot clientScreenshot = new ZestClientScreenshot();
  // Then
  assertEquals(null, clientScreenshot.getFilePath());
}

代码示例来源:origin: mozilla/zest

@Test
public void shouldBePassive() {
  // Given / When
  ZestClientScreenshot clientScreenshot = new ZestClientScreenshot();
  // Then
  assertEquals(true, clientScreenshot.isPassive());
}

代码示例来源:origin: mozilla/zest

@Override
public String invoke(ZestRuntime runtime) throws ZestClientFailException {
  WebDriver wd = runtime.getWebDriver(this.getWindowHandle());
  if (wd == null) {
    throw new ZestClientFailException(
        this, "No client: " + runtime.getVariable(getWindowHandle()));
        "Client does not take screenshots: " + runtime.getVariable(getWindowHandle()));

代码示例来源:origin: mozilla/zest

@Test
public void shouldDeepCopy() throws Exception {
  // Given
  ZestClientScreenshot original =
      new ZestClientScreenshot("windowHandle", "/path", "variableName");
  original.setEnabled(false);
  // When
  ZestClientScreenshot copy = original.deepCopy();
  // Then
  assertTrue(copy != original);
  assertEquals(copy.getElementType(), original.getElementType());
  assertEquals(copy.getWindowHandle(), original.getWindowHandle());
  assertEquals(copy.getFilePath(), original.getFilePath());
  assertEquals(copy.getVariableName(), original.getVariableName());
  assertEquals(copy.isEnabled(), original.isEnabled());
}

代码示例来源:origin: mozilla/zest

@Test(expected = ZestClientFailException.class)
public void shouldFailToInvokeIfWindowHandleNotAvailable() throws Exception {
  // Given
  ZestClientScreenshot clientScreenshot =
      new ZestClientScreenshot("handle", "/path", "variableName");
  ZestRuntime runtime = runtime();
  // When
  clientScreenshot.invoke(runtime);
  // Then = ZestClientFailException
}

代码示例来源:origin: mozilla/zest

@Test
public void shouldSerialiseAndDeserialise() {
  // Given
  ZestClientScreenshot original =
      new ZestClientScreenshot("windowHandle", "/path", "variableName");
  original.setEnabled(false);
  // When
  String serialisation = ZestJSON.toString(original);
  ZestClientScreenshot deserialised =
      (ZestClientScreenshot) ZestJSON.fromString(serialisation);
  // Then
  assertEquals(deserialised.getElementType(), original.getElementType());
  assertEquals(deserialised.getWindowHandle(), original.getWindowHandle());
  assertEquals(deserialised.getFilePath(), original.getFilePath());
  assertEquals(deserialised.getVariableName(), original.getVariableName());
  assertEquals(deserialised.isEnabled(), original.isEnabled());
}

代码示例来源:origin: mozilla/zest

@Test(expected = ZestClientFailException.class)
public void shouldFailToInvokeIfClientTakeScreenshotsButFileAndVariableAreEmpty()
    throws Exception {
  // Given
  String windowHandle = "windowHandle";
  ZestClientScreenshot clientScreenshot = new ZestClientScreenshot(windowHandle, "", "");
  ZestRuntime runtime = runtimeWithWebDriverThatTakesScreenshot(windowHandle);
  // When
  clientScreenshot.invoke(runtime);
  // Then = ZestClientFailException
}

代码示例来源:origin: mozilla/zest

@Test(expected = ZestClientFailException.class)
public void shouldFailToInvokeIfClientDoesNotTakeScreenshots() throws Exception {
  // Given
  String windowHandle = "handle";
  ZestClientScreenshot clientScreenshot =
      new ZestClientScreenshot(windowHandle, "/path", "variableName");
  ZestRuntime runtime = runtimeWithWebDriver(windowHandle);
  // When
  clientScreenshot.invoke(runtime);
  // Then = ZestClientFailException
}

代码示例来源:origin: mozilla/zest

@Test(expected = ZestClientFailException.class)
public void shouldFailToInvokeIfClientTakeScreenshotsButFileAndVariableAreNull()
    throws Exception {
  // Given
  String windowHandle = "windowHandle";
  ZestClientScreenshot clientScreenshot = new ZestClientScreenshot(windowHandle, null, null);
  ZestRuntime runtime = runtimeWithWebDriverThatTakesScreenshot(windowHandle);
  // When
  clientScreenshot.invoke(runtime);
  // Then = ZestClientFailException
}

代码示例来源:origin: mozilla/zest

@Test
public void shouldSaveScreenshotToVariable() throws Exception {
  // Given
  String windowHandle = "windowHandle";
  String variableName = "variableName";
  ZestClientScreenshot clientScreenshot =
      new ZestClientScreenshot(windowHandle, null, variableName);
  ZestRuntime runtime =
      runtimeWithWebDriverThatTakesScreenshot(windowHandle, SCREENSHOT_DATA);
  // When
  clientScreenshot.invoke(runtime);
  // Then
  verify(runtime).setVariable(variableName, SCREENSHOT_DATA_BASE_64);
}

相关文章