public class WebDriverAssist extends Object
Constructor and Description |
---|
WebDriverAssist(org.openqa.selenium.WebDriver webDriver_p,
MbtScriptExecutor scriptExec_p) |
Modifier and Type | Method and Description |
---|---|
org.openqa.selenium.WebElement |
click(org.openqa.selenium.By loc_p)
simulate click on the first element found.
|
org.openqa.selenium.WebElement |
click(org.openqa.selenium.By loc_p,
int coordX_p,
int coordY_p)
simulate click on the first element found.
|
org.openqa.selenium.WebElement |
click(org.openqa.selenium.By loc_p,
String shiftCtrlAlt_p)
simulate click on the first element found with option of holding down shift, ctrl or alt key.
|
org.openqa.selenium.WebElement |
doubleClick(org.openqa.selenium.By locator_p)
double click on the first element found.
|
org.openqa.selenium.WebElement |
dragAndDrop(org.openqa.selenium.By fromLocator_p,
org.openqa.selenium.By toLocator_p)
drag an element and drop it onto another element.
|
org.openqa.selenium.WebElement |
mouseDown(org.openqa.selenium.By locator_p)
trigger mouse down event on the first element found with locator_p.
|
org.openqa.selenium.WebElement |
mouseOver(org.openqa.selenium.By locator_p)
trigger mouse over event on the first element found with locator_p.
|
org.openqa.selenium.WebElement |
mouseUp(org.openqa.selenium.By locator_p)
trigger mouse up event on the first element found locator_p.
|
org.openqa.selenium.WebElement |
rightClick(org.openqa.selenium.By locator_p)
rightClick on the first element found with locator_p.
|
org.openqa.selenium.WebDriver.Timeouts |
setImplicitWait(long millis_p)
sets implicit wait in milliseconds.
|
String |
snapScreen()
Take a snapshot of current AUT window.
|
org.openqa.selenium.WebElement |
waitForElement(org.openqa.selenium.By locator_p,
long timeoutMillis_p)
waits for an element to be visible up to the specified timeout in milliseconds.
|
org.openqa.selenium.WebElement |
waitForElementAttr(org.openqa.selenium.By locator_p,
String attrName_p,
String attrValue_p,
long timeoutMillis_p)
waits for an attribute to contain the specified value on the element.
|
org.openqa.selenium.WebElement |
waitForElementEnabled(org.openqa.selenium.By locator_p,
long timeoutMillis_p)
waits for the specified element to be enabled.
|
org.openqa.selenium.WebElement |
waitForElementText(org.openqa.selenium.By locator_p,
String text_p,
long timeoutMillis_p)
waits for the element up to contain the expected text.
|
public WebDriverAssist(org.openqa.selenium.WebDriver webDriver_p, MbtScriptExecutor scriptExec_p)
public String snapScreen() throws Exception
Typical use of this method is to call it in MBT_FAIL or MBT_ERROR triggers to take a snapshot of the screen of the error.
The screen shot will be marked with the first exception (if multiple exceptions) triggered by current mScript and thus available from the exception popup.
Exception
public org.openqa.selenium.WebElement mouseDown(org.openqa.selenium.By locator_p)
Example:
<action code="$mouseDown('id=F1')"/>
locator_p
- public org.openqa.selenium.WebElement mouseOver(org.openqa.selenium.By locator_p)
Example:
<action code="$mouseOver('id=F1')"/>
public org.openqa.selenium.WebElement rightClick(org.openqa.selenium.By locator_p)
Example:
<action code="$rightClick('id=F1')"/>
public org.openqa.selenium.WebElement click(org.openqa.selenium.By loc_p) throws Exception
Example:
$WEBDRIVER.assist().click(By.id('F1'));
loc_p
- Exception
public org.openqa.selenium.WebElement click(org.openqa.selenium.By loc_p, String shiftCtrlAlt_p) throws Exception
Not available for remote testing using selenium/appium/saucelabs servers.
Example:
<action code="$click('id=F1','S')"/>
shiftCtrlAlt_p
- S for shift, C for ctrl, A for alt, for example "SA" for holding down Shift and Alt key.loc_p
- shiftCtrlAlt_p
- Exception
- on any errorpublic org.openqa.selenium.WebElement click(org.openqa.selenium.By loc_p, int coordX_p, int coordY_p)
Example:
<action code="$click('id=F1','100','200')"/>Notice that even though coordX_p and coordY_p are integer parameters, they must be enclosed by a set of single quote.
loc_p
- coordX_p
- coordY_p
- public org.openqa.selenium.WebElement doubleClick(org.openqa.selenium.By locator_p)
Example:
<action code="$doubleClick('id=F1')"/>
public org.openqa.selenium.WebElement dragAndDrop(org.openqa.selenium.By fromLocator_p, org.openqa.selenium.By toLocator_p)
Example:
<action code="$dragAndDrop('id=F1','id=f2')"/>The above MScript drags element F1 and drops it on the element f2.
fromLocator_p
- element locatortoLocator_p
- element locatorpublic org.openqa.selenium.WebElement mouseUp(org.openqa.selenium.By locator_p)
Example:
<action code="$mouseUp('id=F1')"/>
locator_p
- public org.openqa.selenium.WebDriver.Timeouts setImplicitWait(long millis_p)
millis_p
- public org.openqa.selenium.WebElement waitForElement(org.openqa.selenium.By locator_p, long timeoutMillis_p)
locator_p
- timeoutMillis_p
- public org.openqa.selenium.WebElement waitForElementText(org.openqa.selenium.By locator_p, String text_p, long timeoutMillis_p)
locator_p
- text_p
- text to be expectedtimeoutMillis_p
- public org.openqa.selenium.WebElement waitForElementEnabled(org.openqa.selenium.By locator_p, long timeoutMillis_p)
locator_p
- timeoutMillis_p
- public org.openqa.selenium.WebElement waitForElementAttr(org.openqa.selenium.By locator_p, String attrName_p, String attrValue_p, long timeoutMillis_p)
locator_p
- attrName_p
- attribute nameattrValue_p
- expected valuetimeoutMillis_p
- Copyright TestOptimal, LLC