Skip to content

Instantly share code, notes, and snippets.

View djangofan's full-sized avatar

Jon Austen djangofan

View GitHub Profile
@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 )
@djangofan
djangofan / RWDTest.java
Created November 21, 2012 19:24 — forked from testingbot/gist:2428497
Selenium-2 Remote WebDriver Example
//use testingbot.com or saucelabs or roll your own remote webdriver server
import junit.framework.TestCase; //removes need for annotations by extending
import org.openqa.selenium.*;
import org.openqa.selenium.remote.*;
import java.net.URL;
import java.util.concurrent.TimeUnit;
public class RWDTest extends TestCase {
private WebDriver driver;
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;
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
}