Test automation involves using software to execute test cases, compare outcomes against predictions, and report results. Commonly automated tasks were previously done manually, like regression testing. Selenium is an open-source tool that supports test automation for web applications across browsers and operating systems using various programming languages. To use Selenium, one must install it as a plugin or library and learn at least one supported language to author test cases.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
82 views98 pages
Test Automation Is The Use of Software
Test automation involves using software to execute test cases, compare outcomes against predictions, and report results. Commonly automated tasks were previously done manually, like regression testing. Selenium is an open-source tool that supports test automation for web applications across browsers and operating systems using various programming languages. To use Selenium, one must install it as a plugin or library and learn at least one supported language to author test cases.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 98
Test automation is the use of software
To control the execution of tests.
To compare the actual outcomes to predicted outcomes. To report the Execution Status.
Commonly, test automation involves automating a manual process
Frequent regression testing Repeated test case Execution is required Faster Feedback to the developers Reduce the Human Effort Test same application on multiple environments
Quick Test Professional By HP Rational Functional Tester By Rational (IBM Company) Silk Test By Borland Test Complete By Automated QA Selenium ( Open Source)
Selenium is an open source automation testing tool for web based applications. Its easy to use, strong and is very flexible. You can work on many operating systems using selenium and you can code in any one of the following languages when using selenium.
The language which you use is independent of the language in which your application is made. Fox example if your application is made in C#, then you can use selenium with any languages mentioned above to test it. You need to know at least one programming languages mentioned above in order to learn selenium. Operating systems Supported by Selenium include windows, Mac, Linux, Unix and many more
Selenium IDE: It only installs in Firefox as an add-on. Firefox only supports selenium IDE. Just like other functional testing tools, it contains record and play/run feature. One can also extend IDE functionality with the help of the user extensions. Selenium IDE supports loops, regular expressions, if statements and many more features. It is based of Java Script. Using selenium IDE the test cases can be parameterized.
Selenium RC: This is the older version of selenium. It works on multiple browsers. RC can be implemented in any one of the programming languages mentioned above. RC require server to work.
WebDriver: WebDriver is the new version of selenium. It also works on multiple browsers. Its removed many drawbacks and issues in Selenium RC. It also supports Android and Iphone Testing. WebDriver doesn't require any server to work Grid: Grid is used to run test cases parallely on multiple machines and browsers. One can download Selenium IDE add-on from Selenium's website: http://seleniumhq.org/download Click on the link as highlighted image:
After clicking on the download link it will display like this, Click on the 'Allow'.
Now after few seconds it will display like this given below, Click on 'Install Now' and after the completion of installing click on 'Restart Firefox'.
In this manner Selenium IDE will get installed into the Firefox browser as an add-on. Once the Selenium IDE is installed you can find it under the: Tools -> Selenium IDE.
To verify the selenium IDE is installed properly just click on the 'Selenium IDE' option from the 'Tools' menu. Now one can see the 'Selenium IDE' window is displayed as a popup over the existing Firefox browser. When the Selenium IDE window is displayed to the user by default it is in the recording mode.
If you dont want Selenium-IDE to begin recording automatically you can turn this OFF by going under Options -> Options and deselecting Start recording immediately on open
Now you navigate to any website one can see all the steps and actions done in the Firefox is being recorded by the Selenium IDE add-on tool.
Speed Control: controls how fast your test case runs. Run All: Runs the entire test suite when a test suite with multiple test cases is loaded. Run: Runs the currently selected test. When only a single test is loaded this button and the Run All button have the same effect. Pause/Resume: Allows stopping and re-starting of a running test case. Step: Allows you to step through a test case by running it one command at a time. Use for debugging test cases. Record: Records the users browser actions. When you run your test case, error messages and information messages showing the progress are displayed in this pane automatically, even if you do not first select the Log tab. These messages are often useful for test case debugging. Notice the Clear button for clearing the Log. Also notice the Info button is a drop-down allowing selection of different levels of information to log.
The Reference tab is the default selection whenever you click the commands in Table mode. In Table mode, the Reference pane will display documentation on the current command. Fast and Slow Speed Control: We can specify the speed of the test case using Fast and Slow. Default is fast. Sometimes test fails due to the fast execution. Selenium IDE gives the facility to adjust the speed. You can use the speed slider to slow down how fast your test commands are executed. This can be helpful as you can watch the application under test while your tests are running and see any obvious issues that your tests are failing on. You can also use this in combination with executing commands manually by pausing your tests. XPath is normally called as XML Path. Normally in every web-based applications the XPath or locators are unique addresses for each and every web object. It can be used with selenium to perform operations on each object present in the web page. In the web page each web-object has a primary unique XPath. XPath are derived from the html paths of the objects. One can install firebug, and on the top of firebug, one can install firepath. Both are installed as add-ons on Firefox.
FIREBUG : Navigate to the link: http://getfirebug.com/ and click on the 'Install Firebug' button.
After you have installed firebug you can be able to install fire path. Navigate to the url: https://addons.mozilla.org/en- US/firefox/addon/firepath/
Click on the button 'Add to Firefox After installing the Firebug and FirePath, click on the Firebug icon which is at the top right of the Firefox browser XPath for Username:
XPath for Password:
XPath for Sign in:
To configure 'Selenium RC' server one has to download the latest jar file from the link given below: http://seleniumhq.org/download/
Click on the download link 'Download version 2.25.0' and download the jar file to the local hard drive of your system.
After the downloading is completed, place the jar file in any place in your hard drive. For instance I have placed the jar file inside the D:' drive in my system. Just open the command prompt that is cmd prompt by: Start-->Run-->type 'cmd' and click 'Ok'. Browse to the directory where 'Selenium RC' server jar file is located. In my case it is in the D:' drive. Now after going to that location in the command prompt simply type the following command: java -jar selenium-server-standalone- 2.25.0.jar
Selenium RC stands for 'Selenium Remote Control'. Selenium RC can be configured in the following way:
First one needs to download the latest jar file from the selenium official website.
Second unzip the downloaded jar files and include them in the Selenium RC project.
Here are the steps given below:
One can download the Selenium RC from the given link below: http://code.google.com/p/selenium/downloads/detail? name=selenium-remote-control-1.0.3.zip&can=2&q=
Click on the link which is in the screenshot, and download the zip file to the local system and unzip the downloaded zip file.
We will configure using 'Eclipse IDE'. First we need to download the Eclipse from the 'Eclipse' website.
Go to the website: http://www.eclipse.org/downloads/ and download the following as given in the screenshot:
Please download the version Eclipse IDE for Java EE Developers and choose the 32 bit or 64 bit as per your system.
After the download is successful unzip the zip folder for 'Eclipse' and place the folder anywhere in your hard disk drive. In this example I have placed it in D' drive. Now go to the 'Eclipse' folder as per the given screenshot below:
Double click on the 'eclipse.exe' and one can see the 'Eclipse' will launch with the following window:
Give the workspace name as per your desired requirement or else you can choose for different workspace location by clicking on the 'Browse' button. After you are done with setting your workspace path click on the 'Ok' button and it displays a window like given below:
If you want to read about 'Eclipse' then click on the relevant links or else simply just click on the cross button of the 'Welcome' tab. Then it displays a window like given below:
Now in the 'Project Explorer' right click inside it and click on the 'New -> Project' as given in the screenshot below:
Now in the 'New Project' dialog box click on the 'Java Project' and click on the 'Next' button.
In the next window give the project name and click on the 'Finish' button.
Now it will display a screen like this given below:
In the left hand side, right click on the project name and click on the 'Properties' option as given in the screenshot below:
Now in the properties dialog box click on the 'Java Build Path' and click on the 'Libraries' tab as given in the screenshot below:
Click on the 'Add External JARs...' button and browse for the jar files which is downloaded for the 'Selenium RC' as given in the screenshot below
Choose the jar files under the D:\workspace\selenium- remote-control-1.0.3\selenium-java-client-driver-1.0.1' folder and include all the jars and click on the open button then it will display the screenshot like this given below:
In the above window click on the 'Ok' button and now one can see all the jars included in it. Now 'Selenium RC' is configured in your system with 'Eclipse IDE'. One can write the code in java and execute in the 'Selenium RC', and it will automate the browser actions as per the java code.
In 'Selenium RC' if you have to run test cases then you have to start selenium-server.jar which is needed to start 'Selenium RC' server. In 'Selenium Webdriver', there is no server which you need to start to run the 'Selenium Webdriver' based test cases.
Selenium can be configured in the following ways:
First one needs to download the latest jar files from the selenium official website.
Second unzip the downloaded jar files and include them in the Selenium project.
Here are the steps given below:
One can download the selenium WebDriver from the given link below: http://seleniumhq.org/download/
Click on the download link as per the desired language you want to configure Selenium Webdriver. The example is shown for the Selenium Webdriver configured with Java language.
Once the download link is clicked the user is asked to save the zip files. Then save the zip files into the hard drive of your local system. When the zip files are downloaded properly just unzip the files to get files inside a folder.
Now we will configure WebDriver using the 'Eclipse IDE'.
In the left hand side, right click on the project name and click on the 'Properties' option as given in the screenshot below:
Now in the properties dialog box click on the 'Java Build Path' and click on the 'Libraries' tab as given in the screenshot below:
Click on the 'Add External JARs...' button and browse for the jar files which is downloaded for the Selenium WebDriver as given in the screenshot below:
Choose the jar files under the 'selenium- 2.25.0' folder and 'lib' folder and include all the jars and click on the open button the user is displayed the screenshot like this given below:
In the above window click on the 'Ok' button and now one can see all the jars included in it. Now 'Selenium WebDriver' is configured in your system with 'Eclipse IDE'. One can write the code in java and execute in the Selenium WebDriver and it will automate the browser actions as per the java code.
JUnit is a simple framework to write repeatable tests.
@ Test : This is used to create test. The things that you write in this annotation are executed as a TEST @Before and @After In Junit4 there is no setup() or tearDown() method and instead of that we have @Before and @After annotations. By using @Before you can make any method as setup() and by using @After you can make any method as teardown(). @Before and @After annotated method will be invoked before and after each test case.
@BeforeClass If you want a method to run once for all the methods, then you can use this annotation. It will execute the method once for all the tests of a particular file. @AfterClass It is used with the conjunction with the @BeforeClass. Use this method if you want to execute a method after executing all the tests of a particular file.
For Generating HTML Reports we have to download ANT Navigating to http://ant.apache.org/bindownload.cgi
Download the Zip file which is highlighted one Extract the zip file Navigate to Computer -> right click on properties -> click on Advanced system settings Click on Advanced tab -> Environment variables Click on New button under system variables
Variable name : ANT_HOME Variable Value : C:\apache-ant-1.8.4- bin\apache-ant-1.8.4 Scroll down the System Variables find the variable name as path and click on edit
In variable value go to end of the variable value and type ; C:\apache-ant-1.8.4-bin\apache-ant- 1.8.4\bin If unable to locate tools.jar error is displayed then copy C:\Program Files\Java\jdk1.6.0_26\lib tools.jar to C:\Program Files\Java\jre6\lib Go to command prompt and type ant
Copy the build.xml file into current project Go to command prompt and Navigate to the current project path and type ant
In command prompt type ant compile Navigate to project and click refresh then build folder will be generated In command prompt type ant clean Navigate to project and click refresh then build folder will be deleted. In command prompt type ant run Based on build.xml file it will run. HTML reports will be generated in the path which we have mentioned in the build.xml
TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that make it more powerful and easier to use.
TestNG is required because :
After running Selenium with TestNG get HTML reports for test cases. TestNG supports annotations which are very helpful. We can skip test cases very easily When using ANT with TestNG, we can also generate the TestNG XSLT reports which are better than primitive TestNG reports. TestNG supports parallel execution of test cases We can paramertize Selenium tests with TestNG
It is parallel tool like. Generates the report automatically. Also we can integrate TestNG in eclipse. All you need to do is that Go to help - > Install new software - > In Work with type http://beust.com/eclipse if your Eclipse is above 3.4 version else type http://beust.com/eclipse1.
Follow the instructions accept the agreement and all. Some downloading will happen. After all it will restart the Eclipse. And if everything is fine then you will see the TestNG Under Windows - > Preferences. (or) Window - > Show View -> Java
@Test: This is used to create test. The things that you write in this annotation are executed as a TEST. And if you have more than one test in the class then they will be executed in an alphabetical order. @AfterMethod: The annotated method will be run after each test method @BeforeMethod: The annotated method will be run before each test method BeforeClass : The annotated method will be run before the first test method in the current class is invoked. @AfterClass : The annotated method will be run after all the test methods in the current class have been run.
@BeforeSuite: The annotated method will be run before all tests in this suite have run. @AfterSuite: The annotated method will be run after all tests in this suite have run. @BeforeTest: The annotated method will be run before any test method belonging to the classes inside the <test> tag is run. @AfterTest: The annotated method will be run after all the test methods belonging to the classes inside the <test> tag have run.
For Generating XSLT Reports we have to download ANT Navigating to http://ant.apache.org/bindownload.cgi
Download the Zip file which is highlighted one Extract the zip file Navigate to Computer -> right click on properties -> click on Advanced system settings Click on Advanced tab -> Environment variables Click on New button under system variables
Variable name : ANT_HOME Variable Value : C:\apache-ant-1.8.4- bin\apache-ant-1.8.4 Scroll down the System Variables find the variable name as path and click on edit
In variable value go to end of the variable value and type ; C:\apache-ant-1.8.4-bin\apache-ant- 1.8.4\bin If unable to locate tools.jar error is displayed then copy C:\Program Files\Java\jdk1.6.0_26\lib tools.jar to C:\Program Files\Java\jre6\lib Go to command prompt and type ant
Copy the build.xml file into current project Go to command prompt and Navigate to the current project path and type ant
In command prompt type ant compile Navigate to project and click refresh then build folder will be generated In command prompt type ant clean Navigate to project and click refresh then build folder will be deleted. In command prompt type ant run Based on testng.xml file it will run. In command prompt type ant makexsltreports Navigate to project and click refresh then XSLT_Reports folder will be generated
Type the following in the Notepad d: cd d:\Eclipse\Module9 ant clean compile run makexsltreports SAVE the notepad as MY_TEST_SUITE.bat
Python Programming Reference Guide: A Comprehensive Guide for Beginners to Master the Basics of Python Programming Language with Practical Coding & Learning Tips