Skip to content

Instantly share code, notes, and snippets.

extract(
shortcode_atts(
array(
'id' => null,
),
$atts)
);
if ($id == null) {
return '';
@media only screen and (max-device-width: 480px) {
div#wrapper {
width: 400px;
}
}
protected void starting(Description d) {
fName = d.getClassName() + "." + d.getMethodName();
}
public class NameRuleTest {
@Rule public TestName name = new TestName();
@Test public void testA() {
assertEquals("testA", name.getMethodName());
}
@Test public void testB() {
assertEquals("testB", name.getMethodName());
}
}
boolean findElement(List<String> elements, String desiredElement) {
checkNotNull(elements);
// ...
}
checkArgument(i < j, "Expected i < j, but %s > %s", i, j);
public String toString() {
return new StringBuilder()
.append("Name: " + name)
.append("Foo: " + foo)
.append("Bar: " + bar)
.toString();
}
function NewXmlHttpRequest() {
try {
return new window.XMLHttpRequest();
}
catch(e) {} //standard API
try {
return new ActiveXObject("Msxml2.Xmlhttp.6.0");
}
catch(e) {}
try {
public byte[] takeScreenshot() throws IOException {
TakesScreenshot takesScreenshot = (TakesScreenshot) driver;
return takesScreenshot.getScreenshotAs(OutputType.BYTES);
}
public BufferedImage createElementImage(WebElement webElement)
throws IOException {
// 获得webElement的位置和大小。
Point location = webElement.getLocation();
Dimension size = webElement.getSize();
// 创建全屏截图。
BufferedImage originalImage =
ImageIO.read(new ByteArrayInputStream(takeScreenshot()));
// 截取webElement所在位置的子图。
BufferedImage croppedImage = originalImage.getSubimage(