public class Locomotive extends Object implements Conductor<Locomotive>
| Modifier and Type | Field and Description |
|---|---|
org.openqa.selenium.interactions.Actions |
actions |
String |
baseUrl
The url that an automated test will be testing.
|
Config |
configuration
All test configuration in here
|
org.openqa.selenium.WebDriver |
driver |
static org.apache.logging.log4j.Logger |
log |
int |
MAX_ATTEMPTS |
int |
MAX_TIMEOUT |
| Constructor and Description |
|---|
Locomotive() |
| Modifier and Type | Method and Description |
|---|---|
Locomotive |
check(org.openqa.selenium.By by) |
Locomotive |
check(String css)
Check a checkbox, or radio button
|
Locomotive |
click(org.openqa.selenium.By by) |
Locomotive |
click(String css)
Click an element.
|
Locomotive |
closeWindow()
Closes the current active window.
|
Locomotive |
closeWindow(String regex)
Close an open window.
|
static String |
findFile(String filename) |
String |
get(String key)
Get a variable from the data warehouse.
If the key is not set, then use Conductor.get(String, String) |
String |
get(String key,
String defaultValue)
Get a variable from the data warehouse.
|
String |
getAttribute(org.openqa.selenium.By by,
String attribute) |
String |
getAttribute(String css,
String attribute)
Get an attribute of an element
|
String |
getText(org.openqa.selenium.By by) |
String |
getText(String css)
Get the text of an element.
|
Locomotive |
goBack()
Navigates the browser back one page.
|
Locomotive |
hoverOver(org.openqa.selenium.By by) |
Locomotive |
hoverOver(String css)
Hover over an element.
|
boolean |
isChecked(org.openqa.selenium.By by) |
boolean |
isChecked(String css)
Checks if the element is checked or not.
|
boolean |
isPresent(org.openqa.selenium.By by) |
boolean |
isPresent(String css)
Checks if the element is present or not.
|
Locomotive |
log(Object object)
Log something as information
|
Locomotive |
logDebug(Object object)
Log something as debug
|
Locomotive |
logError(Object object)
Log something as an error
|
Locomotive |
logFatal(Object object)
Log something as fatal
|
Locomotive |
logInfo(Object object)
Log something as information
|
Locomotive |
logWarn(Object object)
Log something as a warning
|
Locomotive |
navigateTo(String url)
Navigates to an absolute or relative Url.
|
Locomotive |
refresh()
Refresh the page
|
Locomotive |
selectOptionByText(org.openqa.selenium.By by,
String text) |
Locomotive |
selectOptionByText(String css,
String text)
Selects an option from a dropdown (<select> tag) based on the text displayed.
|
Locomotive |
selectOptionByValue(org.openqa.selenium.By by,
String value) |
Locomotive |
selectOptionByValue(String css,
String value)
Selects an option from a dropdown (<select> tag) based on the value.
|
Locomotive |
setAndValidateText(org.openqa.selenium.By by,
String text)
Deprecated.
|
Locomotive |
setAndValidateText(String css,
String text)
Deprecated.
|
Locomotive |
setText(org.openqa.selenium.By by,
String text) |
Locomotive |
setText(String css,
String text)
Clears the text from a text field, and sets it.
|
Locomotive |
store(String key,
String value)
Put a variable in the data warehouse.
|
Locomotive |
switchToDefaultContent()
Switch back to the default content (the first window / frame that you were on before switching)
|
Locomotive |
switchToFrame(int index)
Switches to a frame based on the index it comes.
|
Locomotive |
switchToFrame(String idOrName)
Switches to a frame or iframe.
|
Locomotive |
switchToFrame(org.openqa.selenium.WebElement webElement)
Switches to a frame based on a found WebElement
|
Locomotive |
switchToWindow(String regex)
Switch's to a window that is already in existance.
|
void |
teardown() |
Locomotive |
uncheck(org.openqa.selenium.By by) |
Locomotive |
uncheck(String css)
Uncheck a checkbox, or radio button
|
Locomotive |
validateAttribute(org.openqa.selenium.By by,
String attr,
String regex) |
Locomotive |
validateAttribute(String css,
String attr,
String regex)
Validates an attribute of an element.
Example: <input type="text" id="test" /> .validateAttribute("input#test", "type", "text") // validates that the "type" attribute equals "test"
|
Locomotive |
validateChecked(org.openqa.selenium.By by) |
Locomotive |
validateChecked(String css)
Validate that a checkbox or a radio button is checked.
|
Locomotive |
validateFalse(boolean condition)
Validates that a specific condition is false
|
Locomotive |
validateNotPresent(org.openqa.selenium.By by) |
Locomotive |
validateNotPresent(String css)
Validates that an element is not present.
|
Locomotive |
validatePresent(org.openqa.selenium.By by) |
Locomotive |
validatePresent(String css)
Validates that an element is present.
|
Locomotive |
validateText(org.openqa.selenium.By by,
String text) |
Locomotive |
validateText(String css,
String text)
Validate that the text of an element is correct.
|
Locomotive |
validateTextNot(org.openqa.selenium.By by,
String text) |
Locomotive |
validateTextNot(String css,
String text)
Validate that the text of an element is not matching text.
|
Locomotive |
validateTextNotPresent(String text)
Validate that some text is nowhere on the page.
|
Locomotive |
validateTextPresent(String text)
Validate that text is present somewhere on the page.
|
Locomotive |
validateTrue(boolean condition)
Validates that a specific condition is true
|
Locomotive |
validateUnchecked(org.openqa.selenium.By by) |
Locomotive |
validateUnchecked(String css)
Validate that a checkbox or a radio button is unchecked.
|
Locomotive |
validateUrl(String regex)
Validate the Url
|
Locomotive |
waitForCondition(org.openqa.selenium.support.ui.ExpectedCondition<?> condition)
Wait for a specific condition (polling every 1s, for MAX_TIMOUT seconds)
|
Locomotive |
waitForCondition(org.openqa.selenium.support.ui.ExpectedCondition<?> condition,
long timeOutInSeconds)
Wait for a specific condition (polling every 1s)
|
Locomotive |
waitForCondition(org.openqa.selenium.support.ui.ExpectedCondition<?> condition,
long timeOutInSeconds,
long sleepInMillis)
Wait for a specific condition before continuing
|
org.openqa.selenium.WebElement |
waitForElement(org.openqa.selenium.By by)
Method that acts as an arbiter of implicit timeouts of sorts..
|
Locomotive |
waitForWindow(String regex)
Waits for a window to appear, then switches to it.
|
public static final org.apache.logging.log4j.Logger log
public Config configuration
public org.openqa.selenium.WebDriver driver
public int MAX_ATTEMPTS
public int MAX_TIMEOUT
public org.openqa.selenium.interactions.Actions actions
public String baseUrl
public void teardown()
public org.openqa.selenium.WebElement waitForElement(org.openqa.selenium.By by)
waitForElement in interface Conductor<Locomotive>public Locomotive waitForCondition(org.openqa.selenium.support.ui.ExpectedCondition<?> condition)
condition - the condition to wait forpublic Locomotive waitForCondition(org.openqa.selenium.support.ui.ExpectedCondition<?> condition, long timeOutInSeconds)
condition - the condition to wait fortimeOutInSeconds - the timeout in secondspublic Locomotive waitForCondition(org.openqa.selenium.support.ui.ExpectedCondition<?> condition, long timeOutInSeconds, long sleepInMillis)
ConductorwaitForCondition in interface Conductor<Locomotive>condition - the condition to wait fortimeOutInSeconds - how long to waitsleepInMillis - the delay between waitspublic Locomotive click(String css)
Conductorclick in interface Conductor<Locomotive>public Locomotive click(org.openqa.selenium.By by)
click in interface Conductor<Locomotive>public Locomotive setText(String css, String text)
ConductorsetText in interface Conductor<Locomotive>text - The text that the element will have.public Locomotive setText(org.openqa.selenium.By by, String text)
setText in interface Conductor<Locomotive>public Locomotive hoverOver(String css)
ConductorhoverOver in interface Conductor<Locomotive>public Locomotive hoverOver(org.openqa.selenium.By by)
hoverOver in interface Conductor<Locomotive>public boolean isChecked(String css)
ConductorisChecked in interface Conductor<Locomotive>true if the element is checked. and false if it's not.public boolean isChecked(org.openqa.selenium.By by)
isChecked in interface Conductor<Locomotive>public boolean isPresent(String css)
ConductorisPresent in interface Conductor<Locomotive>true if the element is present. and false if it's not.public boolean isPresent(org.openqa.selenium.By by)
isPresent in interface Conductor<Locomotive>public String getText(String css)
ConductorThis is a consolidated method that works on input's, as select boxes, and fetches the value rather than the innerHTMl.
getText in interface Conductor<Locomotive>public String getText(org.openqa.selenium.By by)
getText in interface Conductor<Locomotive>public String getAttribute(String css, String attribute)
ConductorgetAttribute in interface Conductor<Locomotive>attribute - The attribute to getpublic String getAttribute(org.openqa.selenium.By by, String attribute)
getAttribute in interface Conductor<Locomotive>public Locomotive check(String css)
Conductorcheck in interface Conductor<Locomotive>public Locomotive check(org.openqa.selenium.By by)
check in interface Conductor<Locomotive>public Locomotive uncheck(String css)
Conductoruncheck in interface Conductor<Locomotive>public Locomotive uncheck(org.openqa.selenium.By by)
uncheck in interface Conductor<Locomotive>public Locomotive selectOptionByText(String css, String text)
ConductorselectOptionByText in interface Conductor<Locomotive>text - The text that is displaying.Conductor.selectOptionByValue(By, String)public Locomotive selectOptionByText(org.openqa.selenium.By by, String text)
selectOptionByText in interface Conductor<Locomotive>public Locomotive selectOptionByValue(String css, String value)
ConductorselectOptionByValue in interface Conductor<Locomotive>value - The value attribute of the option.Conductor.selectOptionByText(By, String)public Locomotive selectOptionByValue(org.openqa.selenium.By by, String value)
selectOptionByValue in interface Conductor<Locomotive>public Locomotive waitForWindow(String regex)
ConductorwaitForWindow in interface Conductor<Locomotive>regex - Regex enabled. Url of the window, or title.public Locomotive switchToWindow(String regex)
ConductorswitchToWindow in interface Conductor<Locomotive>regex - Regex enabled. Url of the window, or title.public Locomotive closeWindow(String regex)
ConductorConductor.switchToWindow(String) to switch back context.closeWindow in interface Conductor<Locomotive>regex - The title of the window to close (regex enabled). You may specify null to close the active window. If you specify null then the context will switch back to the initial window.public Locomotive closeWindow()
ConductorcloseWindow in interface Conductor<Locomotive>public Locomotive switchToFrame(String idOrName)
ConductorswitchToFrame in interface Conductor<Locomotive>idOrName - The id or name of the frame.public Locomotive switchToFrame(org.openqa.selenium.WebElement webElement)
ConductorswitchToFrame in interface Conductor<Locomotive>webElement - The WebElement object that was found.public Locomotive switchToFrame(int index)
Conductor0)switchToFrame in interface Conductor<Locomotive>index - The index of the frame in which it appearspublic Locomotive switchToDefaultContent()
ConductorswitchToDefaultContent in interface Conductor<Locomotive>public Locomotive validatePresent(String css)
ConductorvalidatePresent in interface Conductor<Locomotive>public Locomotive validatePresent(org.openqa.selenium.By by)
validatePresent in interface Conductor<Locomotive>public Locomotive validateNotPresent(String css)
ConductorvalidateNotPresent in interface Conductor<Locomotive>public Locomotive validateNotPresent(org.openqa.selenium.By by)
validateNotPresent in interface Conductor<Locomotive>public Locomotive validateText(String css, String text)
ConductorvalidateText in interface Conductor<Locomotive>text - The text the element should have.public Locomotive validateText(org.openqa.selenium.By by, String text)
validateText in interface Conductor<Locomotive>@Deprecated public Locomotive setAndValidateText(org.openqa.selenium.By by, String text)
setAndValidateText in interface Conductor<Locomotive>@Deprecated public Locomotive setAndValidateText(String css, String text)
ConductorsetAndValidateText in interface Conductor<Locomotive>text - The text to set and validatepublic Locomotive validateTextNot(String css, String text)
ConductorvalidateTextNot in interface Conductor<Locomotive>text - The text the element should not have.public Locomotive validateTextNot(org.openqa.selenium.By by, String text)
validateTextNot in interface Conductor<Locomotive>public Locomotive validateTextPresent(String text)
ConductorvalidateTextPresent in interface Conductor<Locomotive>text - The text to ensure is on the page.public Locomotive validateTextNotPresent(String text)
ConductorvalidateTextNotPresent in interface Conductor<Locomotive>text - The text to ensure is not on the page.public Locomotive validateChecked(String css)
ConductorvalidateChecked in interface Conductor<Locomotive>public Locomotive validateChecked(org.openqa.selenium.By by)
validateChecked in interface Conductor<Locomotive>public Locomotive validateUnchecked(String css)
ConductorvalidateUnchecked in interface Conductor<Locomotive>public Locomotive validateUnchecked(org.openqa.selenium.By by)
validateUnchecked in interface Conductor<Locomotive>public Locomotive validateAttribute(String css, String attr, String regex)
Conductor<input type="text" id="test" />
.validateAttribute("input#test", "type", "text") // validates that the "type" attribute equals "test"
validateAttribute in interface Conductor<Locomotive>attr - The attribute you'd like to validateregex - What the attribute should be. (this method supports regex)public Locomotive validateAttribute(org.openqa.selenium.By by, String attr, String regex)
validateAttribute in interface Conductor<Locomotive>public Locomotive validateUrl(String regex)
ConductorvalidateUrl in interface Conductor<Locomotive>regex - Regular expression to matchpublic Locomotive validateTrue(boolean condition)
ConductorvalidateTrue in interface Conductor<Locomotive>condition - The condition that is expected to be truepublic Locomotive validateFalse(boolean condition)
ConductorvalidateFalse in interface Conductor<Locomotive>condition - The condition that is expected to be falsepublic Locomotive goBack()
Conductordriver.navigate().back()goBack in interface Conductor<Locomotive>public Locomotive refresh()
Conductorrefresh in interface Conductor<Locomotive>public Locomotive navigateTo(String url)
ConductornavigateTo in interface Conductor<Locomotive>url - Use cases are:navigateTo("/login") // navigate to a relative url. slash meaning start fresh from the base url.
navigateTo("path") // navigate to a relative url. will simply append "path" to the current url.
navigateTo("http://google.com") // navigates to an absolute url.
public Locomotive store(String key, String value)
Conductorstore in interface Conductor<Locomotive>key - The key to put.value - The value to put.public String get(String key)
ConductorConductor.get(String, String)get in interface Conductor<Locomotive>key - The key to fetch.public String get(String key, String defaultValue)
Conductorget in interface Conductor<Locomotive>key - The key to fetch.defaultValue - The value to return if the variable is not set.public Locomotive log(Object object)
Conductorlog in interface Conductor<Locomotive>object - What to log.public Locomotive logInfo(Object object)
ConductorlogInfo in interface Conductor<Locomotive>object - What to logpublic Locomotive logWarn(Object object)
ConductorlogWarn in interface Conductor<Locomotive>object - What to logpublic Locomotive logError(Object object)
ConductorlogError in interface Conductor<Locomotive>object - What to logAutomationTest (for fluency)public Locomotive logDebug(Object object)
ConductorlogDebug in interface Conductor<Locomotive>object - What to logpublic Locomotive logFatal(Object object)
ConductorlogFatal in interface Conductor<Locomotive>object - What to logCopyright © 2016. All rights reserved.