How to search for element



BAS allows to search element in different ways: css, markup part, xpath, coordinates.

By default unique element selector will be generated for you automatically and you don't need to bother about it.

But you can edit default selector or make your own by editing following field:

This widget will appear on any action, which is executed on element.

Widget is located on the upper right corner.



Lets consider following examples:

Css seletors

All css selector are preceded with >CSS> prefix, this prefix tells BAS, that developer uses CSS.



>CSS> #element-id

Find element by id



>CSS> .element-class

Find element by class



>CSS> [attribute*="value part"]

Find element, whith attribute, that contains value part

See this manual for more information https://developer.mozilla.org/en-US/docs/Learn/CSS/Introduction_to_CSS/Selectors



Several >CSS> prefixes may be combined.

>CSS> #element-parent >CSS> #element-id-child

Find element with id element-child inside element element-parent



You can find element with index using >AT> prefix.

>CSS> .element-class >AT> 0

Find first element with class element-class

This selector is identical to:

>CSS> .element-class



>CSS> .element-class>AT> 1

Find second element with class element-class



Variables and resources may be used instead of exact values:

>CSS> #element-class >AT> [[CYCLE_INDEX]]

Find [[CYCLE_INDEX]] element with class element-class



You can combine as much prefixes as you want:

>CSS> #element-parent >CSS> #element-id-child >AT> 0

Match seletors

Another type of selectors is match. It selects element by part of its markup. If you have element with follwoing markup:

You can select it with

>MATCH>title="Search"

Any markup type will do:

>MATCH>autocomplete="off" title="Search"

>MATCH>tle="Search"

etc.



Same as with css, you can combine several match prefixes:

>MATCH>match1>MATCH>match2



Use >AT> prefix:

>MATCH>match1>AT>0



And combine >MATCH> with >CSS>:

>MATCH>match1>CSS>css1>AT>0



It is important to avoid using additional spaces with >MATCH> prefix. All spaces becomes part of selector and may affect result.

Wrong:

>MATCH> match1
Correct:
>MATCH>match1



XPATH seletors

BAS allows to use xpath selector with >XPATH> prefix.

For example:

>XPATH> (//a)[last()]

Find last reference.

You can combine >XPATH>, >CSS>, >MATCH> and >AT>



Xpath queries inside certain element must be relative(must start from dot).

>XPATH> //*[@id='element-parent'] >XPATH> .//*[@id='element-child']



Frames

You can access frame content with >FRAME> prefix



>CSS> #frame-id >FRAME> >CSS> #element-id

This query selects element with id element-id inside frame with id frame-id



Nested frames are also supported:

>CSS> #frame-id1 >FRAME> >CSS> #frame-id2 >FRAME> >CSS> #element-id

This query selects element with id element-id inside frame with id frame-id2 inside frame with id frame-id1



Of course, several prefixes can be used

>CSS> iframe >AT> 1 >FRAME> >CSS> #element-id

This query selects element with id element-id inside second frame