Wednesday 8 July 2015

Download Selenium jar from firefox Browser

This post objective is to illustrate how to use Selenium from Firefox Browser.
Java code snippet is here:
@Test

 public void testDownload() throws Exception {

  WebDriver driver = new FirefoxDriver(FirefoxDriverProfile());

  driver.manage().window().maximize();

  driver.get("http://seleniumhq.org");

  Thread.sleep(5000);

  driver.findElement(By.linkText("Download")).click();

  Thread.sleep(5000);

  driver.findElement(By.linkText("2.46.0")).click();

  Thread.sleep(5000);

 }


 public static FirefoxProfile FirefoxDriverProfile() {

  FirefoxProfile profile = new FirefoxProfile();

  profile.setPreference("browser.download.folderlist", 2);

  profile.setPreference("browser.download.manager.showWhenStarting",false);

  profile.setPreference("browser.download.dir", "E:\\sari\\os");

  profile.setPreference("browser.helperApps.neverAsk.openFile","text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml,application/java-archive");

  profile.setPreference("browser.helperApps.neverAsk.saveToDisk","text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,image/png,image/jpeg,text/html,text/plain,application/msword,application/xml,application/java-archive");

  profile.setPreference("browser.helperApps.alwaysAsk.force", false);

  profile.setPreference("browser.download.manager.alertOnEXEOpen", false);

  profile.setPreference("browser.download.manager.focusWhenStarting",false);

  profile.setPreference("browser.download.manager.useWindow", false);

  profile.setPreference("browser.download.manager.showAlertOnComplete",false);

  profile.setPreference("browser.download.manager.closeWhenDone", false);

  return profile;

 }





Monday 6 July 2015

How to read XML File from a Java program?

<?xml version="1.0" ?>
- <listofname>
- <emp id="1001">
  <firstname>saritha</firstname>
  <lastname>chary</lastname>
  <salary>10000</salary>
  </emp>
- <emp id="2001">
  <firstname>Babu</firstname>
  <lastname>BhayaRaj</lastname>
  <salary>1000000</salary>
  </emp>
  </listofname>




Java Program:



package SeleniumPrograms;

import java.io.File;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.Element;

import java.io.File;

public class ReadforXmlfile {

public static void main(String[] args) throws Exception {
 
File fXmlFile = new File("E:\\sari\\os\\list.xml");//xml file path
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
NodeList nList = doc.getElementsByTagName("emp");
System.out.println("_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_");
for (int temp = 0; temp < nList.getLength(); temp++) {
Node nNode =nList.item(temp);
 
System.out.println("\nCurrent Element :" + nNode.getNodeName());//it will display current element node
 
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
 
Element eElement = (Element) nNode;
 
System.out.println("emp id : " + eElement.getAttribute("id"));
System.out.println("First Name : " + eElement.getElementsByTagName("firstname").item(0).getTextContent());
System.out.println("Last Name : " + eElement.getElementsByTagName("lastname").item(0).getTextContent());
System.out.println("Salary : " + eElement.getElementsByTagName("salary").item(0).getTextContent());
 
}
 }}
}
 


Saturday 4 July 2015

Download links for selenium

This post is created in the view of newbies for Selenium Automation and their system setup. In your system make a separate work directory and name it as Selenium-Works. Most of the Windows or Linux systems when you download files it will be stored in the Downloads directory.

Selenium automation Learning Path


These is the starting point of simply learn Selenium Automation. Know basic about Java programming or Python programming. If you know when to use what then it would be time saver and also your efforts.

Here we have URL's for Downloads select your favorite latest and stable versions.
  1. Eclipse used to develop the Java code http://www.eclipse.org/downloads/  --
  2. JDK is required to run the Java. http://www.oracle.com/technetwork/java/javase/downloads/index.html 
  3. Selenium-server-standalone jar file select latest stable version http://docs.seleniumhq.org/download/  --
  4. Firebug  https://addons.mozilla.org/en-US/firefox/adon/firebug/
  5. Firepath https://addons.mozilla.org/en-US/firefox/addon/firepath/ 
  6. ChromeDriver http://chromedriver.storage.googleapis.com/index.html
  7. IE Driver http://docs.seleniumhq.org/download/
  8. Sikuli https://launchpad.net/sikuli/+download  
  9. Bugzilla https://landfill.bugzilla.org/bugzilla-4.4-branch/

