Skip to content

Instantly share code, notes, and snippets.

View jsdevel's full-sized avatar

Joe Spencer jsdevel

View GitHub Profile
@jsdevel
jsdevel / slack-logger.js
Created January 12, 2018 16:05
Node.js slack logger example
const { IncomingWebhook } = require('@slack/client');
let sendToSlack;
const t = () => (new Date()).toISOString();
if (process.env.SLACK_LOGGING_WEBHOOK_URL) {
const slack = new IncomingWebhook(process.env.SLACK_LOGGING_WEBHOOK_URL);
const handler = err => {
if (err) {
@jsdevel
jsdevel / test-file-upload.js
Last active January 4, 2018 06:11
Shows how to handle file uploads in node.js line by line.
const http = require('http');
const readline = require('readline');
const HTML_PAGE = `<!doctype html>
<html>
<head>
<title>File upload testing</title>
<meta charset="utf-8">
<script>
function handleSubmit(e) {
@jsdevel
jsdevel / james-stock-quote.js
Last active November 4, 2015 03:35
james-stock-quote
// Create the instance
var request = new Request.Stocks({
// Stocks to retrieve
stocks: ["VTI","AMZN"],
// Formatter upon result
onComplete: function(result) {
var quotes = result && result.query && result.query.results && result.query.results.quote;
if(!quotes) return;
mvn archetype:generate \
-DarchetypeGroupId=com.github.jsdevel \
-DarchetypeArtifactId=testng-selenium-archetype
@Test @UserAgent("some new user agent")
public void verify_that_we_can_override_a_user_agent() {
// hooray!
}
package com.github.jsdevel.testng.selenium.samples;
import com.github.jsdevel.testng.selenium.AbstractPage;
import java.net.URL;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class GoogleHomePage extends AbstractPage<GoogleHomePage, SamplePageFactory> {
@FindBy(css = "[name=q]")
public WebElement q;
package my.project;
import com.github.jsdevel.testng.selenium.PageFactory;
public interface MyPageFactory extends PageFactory {
MyHomePage getHomePage();
MyHomePage getHomePage(String path);
}
<dependency>
<groupId>com.github.jsdevel</groupId>
<artifactId>testng-selenium</artifactId>
<!-- Change this to the version you wish to use. -->
<version>RELEASE</version>
</dependency>
package my.project;
import org.testng.annotations.Test;
import com.github.jsdevel.testng.selenium.AbstractSuite;
public class SampleSuiteITest extends AbstractSuite<MyPageFactory> {
@Test
public void we_should_be_able_to_view_the_home_page() {
getPageFactory().getHomePage();
describe('the home page', function() {
it('should allow users to search', function() {
pageFactory.getHomePage()
.get()
.doSomethingOnTheHomePage()
.clickSearchWidgetSubmitButton()
.doSomethingElseOnTheHomePage()
;
});
});