Skip to main content

Almond Automation Selector

This page describe all the selectors available in Almond Automation.
Selectors are used to locate element on html page to perform action.
Almond Automation provides many ways to select any element on html page easily.

Almond Automation you can specify selectors in following way
selector-type=selector-value
selector-type could be of following types
  1. id: it searches for element which matches exact id.
  2. name: it searches for element which matches exact name.
  3. css: This is selenium driver css selector.
  4. xpath: It locate element by xpath.
  5. script: In very complex scenario when none of the above selector work then you can use any javascript code to select element.

ID Selector

This selector is simplest to use. You can easily select element if they have well defined id.
Following are some examples for id selector

Html Almond Automation Selector
<input id="username" type="text" /> id=username
<button id="saveTestCase">Save TestCase</button> id=saveTestCase

NAME Selector

This selector is also similar to ID selector. You can easily select element if they have well defined name. Following are some examples for name selector

Html
Almond Automation Selector
<input name="username" type="text" />
name=username
<button name="saveTestCase">Save TestCase</button>
name=saveTestCase

CSS Selector

This selector is nothing but selenium css selector. This is very powerful and you can locate almost anything using this selector. You can find lots of tutorial in google for selenium css selector. Following are some examples for name selector

Html
Almond Automation Selector
Comment
<input id="username" type="text" />
css=input[id=username]
locate element by id
<a href="servlets">Servlets examples</a>
css=a[href='servlets']
locate link with given href
<div class="almond" style="display:block">
css=div[class='ajax_enabled'] [style='display:block]
locate div with given class and display property as block

XPATH Selector

This selector is selenium xpath selector.

SCRIPT Selector

This selector is specific to Almond Automation.
This is nothing but pure javascript.
In some scenario when no selector works you can block of javascript code to locate element.
Only condition of javascript code is that it should return one and only one element.
I was using jointjs library to create flowchart. Jointjs creates lots of element and it is very difficult to draw flowchart from one node to another. I have created this selector for complex scenario.
Following are some examples for script selector for simple scenario

Html Almond Automation Selector
<input id="username" type="text" /> script=document.getElementById('username')
lots of html element and you want to locate which matches specific condition script=line1;line2;

Comments