Will keep adding soon with latest new browser drivers, which are required in different projects. Most common browsers Mozilla, IE, Chrome related downloads given above. If you found any other driver related information please comment here.

Monday 29 June 2015

Selenium commands

A command is that what tells Selenium framework - what to do. Selenium commands come in three 'flavors':
  1.  Actions,
  2.  Accessors and
  3. Assertions.
 Each command call is one line in the test table of the form:
command
target
value


Actions are commands that generally manipulate the state of the application. They do things like "click this link" and "select that option". If an Action fails, or has an error, the execution of the current test is stopped.

Many Actions can be called with the "AndWait" suffix, e.g. "clickAndWait". This suffix tells Selenium that the action will cause the browser to make a call to the server, and that Selenium should wait for a new page to load.


Accessors examine the state of the application and store the results in variables, e.g. "storeTitle". They are also used to automatically generate Assertions.

Assertions are like Accessors, but they verify that the state of the application conforms to what is expected.
Examples include "make sure the page title is X" and "verify that this checkbox is checked".

All Selenium Assertions can be used in 3 modes: "assert", "verify", and "waitFor". For example, you can "assertText", "verifyText" and "waitForText". When an "assert" fails, the test is aborted. When a "verify" fails,the test will continue execution, logging the failure. This allows a single "assert" to ensure that the application is on the correct page, followed by a bunch of "verify" assertions to test form field values, labels, etc.

"waitFor" commands wait for some condition to become true (which can be useful for testing Ajaxapplications). They will succeed immediately if the condition is already true. However, they will fail and halt the test if the condition does not become true within the current timeout setting (see the setTimeout action below).

Automation Framework Types

Automation framework is broadly divided into 4 different types

·         Linear automation Framework: linear framework mainly based on record and play and follow the procedural code. this framework especially suites for very small projects and for creation of smoke test suites where only basis tests being executed.

·         Structured automation Framework: In Structured framework ,   test cases are writing in more structured way using loops, if else statements, Switch statement and conditional statement, but  it does not have any functions or modularity to make the framework more flexible.

·         Modular automation Framework: In Modular framework, reusable code put in some functions and functions getting called whenever needed. it makes framework more flexible and easy for maintenance.

·         Data-driven automation Framework: When some test needs to repeat for different data set , Data driven framework gets used. In this framework, Parameters in the test case gets linked to databsae, excel, csv, text files from there test case run for all defined parameter in the file.

·         Keyword-driven automation Framework: As Name suggest, Keyword nothing but a code which represent some action, say “login”. in this framework, we map the set of code which perform certain action with a keyword and then we use that keyword across the framework.

·         Hybrid automation Framework: It is nothing but mix of any frameworks together. most popular hybrid automation frameworks are Modular- Data driven and Keyword- data driven.



Sunday 28 June 2015

Software Testing Fundamental Questions and Answers

SOFTWARE TESTING FUNDEMENTALS Questions

1.    Verification part of the V-Model comes after Validation. Say true of false

2.    Performance testing evaluates the time taken of the system to perform its required operation
                   
3.    Identify the severity classification
a)    Show stopper
b)   Medium
c)    Superficial
d)   All the above

4.    In Which model the testing phase starts after the Development phase
a)    V model
b)   Agile model
c)    prototype model
d)   Waterfall model

5.    Activities involved in Verification process:
a)    requirement verification
b)   functional validation
c)    code validation
d)   design validation

6.    Unit Testing testing conduct in order to find out the bug in the code

7.    Say true or false: Each verification activity has its corresponding validation activity True

8.    Synonyms of structural testing
a)    specification based testing
b)   closed box testing
c)   clear box testing
d)   all of the above

9.    Dynamic Testing involves the execution of s/w system

