Skip to content

Instantly share code, notes, and snippets.

View sauceaaron's full-sized avatar
💭
Cooking ribs

Aaron Evans sauceaaron

💭
Cooking ribs
View GitHub Profile
@sauceaaron
sauceaaron / SauceTestInfo.java
Last active March 31, 2020 21:59
Check for tests with errors
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class SauceTestInfo
{
private static Gson gson = new GsonBuilder().create();
@sauceaaron
sauceaaron / HelloCostcoTravel.java
Last active March 2, 2020 23:35
Demonstrate how to update test results with JS Executor and Sauce REST API
import com.saucelabs.saucerest.SauceREST;
import org.junit.After;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.MalformedURLException;
import java.net.URL;
import static org.assertj.core.api.Assertions.assertThat;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class AdditionWithDataProvider
{
@Test(dataProvider = "additionParameters")
public void testAddition(int a, int b, int sum)
{
#!/usr/bin/env python
from time import sleep
from selenium import webdriver
sites = ['https://google.com', 'https://bing.com', 'https://duck.com']
interval = 60 #seconds
iterations = 10 #times
import java.net.MalformedURLException;
import java.net.URL;
public class FindByText
{
URL url = new URL("https://ondemand.saucelabs.com/wd/hub");
DesiredCapabilities capabilities = new DesiredCapabilities();
//... set capabilities;
@Test
PORT=${1:-4447}
echo $TESTOBJECT_USERNAME
echo $SAUCECONNECT_API_KEY
sc -u $TESTOBJECT_USERNAME -k $SAUCECONNECT_API_KEY \
-x https://us1.api.testobject.com/sc/rest/v1 \
-B all \
-i my_rdc_tunnel \
--se-port $PORT \
--logfile /tmp/sc.$PORT.log \

Appium Selectors

General preferences

  • ACCESSIBILITY ID
  • CLASS NAME
  • IOS PREDICATE STRING
  • IOS CLASS CHAIN
  • XPATH
FILE=$1
FILENAME=$(basename $FILE)
if [ ! -f $FILE ]; then
echo "need to specify FILE: $FILE"
fi
URL="https://saucelabs.com/rest/v1/storage/$SAUCE_USERNAME/$FILENAME?overwrite=true"
curl -s -u $SAUCE_USERNAME:$SAUCE_ACCESS_KEY -X POST -H "Content-Type: application/octet-stream" $URL --data-binary @$FILE
@sauceaaron
sauceaaron / BrowserLogTest
Last active December 2, 2019 19:59
Getting browser log messages and javascript console log using Selenium Webdriver
import com.saucelabs.saucerest.SauceREST;
import org.junit.Test;
import org.openqa.selenium.logging.LogEntries;
import org.openqa.selenium.logging.LogType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.MalformedURLException;
import java.net.URL;
package com.saucelabs.test.results;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import com.mashape.unirest.request.HttpRequest;
import io.restassured.path.json.JsonPath;