Skip to content

Instantly share code, notes, and snippets.

View alfredlucero's full-sized avatar

Alfred Lucero alfredlucero

View GitHub Profile
@alfredlucero
alfredlucero / rubypageobjectandspec.rb
Last active September 23, 2019 17:03
Ruby Selenium Page Object and Spec - STUI to Webdriver SG Blog
## Sample Page Object Setup for the Ruby Selenium solution
## We have a base Page object to share some functionality across all pages
## and then each page would have its own helper functions and selectors
include Gridium
class SomePage > Page
def initialize
# Set up some Gridium timeouts/waits
# Set up @member properties i.e. references to elements through XPath/CSS
@alfredlucero
alfredlucero / wdio.conf.js
Last active September 24, 2019 17:33
wdio base config - STUI to Webdriver SG blog
exports.config = {
// This is our base config with which all others should be merged.
// Specify test files, we ended our Webdriver test files with *.uitest.js to not get mixed up with our unit tests
specs: ["./**/*.uitest.js"],
// Patterns to exclude
exclude: [],
// Group tests for a page in a suite for easier running of groups of page tests in CLI
@alfredlucero
alfredlucero / wdio.localhost.conf.js
Created September 24, 2019 17:56
wdio.localhost.conf.js - STUI to Webdriver SG blog
const merge = require("deepmerge");
const wdioConf = require("./wdio.conf.js");
exports.config = merge(wdioConf.config, {
// Localhost config file for when you have local web app running
// and pointing to whichever environment
services: ["selenium-standalone"],
baseUrl: "http://127.0.0.1:8000",
});
@alfredlucero
alfredlucero / wdio.staging.conf.js
Created September 24, 2019 20:10
wdio.staging.conf.js - STUI to Webdriver SG Blog
const merge = require("deepmerge");
const wdioConf = require("./wdio.conf.js");
exports.config = merge(wdioConf.config, {
services: ["selenium-standalone"],
// Staging specific environment variables and settings
user: "staging_user",
password: "staging_user_password",
envValue: "staging",
baseUrl: "https://staging.app.com"
@alfredlucero
alfredlucero / wdio.cicd.staging.conf.js
Created September 24, 2019 20:18
wdio.cicd.staging.conf.js - STUI to Webdriver SG Blog
const merge = require("deepmerge");
const wdioConf = require("./wdio.conf.js");
exports.config = merge(wdioConf.config, {
user: "staging_user",
password: "staging_user_password",
envValue: "staging",
// Selenium Hub in Docker setup
host: "selenium-hub", // Needs to match service name in docker-compose
port: 4444,
@alfredlucero
alfredlucero / package.json
Last active September 24, 2019 20:29
wdio package.json - STUI to Webdriver SG blog
{
"scripts": {
"uitest:localhost": "./node_modules/.bin/wdio wdio.localhost.conf.js",
"uitest:staging": "./node_modules/.bin/wdio wdio.staging.conf.js",
"uitest:cicd:staging": "./node_modules/.bin/wdio wdio.cicd.staging.conf.js",
}
}
@alfredlucero
alfredlucero / Dockerfile
Created September 24, 2019 21:27
Dockerfile.uitests - STUI to Webdriver SG Blog
FROM node:12.9.0
# Create working directory to install dependencies into
RUN mkdir -p /opt/frontendapp
WORKDIR /opt/frontendapp
COPY package.json /opt/frontendapp
RUN npm install
# Copy over the application code
@alfredlucero
alfredlucero / docker-compose.yml
Created September 24, 2019 21:34
docker-compose.uitests.yml - STUI to Webdriver SG Blog
version: '2.1'
services:
selenium-hub:
image: 'selenium/hub:latest'
ports:
- '4444:4444'
environment:
SE_OPTS: '-timeout 10000 -browserTimeout 10000'
JAVA_OPTS: '-Xmx1024m'
selenium-chrome:
@alfredlucero
alfredlucero / page.js
Created September 25, 2019 20:24
WDIO Base Page object - STUI to Webdriver SG Blog
export default class Page {
open(path) {
browser.url(`/${path}`);
}
// Other shared functionality across all pages
}
@alfredlucero
alfredlucero / SomePage.js
Created September 25, 2019 20:31
WDIO Specific Page Object - STUI to Webdriver SG Blog
import Page from './page';
class SomePage extends Page {
get submitButton() {
return $("button[data-testid=submit]");
}
get tableRows() {
return $$("tbody > tr[data-testid=tableRow]");
}