10.  Quality of the software depends on
          a) Usability
          b) Portability
          c) Maintainability
          d) All the above
Integration Testing checks the interaction between the modules

11.  Which of the following is NOT a black box testing technique?
a)    State transition testing
b)   LCSAJ
c)    Syntax testing
d)   BVA
e)    All the above
12.  State  is the condition in which system is waiting for events


13.  Entry criteria for testing
  1. Starting the App server
  2. Designing the test cases
  3. Prioritize test cases
  4. Environmental setup
  5. All the above
14.              Exit criteria & entry criteria for system design

a)    detailed design & business requirement
b)   system requirement & System design document
c)    detailed design & system design document
d)    None of the above

15. During the design phase the emphasis on_________ 
a)    validation
b)   Inspection
c)   Verification
d)  None of the above

16.              Say true or False: Cost of defects would be low if defect find at the          later stages of SDLC False

17. Quality is the indication of how well the s/w meets the requirements

18. Which is not a type of review?
a)    Inspection
b)   Walkthrough
c)    Informal review
d)  Management approval

19. Online testing is the testing of UI & responses in webpage

20. ________ testing ensures that no new defects been introduced after the modification in the code
a)    Retesting
b)  Regression testing
c)    Both a & b
d)   None of the above
 
21. Validation ensures that are we building the product right. Say T or F
              False

22. White Box testing based on the analysis of internal structure of the system
23. Sanity testing checks the stability of the system prior to functional testing

24. Boundary conditions checks in ________& ________ testing
a)    Unit & integration
b)   Integration & system
c)    Unit and System
d)   None of the above

25. Integration testing methods:
a)    top-down integration
b)   sandwich integration
c)    bottom up integration
d)   All the above

26. Software Reliability is the probability that s/w will not fail for specified period of time

27. Software testing is oriented to Detection

28. Mismatch between the requirements & in the application is called Defect

29. In which phase of SDLC, the requirements are broken into modules

                     Ans: System Design

30. Testing without test cases document is called Ad-Hoc Testing

31. Find the odd man out:
a)    Regression testing
b)   Mutation testing
c)    GUI Testing
d)   Adhoc testing

32. classification of Performance testing
a)    Load testing
b)   Database testing
c)    Stress testing
d)   All the above

33. Which of the following is a test type?
a)    Component testing
b)   Functional Testing
c)    System testing
d)   Acceptance testing

34. Beta testing is :
a)    performed by customers at development site
b)   performed by an independent test team
c)    Performed by customers at their own site
d)   None of the above

35. Agile model is used when requirements changes frequently
a)    Waterfall
b)   Incremental
c)    Prototype
d)   Agile

36. Objectives of testing?
a)    Early defects
b)   Gaining confidence
c)    Preventing defects            
d)  All of the above

37.              Static testing methodologies are:
a.    Inspection
b.    Review
c.    Walkthrough
d.   All of the above

38.   Test automation makes the regression testing cost effective & good coverage. Say true or false True

39.  Set of jobs or data to be processed in a single execution is called Batch

40.  Testing a selected test cases rather than taking all test cases is called
a.    Adhoc testing
b.    Regression testing
c.    Sanity testing
d.    None of the above

41. Functional testing which is informal & unplanned called Ad-Hoc Testing

42. Levels of testing: Unit Testing, System Testing, Integraation Testing,   Acceptance Testing

43.  Testing to be done on different languages & for the system content Localization Testing or Globalization Testing

44.  Testing of the software used to convert data from existing system to the latest system is called as Migration Testing

45.  Name the black box testing technique
a)    Boundary value
b)   State transition
c)    Decision table
d)  All of the above
46.               _______ is a human action that produces incorrect result

a)    Fault
b)   Mistake
c)    Defect
d)   All of the above

47.  Volume testing where the system is subjected to large volume of data

48. V model defines how testing activities can be integrated into each phase of software development life cycle

49. SRS document is the base document for testing?

50. During the testing phase the emphasis on_________ 
a)    Inspection
b)   Verification
c)    validation

d)   None of then above