Skip to content

Instantly share code, notes, and snippets.

@dougnoel
dougnoel / BaseSteps_old.java
Created August 24, 2018 03:55
Old reflection code
private static Object getObject(String elementName) throws Throwable {
Page page = PageManager.getPage(); // Get the current reference to the page I am on.
elementName = elementName.replaceAll("\\s+", "_").toLowerCase(); // Turn our text into all lower case with spaces replaced by underscores to match object names.
Method pageElementName = null;
try {
pageElementName = page.getClass().getMethod(elementName); // Create a Method object to store the PageElement we want to exercise.
} catch(NoSuchMethodException e) {
log.error("Element " + elementName + " is not defined for the page object " + page.getClass().toString() + ". Make sure you have spelled the page object name correctly in your Cucumber step definition and in the page object.");
throw e;
}
@dougnoel
dougnoel / API_Auth.java
Last active December 8, 2022 20:13
Authentication code removed from com.dougnoel.sentinel.apis.API.Java
private AuthenticationType authenticationType = NONE;
private Object authToken = null;
private static final AuthenticationType JWT = AuthenticationType.JWT;
private static final AuthenticationType AUTH_KEY = AuthenticationType.AUTH_KEY;
private static final AuthenticationType NONE = AuthenticationType.NONE;
/**
* Sets the authentication type that this API uses.
@dougnoel
dougnoel / APISteps_Auth.java
Created December 8, 2022 20:16
Code removed from com.dougnoel.sentinel.steps.APISteps.java
/**
* Gets a JWT Token from a currently open browser that you have logged into
* and sets it for the curently active API
*/
@When("^I scrape the JWT from the current page$")
public void scrapeJWT() {
AuthenticationType authType = AuthenticationType.JWT;
APIManager.getAPI().setAuthType(authType);
APIManager.getAPI().setAuthToken();
}
@dougnoel
dougnoel / AuthenticationType.java
Created December 8, 2022 20:18
com.dougnoel.sentinel.enums.AuthenticationType.java removed from Sentinel
package com.dougnoel.sentinel.enums;
/**
* Possible methods for an API to authenticate.
*
* @author Doug Noël
*
*/
public enum AuthenticationType {
NONE,