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]