Skip to content

Instantly share code, notes, and snippets.

View djangofan's full-sized avatar

Jon Austen djangofan

View GitHub Profile
@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();
}
@djangofan
djangofan / SauceBrowserDataProvider.java
Created November 5, 2014 23:40
Sauce on demand data provider for TestNG
package com.saucelabs.testng;
import com.saucelabs.common.Utils;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.testng.annotations.DataProvider;
import java.lang.reflect.Method;
@djangofan
djangofan / TestLogger.java
Created October 17, 2014 22:23
Logger that logs like Log4j but will also log TestNG static Reporter.log as well.
import org.testng.Reporter;
import java.io.File;
import java.util.Enumeration;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.log4j.Appender;
import org.apache.log4j.FileAppender;
import org.apache.log4j.Layout;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
@djangofan
djangofan / dataprovider.java
Created October 7, 2014 22:31
Example data provider creating instances of various web browsers
public class FactoryDataProviderTestBase extends MyTestBase
{
@Factory(dataProvider = "dp")
public FactoryDataProviderTestBase( SauceTestHelper helper,
Map<String,String> csvArgMap ) {
super( helper, csvArgMap );
}
@DataProvider( name = "factory" )
static public Object[][] factoryDataProvider() {
@djangofan
djangofan / ansible_HOWTO.txt
Last active August 29, 2015 14:00
First time using Ansible
Using Ansible, given scenario with 3 hosts: vbox1, vbox2, and vbox3, this guide will teach you to do the
following Ansible tasks:
A. Configure Ansible
B. Define remote slave servers by group
C. Run any shell commands on your remote servers by their group name
D. Create a Apache playbook to install Apache2 on all of your remote servers
E. SCP files out to your remote servers
F. Create a new blank role directory structure for you to write your own Role and publish it to "Ansible Galaxy" for re-use.
@djangofan
djangofan / gist:10421275
Last active August 29, 2015 13:58
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>myappJMeterTest</groupId>
<artifactId>myappJMeterTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>patsatJMeterTest</name>
<description>JMeter tests for testing myapp APIs.</description>
<repositories>
<repository>
@djangofan
djangofan / schemacrawler.bat
Last active January 22, 2019 13:30
Example of using schemacrawler from the command line with Oracle
@ECHO off
SETLOCAL ENABLEDELAYEDEXPANSION
SET TITLE=Schema crawler
TITLE %TITLE%
ECHO.&ECHO.
:: FORMAT can be csv or html
SET FORMAT=html
SET INPUTFILE=table.names
SET USER=user
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 / JenkinsHTMLReport.java
Last active April 18, 2017 05:39
Customized HTML report for TestNG for use on Jenkins job
package engine.test.selenium.common.helper;
import org.testng.IInvokedMethod;
import org.testng.IReporter;
import org.testng.IResultMap;
import org.testng.ISuite;
import org.testng.ISuiteResult;
import org.testng.ITestClass;
import org.testng.ITestContext;
import org.testng.ITestNGMethod;
@djangofan
djangofan / pom.xml
Last active March 15, 2017 21:49
pom.xml file for JMeter project
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>JMeterTest</groupId>
<artifactId>JMeterTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>JMeterTest</name>
<description>JMeter tests for testing API</description>
<dependencies>
<dependency>
<groupId>com.lazerycode.jmeter</groupId>