public class SeleniumAssist extends WebDriverAssist
$SELENIUM.assist().'funcName'(...)
Constructor and Description |
---|
SeleniumAssist(org.openqa.selenium.WebDriver webDriver_p,
MbtScriptExecutor scriptExec_p) |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptAlert()
accept the alert dialog window by clicking on "OK" button.
|
boolean |
containsText(String text_p)
returns true if current window/frame/page contains the text specified (case insensitive).
|
boolean |
dismissAlert()
dismiss the alert/confirm dialog by clicking on close or "cancel" button.
|
String |
getAlertText()
returns the message in the alert pop-up dialog if present.
|
org.openqa.selenium.WebElement |
highlightElement(org.openqa.selenium.By locator_p,
String color_p,
long millis_p)
highlight element(s) by changing its border color temporarily for a duration specified in milliseconds.
|
boolean |
isAlertPresent()
returns true if the alert dialog has been displayed(triggered).
|
List<org.openqa.selenium.WebElement> |
listIFrames()
returns a list of iframes in current window
|
Object |
runJS(String javascript_p)
executes javascript on current window/frame.
|
Object |
scrollBy(int x_delta_p,
int y_delta_p)
scrolls window by the x and y pixels specified.
|
Object |
scrollTo(int x_p,
int y_p)
scrolls window to the x,y coordinates specified.
|
org.openqa.selenium.support.ui.Select |
selectOptionByIndex(org.openqa.selenium.By locator_p,
int index_p)
selects an option for the Select element by option index (0-based).
|
org.openqa.selenium.support.ui.Select |
selectOptionByText(org.openqa.selenium.By locator_p,
String text_p)
selects an option for the Select element by matching the option display text.
|
org.openqa.selenium.support.ui.Select |
selectOptionByValue(org.openqa.selenium.By locator_p,
String value_p)
selects an option for the Select element by matching the value attribute.
|
String |
selectWindowByIndex(int idx_p) |
org.openqa.selenium.WebElement |
sendKey(org.openqa.selenium.By locator_p,
String keyString_p)
type the string to the first element found with locator_p.
|
org.openqa.selenium.WebElement |
setCheckbox(org.openqa.selenium.By locator_p,
boolean checked_p)
sets the checkbox.
|
org.openqa.selenium.WebDriver.Timeouts |
setImplicitWait(long millis_p)
sets the implicitWait parameter for WebDriver.
|
void |
setWindowSize(int width_p,
int height_p)
sets the browser window size to the specified dimension: width and height.
|
org.openqa.selenium.WebElement |
type(org.openqa.selenium.By locator_p,
String keyString_p,
String shiftCtrlAlt_p)
type the string to the first element found with locator_p with the option to have shift/control/alt key pressed.
|
click, click, click, doubleClick, dragAndDrop, mouseDown, mouseOver, mouseUp, rightClick, snapScreen, waitForElement, waitForElementAttr, waitForElementEnabled, waitForElementText
public SeleniumAssist(org.openqa.selenium.WebDriver webDriver_p, MbtScriptExecutor scriptExec_p)
public String getAlertText()
public boolean isAlertPresent()
public boolean acceptAlert()
public boolean dismissAlert()
public boolean containsText(String text_p)
text_p
- public String selectWindowByIndex(int idx_p)
idx_p
- 0-based indexpublic org.openqa.selenium.WebElement setCheckbox(org.openqa.selenium.By locator_p, boolean checked_p)
Example:
$SELENIUM.assist().setCheckBox(By.id('F1'), true);
locator_p
- locator to the checkbox elementchecked_p
- true or falsepublic org.openqa.selenium.support.ui.Select selectOptionByText(org.openqa.selenium.By locator_p, String text_p) throws MBTException
Example:
$SELENIUM.assist().selectOptionByText(By.id('F1'),'this is the label text');
locator_p
- locator for the elementtext_p
- text string to identify the optionMBTException
public org.openqa.selenium.support.ui.Select selectOptionByValue(org.openqa.selenium.By locator_p, String value_p) throws MBTException
Example:
$SELENIUM.assist().selectOptionByValue(By.id('F1'),'2');
locator_p
- locator for the elementvalue_p
- text string to match to option valueMBTException
public org.openqa.selenium.support.ui.Select selectOptionByIndex(org.openqa.selenium.By locator_p, int index_p) throws MBTException
Example:
$SELENIUM.assist().selectOptionByText(By.id('F1'), 0);
locator_p
- locator for the elementindex_p
- 0-based indexMBTException
public org.openqa.selenium.WebElement type(org.openqa.selenium.By locator_p, String keyString_p, String shiftCtrlAlt_p) throws Exception
Not available for remote testing using selenium/appium/saucelabs servers.
Example:
$SELENIUM.assist().type(By.id('F1'),'abc','S');
locator_p
- shiftCtrlAlt_p
- include char "c" for control key, "a" for alt key and "s" for shift key. For example
"cs" to have control and shift keys pressed.keyString_p
- MBTException
Exception
public org.openqa.selenium.WebElement sendKey(org.openqa.selenium.By locator_p, String keyString_p)
Example:
$SELENIUM.assist().sendKey(By.id('F1'),'abc');
Use the following tokens to simulate special keyboard key:
$SELENIUM.assist().sendKey(By.id('F1'),'[KEYS.ENTER]') or $SELENIUM.assist().sendKey(By.id('F1'),'abc[KEYS.TAB]');
public Object runJS(String javascript_p) throws MBTException
javascript_p
- MBTException
public void setWindowSize(int width_p, int height_p)
Example:
$SELENIUM.assist().setWindowSize(1000, 2000)
width_p
- height_p
- public org.openqa.selenium.WebElement highlightElement(org.openqa.selenium.By locator_p, String color_p, long millis_p) throws Exception
locator_p
- color_p
- html color codemillis_p
- number of milliseconds, 0 for leaving the highlight (note this may affect your application behavior due to style attribute
changed)Exception
public List<org.openqa.selenium.WebElement> listIFrames()
public Object scrollBy(int x_delta_p, int y_delta_p) throws MBTException
x_delta_p
- integer, amount to scroll on x coordinate (horizontal axis), specify 0 for no change.y_delta_p
- integer, amount to scroll on y coordinate (vertical axis), specify 0 for no change.MBTException
public Object scrollTo(int x_p, int y_p) throws MBTException
x_p
- integer, x coordinate (horizontal)y_p
- integer, y coordinate (vertical)MBTException
public org.openqa.selenium.WebDriver.Timeouts setImplicitWait(long millis_p)
You may need to use other wait method to supplement this global setting to meet specific needs in different part of the model.
setImplicitWait
in class WebDriverAssist
millis_p
- number of millisecondsCopyright TestOptimal, LLC