Thursday 23 August 2012

All QA people invited to join me on FB

Learn selenium webdriver by example

1. Download Eclipse http://www.eclipse.org/downloads/
2. make new java project http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2FgettingStarted%2Fqs-3.htm
3. Create new class file with main
4. copy paste following code and enjoy 


public class ScrapNaukri {


public static void main(String[] args) throws IOException {

WebDriver driver = new FirefoxDriver();
driver.get("http://www.naukri.com");


driver.findElement(By.xpath("//*[@id='spanid_farea']/input[@id='farea']")).sendKeys("QA & Testing");

//Enter Location
//driver.findElement(By.xpath("//*[@id='ql']")).sendKeys("pune");

// Click on Search
driver.findElement(By.xpath("//*[@id='search']")).click();

//Xpaths
String Start_xpath_searchString = "//*[@id='";
String End_xpath_searchString = "']";


FileWriter fstream = new FileWriter("C:\\outfilename.txt", true);
BufferedWriter out = new BufferedWriter(fstream);


try {
while ((driver.findElement(By.xpath("//*[@id='pageNext']"))) != null) {

//Click on each link of search result
for(int i=1;i<=50;i++){

try{
driver.findElement(By.xpath(Start_xpath_searchString + i +End_xpath_searchString )).click();


// Go to Job Details
Set<String> windowids = driver.getWindowHandles();
Iterator<String> iter= windowids.iterator();


String mainWindowId=iter.next();
iter.next();
String tabbedWindowId=iter.next();

driver.switchTo().window(tabbedWindowId);

try{
driver.findElement(By.xpath("//*[@id='viewBtn']/a")).click();
Thread.sleep(1000);

System.out.println(driver.findElement(By.xpath("//*[@id='contactDet']")).getText());
String test = driver.findElement(By.xpath("//*[@id='contactDet']")).getText();
out.write(test);
out.newLine();

}catch(Exception e){
System.out.println("Skipped-----------------------------" + i);
}

driver.close();
driver.switchTo().window(mainWindowId);
}catch (Exception e) {
System.out.println("No more Page links to click");
}


}

driver.findElement(By.xpath("//*[@id='pageNext']")).click();
}
} catch (Exception e) {
System.out.println("No more Next button");
out.close();
}



driver.quit();
}

Thursday 2 August 2012

Selenium WebDriver Drag & Drop

Below links will help you to explore more Selenium WebDriver Drag & Drop:

1. Selenium WebDriver Using Drag / Drop. [Link]

2. Using Drag and Drop with WebDriver. [Link]

3. Using Drag and Drop in WebDriver. [Link]

4. Python Selenium WebDriver drag-and-drop. [Link]

5. Similar to above one:
Drag-and-drop failing on complex jQuery UI. [Link]

6. HTML5 Drag and Drop using Selenium WebDriver for Ruby. [Link]

7. Drag & Drop with WebDriver. [Link]

Selenium WebDriver & Internet Explorer

Selenium WebDriver & Internet Explorer

Below are some of the links to help you with your efforts to get Selenium WebDriver & Internet Explorer working:

1. Internet Explorer Driver. [Link]

2. How do I start the Internet Explorer WebDriver for Selenium in Python? [Link]

3. Interacting with web pages using Selenium WebDriver for C#. [Link]

4. Selenium Web Driver: InternetExplorerDriver : NoSuchElementException. [Link]

5. Using the Selenium WebDriver. [Link]

6. Selenium WebDriver and InternetExplorer. [Link]

7. Selenium WebDriver error for IE. [Link]

Selenium WebDriver Installation

WebDriver is a clean, fast framework for automated testing of webapps. Selenium WebDriver is not tied to any particular test framework.

Google Opensource blog says: WebDriver takes a different approach to solve the same problem as Selenium. Rather than being a JavaScript application running within the browser, it uses whichever mechanism is most appropriate to control the browser. For Firefox, this means that WebDriver is implemented as an extension. For IE, WebDriver makes use of IE's Automation controls. By changing the mechanism used to control the browser, we can circumvent the restrictions placed on the browser by the JavaScript security model. In those cases where automation through the browser isn't enough, WebDriver can make use of facilities offered by the Operating System. For example, on Windows we simulate typing at the OS level, which means we are more closely modeling how the user interacts with the browser, and that we can type into "file" input elements.

For in-depth knowledge on Selenium WebDriver, see here

Below are few links to help you in the process of Selenium WebDriver installation:
1. WebDriver for Chrome [Link]
2. Setting Up a Selenium-WebDriver Project [Link]
3. Installing Selenium Webdriver on Ubuntu 11 [Link]
4. Installing Selenium Webdriver (selenium-dotnet-2.20.0.zip) [Link]
5. Setting Up a Selenium-WebDriver Project [Link]
6. Selenium Webdriver for Python installation [Link 1] [Link 2]
7. Python - Getting Started With Selenium WebDriver on Ubuntu/Debian [Link]
8. Get started with Selenium 2 [Link]
10. Selenium WebDriver AndroidDriver [Link]

Selenium Element Locator Examples

An element Locator tells Selenium which HTML element a command refers to. The format of a locator is:

locatorType=argument 

Below are some of the awesome links to help you understand Selenium element locator in a better way:

1. Selenium Tutorial : Locators [Link]

2. Locating page elements using WebDriver [Link]

3. How to locate elements in Selenium IDE? [Link]

4. A Quick Introduction to CSS Locators in Selenium [Link]

5. Selenium Element Locators [Link]

6. Selenium Tips: Start improving your locators [Link]

7. Selenium Tips: CSS Selectors in Selenium Demystified [Link]

8. Selenium: Is it possible to use the regexp in selenium locators [Link]

9. How to use regex in selenium locators [Link]

10. Selenium IDE with an XPath Locator [Link]

11. When to use which element locator, element locator use in selenium Xpath,CSS, DOM [Link]

Selenium Element Locator Examples

An element Locator tells Selenium which HTML element a command refers to. The format of a locator is:

locatorType=argument 

Below are some of the awesome links to help you understand Selenium element locator in a better way:

1. Selenium Tutorial : Locators [Link]

2. Locating page elements using WebDriver [Link]

3. How to locate elements in Selenium IDE? [Link]

4. A Quick Introduction to CSS Locators in Selenium [Link]

5. Selenium Element Locators [Link]

6. Selenium Tips: Start improving your locators [Link]

7. Selenium Tips: CSS Selectors in Selenium Demystified [Link]

8. Selenium: Is it possible to use the regexp in selenium locators [Link]

9. How to use regex in selenium locators [Link]

10. Selenium IDE with an XPath Locator [Link]

11. When to use which element locator, element locator use in selenium Xpath,CSS, DOM [Link]

Selenium WebDriver Page Objects

The Page Object pattern represents the screens of your web app as a series of objects. There is a PageFactory in the support package that provides support for this pattern, and helps to remove some boiler-plate code from your Page Objects at the same time.

Below you can find few awesome links on Page Objects in order to understand these in depth:

1. Page Objects in Selenium 2.0
In this post the author looks at the difference between test specification and test implementation and how Selenium achieves this with page objects. [Link]

2. Using Page Objects with Selenium and Web Driver 2.0. [Link]

3. Good explanation of Page Objects, Implementation Notes and an example. [Link]

4. Selenium Page Object Pattern
This post makes you understand how to apply the Page Object design pattern. [Link]

5. Automated Testing Using Page Objects and WebDriver. [Link]

6. Selenium WebDriver: Page Object Pattern and PageFactory. [Link]
This post explains Page Object Pattern, main advantages of Page Object Pattern, Why use PageFactory? and much more.

7. Selenium PageObjects and PageFactory. 
This article discusses the PageObject design pattern and a factory class from WebDriver support libraries. [Link]

8. Abstracting Web Page Interaction. [Link]

9. Selenium 2/Web Driver - the Land Where Page Objects are King! [Link]

10. Page Object Model – Introduction - (infact all posts related to Page Object Model, using Integrate Development Environment, called Eclipse). [Link]

11. Page Objects design issues. [Link]

12. Selenium webdriver page object.
It is tough to figure out how to define each page object BUT lets say I have figured that out and defined several page objects that represent our site. 
How do you handle crossing from page to page. So I get a page object for my home page and one for my account page and one for my results page. Then I need to write a test that traverses all my pages to simulate a user performing multiple actions. [Link]

13. The PageObject pattern for Selenium WebDriver UI tests. [Link]

14. Selenium Page Objects and Abstraction (explanation that relates the page object pattern to the concept of abstraction in programming). [Link]

15. WebDriver: How to check if an page object web element exists? [Link]

Selenium Tutorial Links

People use Selenium for automating web applications for testing purposes.
Selenium is a suite of tools to automate web browsers across many platforms.

Selenium works with many browsers (Firefox, IE, Safari, Opera, Chrome) , operating systems (Windows, OS X, Linux, Solaris), programming languages (C#, JAva, Perl, PHP, Python, Ruby), and testing frameworks(Bromine, JUnit, NUnit, RSpec, Test::Unit, TestNG, unittest). For more on platforms see here.

You can find solutions to most Selenium problems here.

Below are the best tutorials (Selenium links, tutorials, videos, forums etc.) you could ever find on a Selenium:

1.
Selenium Documentation - Link

2.
Selenium Documentation in PDF - Link

3.
Selenium Reference, commands etc. - Link

4.
The silverlight-selenium libraries extend the Selenium RC clients, adding Silverlight communication capabilities to the Selenium RC tests. - Link

5.
Basic Selenium Tutorial PDF - Link

6.
Getting Started with Selenium - awesome Selenium RefCardz - Link

7.
Selenium IDE Tutorial – Part 1 - Link

8.
Selenium IDE Tutorial – Part 2 - Link

9.
Selenium Forum - Link

10.
Another Good Selenium Forum - Link

11.
Selenium: Cross-browser Website Testing - A two page post on Selenium - Link

12.
Automated Web Testing with Selenium - Link

13.
Advanced Selenium - Link

14.
Automation using Selenium - Link

15.
Test Automation Framework – Selenium - Link

16.
Selenium Tutorial - Chapter 1 to Chapter 8 - Link

17.
A small Selenium Tutorial - Link

18.
Test Automation Using Selenium - Link

19.
Functional Testing of ASP.Net Applications with Selenium - Link

20.
How to automate file upload in Internet Explorer using Selenium? - Link

21.
Selenium Browser automation framework - Link

22.
Stories on a Cloud - Distributed Browser Testing with Selenium - Link

23.
Testing web applications with Selenium - Link

24.
Online Selenium Testing - Link

25.
Selenium: Cross-browser Website Testing - A small post on introduction to selenium - Link

26.
Sauce Labs: Run your Selenium tests in our cloud. Save yourself a QA Lab - Link

videos
27.
Learn how to use Selenium with Maven/Ant to automate testing of web apps - Link

28.
Selenium User Meetup 2008: Developer Questions & Answers - Link

29.
Selenium: The in-browser acceptance testing tool - Link

30.
Why Your Selenium Tests Are So Dang Brittle (and What To Do About It) - Link

31.
FLOSS Weekly Interview on Selenium - Link

32.
How Mozilla uses Selenium - Link

33.
Follow Selenium on Facebook - Link

34.
Selenium WebDriver, Selenium Server and PageObjects by Example - Link

35.
Video tutorial: functional testing with Selenium IDE - Link

36.
Get started with Selenium 2 - Link

37.
A Look at Selenium - Better Software - Link

38.
Learn with examples on Selenium WebDriver API - Link

39.
Automated Web Testing with Selenium IDE - Link


You can also download Selenium.