Friday, November 11, 2011

How to locate an element with multiple CSS classes?

Consider if multiple classes are applied to an element, then how to identify it using CSS locator?

See the below HTML element is applied with three CSS classes (i.e. fac, important & cls).

<font class="fac important cls">MULTI CSS</font>

This element can be identified using CSS locator with all the three classes as given below:
String strText1;
strText1=selenium.getText("css=font.fac&&font.important&&font.cls");//Multi CSS
System.out.println(strText1);