SonnetTEST Framework Commands - sonnettest/TestAutomation GitHub Wiki
The following methods are built to handle page synchronization along with required functionalities. Framework waits for certain time (as in configuration - element_wait) to find an element before it throws time out exception. Similarly Framework ensures that element is visible before performing an action.
In case of ajax call where object get refreshed, user can set optional parameters [setting to 'true'] to wait for following element to be available.
Used to identify a webelement based on the locator parameterized and allow to perform action by invoking click(), sendKey() method.
In case of any expection (like element NOT found), framework writes the details to the error log and abort the test. Test will be considered as fail.
Example
findElement(By.xpath("//*[@href='/moc']")).click();
findElement(By.name("USERNAME")).sendKeys("guest");
Used to build collection of elements based on the locator parameterized. It will used where elements will have same attribute details and select based on the location within the collection / certain criteria. The below example explains selecting a color in the combobox / dropdown. Name of the color is read from test data file (maintained in a datasource object - 'productData')
findElements(By.xpath("//li[@class='select_colour']//ul/li//a"))
.selectWebElement(Attributes.TITLE,
productData.GetData("style")).click();
Used to directly perform action on the web element. User needs to pass valid javascript command to perform action.
executeJavaScript("$('#chkOneWay').click();");
Used for ajax calls wherein framework wait for JQuery get processed
Used for wait for executing javascript command.
Return title of the browser.
Return current URL
Return current page source
Switch to window based on the location passed as parameter
Switch to Framework based on name or id given to the frame
Select a frame using its previously located web element
Select a frame based index (zero-based).
Select a frame based index (zero-based) using Java script.
Set focused to parent frame
Selects either the first frame or the main page that contains iframes.
Accept button is clicked on Alert window, if present
Dismiss button is clicked on Alert window, if present
Returns text present on Alert window, if present
Check whether Alert window is present on the browser
Perform keyboard operation
Enter value on the Alert window, if present
The following methods are called following findElement(), findElements(). The method gets invoked once an element is available to perform following action.
Enter data 'inputValue' into editable text box.
Second parameter is optional. In case of Ajax call, user can set to true to wait for element refresh.
It is equivalent to pressing {ENTER} to submit the page.
Wait for current element to be visible before performing any action like click(), sendKeys();
Wait for element to be visible.
Wait for element to refresh post ajax call
Wait for element to visible on the browser
Click on the element identified - like checkbox, button, text box etc
User can set two parameters, which are optional. First parameter is to wait for object refresh (setting to 'true' to wait for completing ajax call).
Second parameter is to wait for page refresh (setting to 'true')
Clear the value in the element identified.
Remove selection of text in the dropdown / combo box
Second parameter is optional. In case of Ajax call, user can set to true to wait for element refresh.
To Select all options that display text matching the given argument. It will not look for any index or value, it will try to match the VisibleText (which will display in dropdown)
Second parameter is optional. In case of Ajax call, user can set to true to wait for element refresh.
Select the options that have a value matching with the given argument by the user
Second parameter is optional. In case of Ajax call, user can set to true to wait for element refresh.
Example:
<select name="Mobiles"><option selectd> Please select</option>
<option value="iphone">iPhone</option>
<option value="nokia">Nokia</option>
<option value="samsung">Samsung</option>
<option value="htc">HTC</option>
<option value="blackberry">BlackBerry</option>
</select>
Remove selected value in the drop down
Second parameter is optional. In case of Ajax call, user can set to true to wait for element refresh.
To Select the option based on the index given by the user. There is an attribute called "values" which will have the index values.
Second parameter is optional. In case of Ajax call, user can set to true to wait for element refresh.
It is an alternative option to method 'selectByVisibleText(String visibleText)'
Second parameter is optional. In case of Ajax call, user can set to true to wait for element refresh.
Returns TRUE if the selected element is empty. Else it returns FALSE
Returns TRUE if the selected element is checked [applicable only for checkbox]. Else it returns FALSE
Returns TRUE if the element is visible on the browser. Else it returns FALSE.
Returns TRUE if the element is editable. Else it returns FALSE.
Return value in the specified attribute of the selected element (selected using findElement() method).
It is alternative to methods like selectByValue() and selectByVisibleText(). It should be called following findElements() method to select a value / element within the collection.
It is alternative to methods like selectByIndex(). It should be called following findElements() method to select a value / element within the collection using index.
Used to assert / verify a selected / identified web element. Expected Value can have two values (as separate parameter) to verify against value in the element and message to be displayed in case verification is successful.
In case assertion fails, expected and actual values will be written to test result.
Move to the element currently identified