本文整理了Java中org.mozilla.zest.core.v1.ZestClientScreenshot
类的一些代码示例,展示了ZestClientScreenshot
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZestClientScreenshot
类的具体详情如下:
包路径:org.mozilla.zest.core.v1.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);
}
内容来源于网络,如有侵权,请联系作者删除!