Skip to content

Instantly share code, notes, and snippets.

View djangofan's full-sized avatar

Jon Austen djangofan

View GitHub Profile
import org.testng.annotations.*
import org.testng.TestNG
import org.testng.TestListenerAdapter
@Grab(group='org.testng', module='testng', version='5.7', classifier='jdk15')
class HogeTest {
@Test
void add() {
assert 1 + 1 == 2
}
@djangofan
djangofan / wd.java
Created March 13, 2012 21:43 — forked from jarib/wd.rb
selenium-webdriver wait
public WebElement waitFindElement(WebDriver drv, By by, long timeout, long interval)
{
long start = System.currentTimeMillis();
while(true){
try{
return drv.findElement(by);
} catch(NoSuchElementException nse) {
if(System.currentTimeMillis()-start>=timeout)
{
throw new Error("Timeout reached and element["+by+"]not found");
@djangofan
djangofan / CollectionFilter.xtend
Created August 7, 2012 19:49 — forked from quicy/CollectionFilter.xtend
Collection filter by Xtend closure
import java.util.List
import static extension java.util.Collections.*
class CollectionFilter {
def static void main(String[] _) {
val values = new ArrayList( 1, 5, 33, 0, -2, -10, 4, 36, -82 )
positiveOnly( values )
negativeOnly( values )
private ExpectedCondition<Boolean> element(final By findCondition) {
return new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver from) {
RenderedWebElement element = (RenderedWebElement)
driver.findElement(findCondition);
return element.isDisplayed();
}
};
}
public static void mouseClickByLocator( String cssLocator ) {
String locator = cssLocator;
WebElement el = driver.findElement( By.cssSelector( locator ) );
Actions builder = new Actions(driver);
builder.moveToElement( el ).click( el );
builder.perform();
}
@djangofan
djangofan / jboss7-as.sh
Last active December 10, 2015 12:48 — forked from lionelg3/jboss-as
JBoss 7 Application Server Debian control script
#!/bin/sh
# Load JBoss AS init.d configuration.
if [ -z "$JBOSS_CONF" ]; then
JBOSS_CONF="/etc/jboss-as/server-jboss7.conf"
fi
# source the JBoss config file
[ -r "$JBOSS_CONF" ] && . "${JBOSS_CONF}"
create user usr_name identified by [pass***word] profile usr_profile default tablespace usr_ts temporary tablespace temp quota unlimited on usr_ts account unlock
grant create session to usr_name
grant create table to usr_name
grant create view to usr_name
grant create sequence to usr_name
grant create procedure to usr_name
grant create database link to usr_name
@djangofan
djangofan / SeleniumRemoteExample.java
Last active December 11, 2015 07:58 — forked from neino3/Selenium2Example1Test.java
SeleniumRemote example using Augmenter for screenshot
import java.io.File;
import java.io.IOException;
import java.net.URL;
import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.Platform;
import org.openqa.selenium.TakesScreenshot;
package com.yahoo.media.mediaqa.selenium2test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.android.AndroidDriver;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.firefox.internal.ProfilesIni;
@djangofan
djangofan / predicate.java
Last active March 31, 2017 14:13 — forked from anonymous/test.java
Predicate used in Selenium WebDriver wait
public void authenticate() {
this.authenticateButton.click();
new WebDriverWait(driver, 30).until(authenticated());
}
private Predicate<WebDriver> authenticated() {
return new Predicate<WebDriver>() {
@Override public boolean apply(WebDriver driver) {
return isAuthenticated();
}