Sunday, January 30, 2011

Example for using GetEval in selenium to get the list of checkbox ids...

import com.thoughtworks.selenium.DefaultSelenium; public class CheckBoxesStatusTest { public static void main(String[] args) { DefaultSelenium selenium = new DefaultSelenium("localhost", 8888, "iexplore", "http://browsershots.org/"); selenium.start(); selenium.open("http://browsershots.org/"); selenium.waitForPageToLoad("30000"); String checkBoxIds = selenium.getEval("function getCheckBoxsStatus() {" + "var cbgChkRefid='checked:';" + "var chkCounter=0;" + "var cbgNonChkRefid='unchecked:';" + "var unchkCounter=0;" + "var docref = window.document;" + "var ipRef=docref.getElementById('startform').getElementsByTagName('input');" + "for(var k=0;k< ipRef.length;k++){ +" if (ipRef[k].type == 'checkbox') { +" if (ipRef[k].checked) { +" chkCounter = chkCounter + 1; " +" cbgChkRefid = cbgChkRefid + ' ' + ipRef[k].id; + " } +" else { " +" unchkCounter = unchkCounter + 1; " +" cbgNonChkRefid = cbgNonChkRefid + ' ' + ipRef[k].id; "+" } "+" } "+" } "+" return (cbgChkRefid + ' cheked Checkboxes Number' + chkCounter.toString() + '::' + cbgNonChkRefid + ' uncheked Checkboxes Number' + unchkCounter.toString() + ' totalNumberofcheckboxesonthePage:' + ipRef.length); "+" } "+" getCheckBoxsStatus(); "); checkBoxIds = checkBoxIds.replaceAll(": ", "\n "); System.out.println("All checked and Unchecked IDS: \n"+checkBoxIds.replaceAll(": ", "\n ")); System.out.println("All checked and Unchecked IDS in line by lineformat: \n "+checkBoxIds.replaceAll("", "\n ")); } }

Saturday, January 15, 2011

REFERENCCE LINKS FOR LOCATORS

http://www.w3.org/TR/xpath20/

http://www.w3.org/TR/2001/CR-css3-selectors-20011113/

http://www.w3.org/TR/CSS2/selector.html

Go through the above links which contain massive information on the locators....


This Pdf contains selenium Info ...

http://www.lucid-forums.com/downloads/Selenium.pdf

Working with Color Boxes and AJAX Loading in Selenium

Nowadays the fashion for developers is to use the light boxes or color boxes in the web applications.. to impress the end users .... Inorder to test such scenarios using selenium follow the below steps... It is to notice that the color boxes will appear in UI after some user interaction in the web page. So in case of color boxes the development code is as follows ..

Generally the HTML related to colorbox is already embedded in the webpage when you navigate.
Here one need to concentrate what is going on in the UI when a user performs some set of operations... As per my knowledge there will be some divs in webpage added with a dynamic content and some gray layer is added to the main page ...
So the selenium code to identify such color boxes should be some thing like this ....


  • Perform an event
  • Wait for the response
  • Check the UI is showing that div or not ....
  • Later on perform the necessary actions there....
Sample code would be as follows...


selenium.click("click the item which causes colorbox to open");

Run an infinite for loop .....

for(int i=0;;i++){
try {
if(selenium.isVisible("//div[@id='ajaxResp']")){
System.out.println("Found");
System.out.println(selenium.getText("//div[@id='ajaxResp']"));
break;
}else{
Thread.sleep(1000);
}
}catch(Exception e){

}
}

In the above program assume "ajaxResp" is the ID of the division which gets visible whenever the colorbox content is loaded in that DIV. If that div is visible then we can write the necessary tests we need to perform there...

For explanation .... the for loop first checks whether the div with id "ajaxResp" is visible or not...
if it is not visible it will stop the current thread execution for one second and the loop iterates again .... like wise it will keep on iterate until that div gets visible... there by we can perform the necessary actions there and ... the loop breaks there.....
If you want to cross verify whether the div is there or not .... do a getAttribute or isElementPresent on that div...

The getAttribute("XPATH OF COLOR BOX DIV@style")
gives a string we need to check whether display:none or visibility:hidden is set in that div or not.... If any one of this string is find then we can ensure that the div is available in the page but it is in hidden mode....

Same code is helpful in case of ajax applications.....

Working with frames in selenium





Assume some times we need to write the test cases for frames applications.
In Such case the thing we need to follow is to check for the frame id .
In the main window the frames are being embedded.
So always to perform any action on frames content first we need to move our cursor to the frame using the selenium API. Check the below program...

package com.tests;

import junit.framework.*;

import com.thoughtworks.selenium.DefaultSelenium;

public class FramesDemo extends TestCase{
public static void main(String[] args) {
try{

DefaultSelenium selenium = new DefaultSelenium("localhost", 8888, "*firefox","http://localhost:8383");
selenium.start();
selenium.open("http://localhost:8383/testApplication/test.jsp");
selenium.setSpeed("2000");
System.out.println("Page Title "+selenium.getTitle());
assertEquals("Frames Concept", selenium.getTitle());
selenium.highlight("firstframe");
selenium.selectFrame("firstframe");
System.out.println("First frame Data "+selenium.getText("//div[@id='first']"));
selenium.selectFrame("relative=up");
selenium.highlight("secondframe");
selenium.selectFrame("secondframe");
System.out.println("Second frame Data "+selenium.getText("//div[@id='second']"));
selenium.selectFrame("relative=up");
selenium.highlight("thirdframe");
selenium.selectFrame("thirdframe");
System.out.println("Third frame Data "+selenium.getText("//div[@id='third']"));
selenium.selectFrame("relative=up");
selenium.highlight("fourthframe");
selenium.selectFrame("fourthframe");
System.out.println("Fourth frame Data "+selenium.getText("//div[@id='fourth']"));
selenium.selectFrame("relative=up");
selenium.selectFrame("secondframe");
selenium.highlight("link=Click Me to go to ThirdFrame");
selenium.click("link=Click Me to go to ThirdFrame");
selenium.waitForFrameToLoad("thirdFrame", "30000");
selenium.selectFrame("relative=up");
selenium.highlight("thirdframe");
selenium.selectFrame("thirdframe");
System.out.println("Third frame Data after Refresh "+selenium.getText("//div[@id='third']"));
System.out.println("Third frame Data in iframe is "+selenium.getText("//div[@id='fourth']"));

}catch(Exception e){
e.printStackTrace();
}
}
}

So using selectFrame we can select any frame and perform needed actions there and back to main window using selenium.selectFrame("relative=up"); .....

Hope this helps.....

Friday, January 14, 2011

Handling popup windows in selenium

Handling pop up windows in selenium is a good mechanism.
All you need to know is pop up window ID.
In general pop up windows are generated in a website with some javascript code .
That particular code is as follows.

window.open('url','windowname','properties');

or

window.open('url','','properties');

So in the first case we can be able to identify the pop up window in selenium.
Where as with second case we cannot be able to recognize the popup window.



Follow the below steps to recognize a pop up and move your control onto that pop up and do the necessary actions there and return back to main window.


package com.tests;

import com.thoughtworks.selenium.DefaultSelenium;

public class PopUpWindowDemo {

public static void main(String[] args) {
try {
DefaultSelenium selenium = new DefaultSelenium("localhost", 8888,"*iexplore", "http://localhost:8383");
selenium.start();
selenium.open("http://localhost:8383/testApplication/mainPage.jsp");

selenium.click("link=Click Me");
String[] winNames = selenium.getAllWindowNames();
for (String winName : winNames) {
if (!winName.contains("selenium")) {
selenium.waitForPopUp(winName, "30000");
selenium.selectWindow(winName);
selenium.windowFocus();
//Here u can write the steps related to pop up window....
//Close the pop up once all the manipulations in the pop up window done successfully...
//Move the cursor to the main Window using the selenium.selectWindow("null") or selenium.selectWindow("")
if(selenium.isElementPresent("//div[@id='popUpDiv']")){
System.out.println("U r successfully entered in pop up window");
System.out.println("Text in the pop up Window "+selenium.getText("//div[@id='popUpDiv']"));
if(selenium.isElementPresent("link=Close Me")){
selenium.click("link=Close Me");
}

}else{
System.out.println("U r not successfully entered in pop up window");
}
selenium.selectWindow("null");
selenium.windowFocus();
//Now the cursor is returned to the main window
//Do the operations on the main window...

}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}




XPATH LOCATORS DEMO JAVA FILE



package com.demo.tests;

import com.thoughtworks.selenium.DefaultSelenium;

public class XPATHLocatorsDefinitionTest {


public static void main(String[] args) {
try{
int i = 1;
int count = 0;
int noOfRows = 0;
String optionLabel = "";
String searchableString = "Two";
DefaultSelenium selenium = new DefaultSelenium("localhost", 8888, "*iexplore","http://localhost:8383");
selenium.start();
selenium.open("http://localhost:8383/testApplication/cssLocators.html");
selenium.setSpeed("3000");
selenium.windowMaximize();
/**
* isElementPresent is a method for checking whether the element given in xpath is showing in the page or not
* It will return true if the element is displayed or false if the element is not displayed
* For every css locator u need to use / or // or xpath= prior to every locator.
* Finding the number of rows in a Table
* Here infoTable is the table ID
* We refer an element with the ID as follows E[@id=value] Here E stands for element.
* id stands for ID of that particular element
* Here the locator table[@id='infoTable']/tbody/tr["+i+"]
* The first part table[@id='infoTable']/tbody/tr["+i+"] indicates we are referring the row of a table
* If we want to refer the first row table tr[1] indicates the first row reference
* Through tr[arg] is a index location used for finding the paticular child of the parent.
* Here arg is the location of the child like 1,2,3,........with respect to table
*/

while(selenium.isElementPresent("//table[@id='infoTable']/tbody/tr["+i+"]")){
noOfRows++;
i++;
}
System.out.println("The number of rows in the Table are : "+noOfRows);

/**
* Fetching the complete rows Data
* Here all the rows Data is gathered
* We can pass through the index from 1,2,3.........
*/

i = 1;
while(selenium.isElementPresent("//table[@id='infoTable']/tbody/tr["+i+"]")){
System.out.println(""+i+" Row Data "+selenium.getText("//table[@id='infoTable']/tbody/tr["+i+"]"));
i++;
}

for(i=1;i<=noOfRows;i++){
System.out.println("Value of i "+i);
if(selenium.getText("//table[@id='infoTable']/tbody/tr["+i+"]/td[2]").indexOf("Two")!=-1){
count++;
}
}
System.out.println("The no of rows in a table that has the Vendor column data has "+searchableString+" is : "+count);


selenium.highlight("//table[@id='infoTable']");
System.out.println("Getting the Table Data From The Body Tag");
System.out.println(selenium.getText("//body/table[@id='infoTable']"));


/**
* This is the example for finding the particular Element in the page using its immediate adjacent Element
* This is very useful When u have same link like
* Administrator Login
* Registered User Login
* Like here Login is a common link but we need to identify it with the adjacent text beside the Login
* Here i am finding the
*/
System.out.println("Highlight Adjacent Elements ");
selenium.highlight("//span[contains(text(),'Administrator')]/following-sibling::a");
System.out.println("First Anchor Data "+selenium.getText("//span[contains(text(),'Registered User')]/following-sibling::a"));
System.out.println("Anchor with text data "+selenium.getText("//a[contains(text(),'Login')]"));


if(selenium.isElementPresent("//div[@id='adminWelcome']")){
System.out.println("Admin Welcome message Using E[@id=value] notation "+selenium.getText("//div[@id='adminWelcome']"));
}else{
System.out.println("Admin Welcome message Using E[@id=value] notation not found");
}

if(selenium.isElementPresent("//div[contains(@id,'Welcome')]")){
System.out.println("Admin Welcome message Using E[contains(@att,value)] notation "+selenium.getText("//div[contains(@id,'Welcome')]"));
}else{
System.out.println("Admin Welcome message Using E[contains(@att,value)] notation not found");
}

if(selenium.isElementPresent("//div[@class='adminRelated']")){
System.out.println("Admin Welcome message Using E[@class=value] notation "+selenium.getText("//div[@class='adminRelated']"));
}else{
System.out.println("Admin Welcome message Using E[@class=value] notation not found");
}

i = 1;
noOfRows = 0;
while(selenium.isElementPresent("//select[@id='country']/option["+i+"]")){
noOfRows++;
i++;
}
for(i=1;i<=noOfRows;i++){
optionLabel = selenium.getText("//select[@id='country']/option["+i+"]");
selenium.select("css=select#country", "label="+optionLabel);
selenium.select("css=select#country", "label="+optionLabel);
System.out.println(""+i+" Option Value : "+selenium.getSelectedValue("//select[@id='country']")+" Option Label "+optionLabel);
}

/**
* Checking for the element with the attributes disabled and checked
*/
if(selenium.isElementPresent("//input[@type='text' and @id='ipBox']")){
if(selenium.getAttribute("//input[@type='text' and @id='ipBox']@disabled").equals("true")){
System.out.println("The input field is disabled");
System.out.println("The input field value is : "+selenium.getValue("//input[@type='text' and @id='ipBox']"));
}else{
System.out.println("In not entering");
}
}else{
System.out.println("The input field is not displayed");
}
if(selenium.isChecked("//input[@type='checkbox' and @id='chkBox']")){
System.out.println("The input field is checked");
}else{
System.out.println("The input field is not checked");
}
}catch(Exception e){
e.printStackTrace();
}
}

}

HTML FILE TO IDENTIFY THE CSS AND XPATH FOR THE ABOVE MENTIONED RULES

Odd Meerasaab ThreeOdd
Even Two2EvenClick Me Three2Even
One3 Two3 Three3

This

headline is very

important


Administrator Login

Registered UserLogin

Welcome Administrator

Ramesh
Hi Meera Hi vamsi



The above is the HTML for which i am writing the Java class .
In this Java class i am trying to include how to use the css and xpath locators for all the mentioned html elements like div,select,input,links and many more.
In the java class read the comments well to understand the things so simple and there is a good comments set for each operation.



JAVA CLASS FOR THE DEMO OF USING CSS LOCATORS

package com.tests;

import com.thoughtworks.selenium.DefaultSelenium;

/**
* The CSSLocatorsDefinitionTest tells how the various css locators will work
* @author - meerasaab786@gmail.com (Meerasaaheb Mohmmad)
*/

public class CSSLocatorsDefinitionTest {

public static void main(String[] args) {
try{
int i = 1;
int count = 0;
int noOfRows = 0;
String optionLabel = "";
String searchableString = "Two";
DefaultSelenium selenium = new DefaultSelenium("localhost", 8888, "*firefox","http://localhost:8383");
selenium.start();
selenium.open("http://localhost:8383/applicationname/cssLocators.html");

/**
* isElementPresent is a method for checking whether the element given in xpath is showing in the page or not
* It will return true if the element is displayed or false if the element is not displayed
* For every css locator u need to use css= prior to every locator.
* Finding the number of rows in a Table
* Here infoTable is the table ID
* We refer an element with the ID as follows E#id Here E stands for element.
* id stands for ID of that particular element
* Here the locator table#infoTable tr:nth-child("+i+")
* The first part (table#infoTable tr) indicates we are referring the row of a table
* If we want to refer the first row table tr:nth-child(1) indicates the first row reference
* Through nth-child(arg) is a method used for finding the paticular child of the parent.
* Here arg is the location of the child like 1,2,3,........
*/
while(selenium.isElementPresent("css=table#infoTable tr:nth-child("+i+")")){
noOfRows++;
i++;
}
System.out.println("The number of rows in the Table are : "+noOfRows);
/**
* Finding the complete rows Data
* Here all the rows Data is gathered
* We can pass through the index from 1,2,3.........
*/
i = 1;
while(selenium.isElementPresent("css=table#infoTable tr:nth-child("+i+")")){
System.out.println(""+i+" Row Data "+selenium.getText("css=table#infoTable tr:nth-child("+i+")"));
i++;
}

/**
* I am included this because we have tested this functionality using XPATH locators
* This is the functionality for testing the no of times the rows have a column as "Two".
* contains(arg) is a method to check whether the particular reference has the data as arg in it.
* Here in our case the I am checking the row has the data of "Two" in the second column.
* The Symbol E'>'F is used to find the element F which is the child of E.
* In the below case css=table#infoTable tr:nth-child("+i+")>td
* E stand for css=table#infoTable tr:nth-child("+i+")
* and F stands for the td
* E>F means is finding the first td of the corresponding tr i,e 1,2,3,4.....
* The Symbol '~' is used for finding the element that is adjacent to it.
* E~F means finding the element F which is present adjecent to it(i,e E). *
*
*/
for(i=1;itd~td:contains(searchableString)")){
count++;
}
}
System.out.println("The no of rows in a table that has the Vendor column data has "+searchableString+" is : "+count);

/**
* Highlight is a method in selenium which is used for highlighting a specific Element
* selenium.highlight(String locator)
* Here i am highlighting the table i,e dispalyed in the web page cssLocators.html
* The below is a way of accessing the child element from the parent
* Syntax E F
* The space between E and F is a must
* Here E denotes the body and F denotes the child i,e a table with id infoTable
*
*/

selenium.highlight("css=body table#infoTable");
System.out.println("Getting the Table Data From The Body Tag");
System.out.println(selenium.getText("css=body table"));

/**
* Accessing the first child Element of a particular parent
* :first-child is a pseudo class defined for accessing the first child in the parent
* Similarly we have last-child also
*/

System.out.println("FirstChild of h1 "+selenium.getText("css=h1 p:first-child"));
System.out.println("FirstChild of h1 "+selenium.getText("css=h1 p"));

/**
* The below is the code snippet for getting all the childs that have paragraph tag inside the h1 tag
*/
System.out.println("FirstChild of h1 with descendent child "+selenium.getText("css=h1 * p"));

/**
* This is the example for finding the particular Element in the page using its immediate adjacent Element
* This is very useful When u have same link like
* Administrator Login
* Registered User Login
* Like here Login is a common link but we need to identify it with the adjacent text beside the Login
* Here i am finding the
*/
System.out.println("Highlight Adjacent Elements ");
selenium.highlight("css=span:contains('Administrator') + a:contains('Login')");
System.out.println("First Anchor Data "+selenium.getText("css=span:contains('Registered User') + a:contains('Login')"));

System.out.println("First Anchor Data with Tilde is :: "+selenium.getText("css=span:contains('Registered User') ~ a:contains('Login')"));

/**
* Highlighting the same adjecent element Using the CSS Mixing
* E + F
* Finding the element F which is exactly adjacent to the Element E.
* Locating the Element using its ID has the following syntax
* K[attribute=value]
* K[id='nameId'] Here i am finding the span element that has nameId as its id
*
*/
selenium.highlight("css=span[id='nameId'] + a:contains('Login')");
System.out.println("Anchor Data using attribute "+selenium.getText("css=span[id='nameId'] + a:contains('Login')"));
System.out.println("Anchor with text data "+selenium.getText("//a[contains(text(),'Login')]"));

/**
* Accessing the element with its ID and classname
* Here we can use the locator as follows
* E[att=value] Matches the Element E with the attributes exact value
* E#id Matches the Element E with the ID
* E[att$=value] Matches the Element E with the attribute value ends with the provided value
* E[att*=value] Matches the Element E with the attribute value conatins value at any position
* E.cssClassName Matches the Element E with cssClassName provided
*/

if(selenium.isElementPresent("css=div#adminWelcome")){
System.out.println("Admin Welcome message Using Hash i,e E#id notation "+selenium.getText("css=div#adminWelcome"));
}else{
System.out.println("Admin Welcome message Using Hash i,e E#id notation not found");
}
if(selenium.isElementPresent("css=div[id=adminWelcome]")){
System.out.println("Admin Welcome message Using E[att=value] notation "+selenium.getText("css=div[id=adminWelcome]"));
}else{
System.out.println("Admin Welcome message Using E[att=value] notation not found");
}
if(selenium.isElementPresent("css=div[id$=Welcome]")){
System.out.println("Admin Welcome message Using E[att$=value] notation "+selenium.getText("css=div[id$=Welcome]"));
}else{
System.out.println("Admin Welcome message Using E[att$=value] notation not found");
}
if(selenium.isElementPresent("css=div[id*=admin]")){
System.out.println("Admin Welcome message Using E[att*=value] notation "+selenium.getText("css=div[id*=admin]"));
}else{
System.out.println("Admin Welcome message Using E[att*=value] notation not found");
}
if(selenium.isElementPresent("css=div.adminRelated")){
System.out.println("Admin Welcome message Using E[att*=value] notation "+selenium.getText("css=div.adminRelated"));
}else{
System.out.println("Admin Welcome message Using E[att*=value] notation not found");
}
/**
* Example for a descendant id('select')/descendant::*
*/
System.out.println("Descendant ::: "+selenium.getText("xpath=/descendant::tr"));
i = 1;
noOfRows = 0;
while(selenium.isElementPresent("css=select#country>option:nth-child("+i+")")){
noOfRows++;
i++;
}
for(i=1;i<=noOfRows;i++){ optionLabel = selenium.getText("css=select#country>option:nth-child("+i+")");
selenium.select("css=select#country", "label="+optionLabel);
System.out.println(""+i+" Option Value : "+selenium.getSelectedValue("css=select#country")+" Option Label "+optionLabel);
}

if(selenium.isElementPresent("//div[@id='country1']")){
System.out.println("Data");
System.out.println(selenium.getText("//div[@id='country1']"));
}else{
System.out.println("Not found");
}
if(selenium.isElementPresent("//select")){
System.out.println("Data in Select ");
System.out.println(selenium.getText("//select"));
}else{
System.out.println("Not found");
}

/**
* Clicking the checkbox in a td with the assumed link in the desired tr
*/
if(selenium.isElementPresent("//tr[descendant::td/a[contains(text(),'Click')]]/td/input[@name='chkBox']")){
selenium.click("//tr[descendant::td/a[contains(text(),'Click')]]/td/input[@name='chkBox']");
}

if(selenium.isElementPresent("css=tr:nth-child(2):contains('Click')>td>input")){
selenium.click("css=tr:nth-child(2):contains('Click')>td>input");
}
if(selenium.isElementPresent("//descendant::select")){
System.out.println("Yesssssssss "+selenium.getText("//descendant::select"));
}else{
System.out.println("Noooooooooooo");
}
System.out.println("Hidden Field Text "+selenium.getValue("//input[@id='hiddenName']"));
/*selenium.keyPress("akku", "34");
selenium.type("akku", "34");
selenium.keyPress("five", "34");
selenium.type("five", "34");*/


if(selenium.isElementPresent("css=table tr>td:nth-child(indexOftheMailSubject):contains('Ur desired Subject')")){
System.out.println("The element Found");
}else{
System.out.println("The element not Found");
}


selenium.select("//select[@name='locations:selectedLocation']","label=India");

}catch(Exception e){
e.printStackTrace();
}
}
}



XPATH Locators

Pattern Meaning
//E an element of type E
//E[@foo="bar"] an E element whose "foo" attribute value is exactly equal to "bar"
//E[contains(text(),"foo")] an E element containing the substring "foo" in its textual contents
//E[contains(@foo,"value")] an E element containing the substring "value" in the attribute foo
//E[@foo="bar" and @foo1="bar1"] an E element whose "foo" attribute value is exactly equal to "bar" and "foo1" attribute value is exactly equal to "bar1"
//E[descendant::F] an E element which contains the F as its child
//E/following-sibling::F an F element which has an adjacent element as E
//E/preceding-sibling::F an F element which is beside E



IDENTIFY AN ELEMENT USING MULTIPLE ATTRIBUTES

Eg: Using XPATH AND CSS


To combine the css locators for multiple attributes use the following way..
css=E[foo='abc'][foo1='abcs'][foo2='abcd'] and so on...
for xpath locators using and u can combine..
//E[@foo="bar" and @foo1="bar1"]
Use getAttribute method to get any element attribte
See the attribute values using firebug suppose

Div Text


to get the style attribute from the above div use some thing like below.
String divStyle = selenium.getAttribute(XPATHOFDIV@style);
String divStyle = selenium.getAttribute(CSSLOCATOR OF DIV@style);
Eg:: String divStyle = selenium.getAttribute(//div[@id='one']@style);
or use CSS locators too..
String divStyle = selenium.getAttribute(css=div[id='one']@style);

Thursday, January 13, 2011

CSS Locators

Pattern Meaning
E an element of type E
E[foo] an E element with a "foo" attribute
E[foo="bar"] an E element whose "foo" attribute value is exactly equal to "bar"
E[foo~="bar"] an E element whose "foo" attribute value is a list of space-separated values, one of which is exactly equal to "bar"
E[foo^="bar"] an E element whose "foo" attribute value begins exactly with the string "bar"
E[foo$="bar"] an E element whose "foo" attribute value ends exactly with the string "bar"
E[foo*="bar"] an E element whose "foo" attribute value contains the substring "bar"
E:nth-child(n) an E element, the n-th child of its parent
E:nth-last-child(n) an E element, the n-th child of its parent, counting from the last one
E:first-child an E element, first child of its parent
E:last-child an E element, last child of its parent
E:only-child an E element, only child of its parent
E:only-of-type an E element, only sibling of its type
E:empty an E element that has no children (including text nodes)
E:active
E:hover
E:focus
an E element during certain user actions
E:enabled
E:disabled
a user interface element E which is enabled or disabled
E:checked a user interface element E which is checked or in an indeterminate state (for instance a radio-button or checkbox)
E:contains("foo") an E element containing the substring "foo" in its textual contents
E#myid an E element with ID equal to "myid".
E:not(s) an E element that does not match simple selector s
E F an F element descendant of an E element
E > F an F element child of an E element
E + F an F element immediately preceded by an E element
E ~ F an F element preceded by an E element

Basic Introduction of selenium

Hi All,
In my opinion selenium is a wonderful tool for automatic web application testing.
I believe selenium testing is a manual testing where a computer see a webpage content using xpath and css locators. To get succeded in selenium concentrate more on the User Interface ....
like how the website is behaving with user actions etc...

For testing a web application using selenium a user has to have aware on this below mentioned things.
  • Locators ( XPath Locators , CSS Locators , DOM locators,Javascript locators)
  • Basic scripting language knowledge
To master in selenium a user has to have good knowledge in locators first and have a basic knowledge on any language like Java,Perl,C# for writing the selenium scripts.So in my opinion learning any testing framework is not a big deal.
To rock in selenium spend dedicated time on learning XPATH and CSS locators first. Later on any testing framework utilization like JUNIT,TESTNG will be an added advantage.

I am about to share knowledge i have on xpath and css locators and dom locators.