Automation
Test Automation software is the best way to increase the effectiveness, efficiency, and coverage of your software testing.
Software tests have to be repeated often during development cycles to ensure quality. Every time source code is modified software tests should be repeated. For each release of the software it may be tested on all supported operating systems and hardware configurations. Manually repeating these tests is costly and time-consuming. I did develop from scratch an automation framework using Java, Selenium, TestNG, Git, Maven & Jenkins. The tests must be easy to use & update so the maintenance is also quick & easy. The code must be written efficient, no duplicate code so I used Page Object Model principles. The framework is created with the setup of the testing environment, basic methods are implemented, the foundation on which the actual tests will be implemented such as click(), enterText(), selectFromDropDown(), maximize(), load(), etc.. into Utility package. Each test suite is implemented by writing code for each page (Java class) from the application & creating a TestNG for the actual test.
Automated tests mainly have a purpose for smoke testing & regression testing.
All the effort spent on manually testing is no longer applicable because the automated tests do the actual work. The framework is easily maintainable, sustainable, and can be updated. If a test is built for one country, the same test can be extended for other countries too with a minimum of effort. Each test is built to follow all the test steps for each of the functionality of the application. All the tests are encapsulated into a single XML file that is collected by the Jenkins job and can be run as many times as is needed. Tests results are also being visible on Jenkins and also the cause for which the test is failing so this way the test can be easily investigated and fixed. If you have to run a regression session for an application instead of doing it into let’s say 8 hours (manually), it can be read through the automated tests in 45 minutes, this depends on the performance of the testing environment. Every functionality can be automated, you can have positive tests but you can also implement negative tests. All the tests are TestNG classes using annotations like @Test, @BeforeTest & @AfterTest. You can also set the priority in order to run the tests in a specific order, also you can have multiple tests grouped into a suite of tests. Preconditions: Java 1.8, Apache Maven 3.5.4, Eclipse Photon IDE or any other version with git & Maven futures
You can find automation frameworks from previous projects here: https://github.com/shippingcode
How do I get set up?
Pre-requirements:
- 1.) Install Eclipse from https://eclipse.org/downloads/, you can choose https://eclipse.org/luna/ or any other version.
- 2.) Download selenium-server-standalone from http://www.seleniumhq.org/download/ How to include it in Eclipse?
- a. Open Eclipse
- b. Create a package
- c. Click on the package and go to Build Path → Configure Build Path
- d. Go to Libraries & go to Add external JARs e. Choose selenium-server-standalone
- 3.) Copy link address from Download from this http://www.eclipse.org/egit/?gclid=CJ3b0Kbwv8sCFVRsGwod8l4EoQ
- Open Eclipse;
- Go to Help -> Install new software;
- Press Add & fill a name and paste the link copied;
- Check the checkboxes: Eclipse Git Team Provider & JGit;
- Now Open Perspective and choose Git from the list;
- Click Clone Repository Button https://aila_bogasieru@bitbucket.org/aila_bogasieru/hubeleon-selenium-webdriver.git
- Enter your Bitbucket URL and User Information;
- Each test suite can be run individually, but at the same time all at once.
- Each test can be created as an individual class or JUnit test under Hubeleon Tests package
- 4.) In order to run TestNG Test TestNG, you have to install TestNG Eclipse Plugin
- Steps to follow:
- 4.1) Launch the Eclipse IDE and from Help menu, click “Install New Software”.
- 4.2) You will see a dialog window, click the “Add” button.
- 4.3) Type name as you wish, let’s say take “TestNG” and type “http://beust.com/eclipse/” as location. Click OK.
- 4.4) You come back to the previous window but this time you must see TestNG option in the available software list. Just Click TestNG and press the “Next” button.
- 4.5) Click “I accept the terms of the license agreement” then click Finish.
- 4.6) You may or may not encounter a Security warning if in case you do just click OK.
- 4.7) Click Next again on the succeeding dialog box until it prompts you to Restart the Eclipse.
- 4.8) You are all done now, just click Yes.
- 4.9) Proceed with your workplace.
- 4.10) After the restart, verify if TestNG was indeed successfully installed. Right-click on your project and see if TestNG is displayed in the opened menu.
To run a test suite with TestNG a .xml file must be created in order to create all classes.
- 5.) To install Maven you need to access: https://marketplace.eclipse.org/content/maven-integration-eclipse-luna-and-newer by using drag & drop on the install icon into Eclipse Check the checkbox for accepting the agreement & restart Eclipse in order to have applied the changes. Somehow you need to repeat step 3.) (Git is no longer available after Maven is integrated into Eclipse)
- 6. Pre-requirements
- 6.0.) Download Apache-maven from here: https://maven.apache.org/download.cgi?Preferred=http%3A%2F%2Fapache.javapipe.com%2F
- 6.1.) Add system variables: JAVA_HOME with value: C:\Program Files\Java\jdk1.8.0_73 M2 with value: %M2_HOME%\bin M2_HOME with value: C:\Program Files\apache-maven-3.3.9 PATH with value: C:\Program Files\apache-maven-3.3.9\bin
- 7.) The final step is to Generate XSLT Report (Advanced HTML report) in Selenium 7.a.) For this you will have to download XSLT Report from here: https://drive.google.com/drive/u/0/folders/0B5v_nInLNoquV1p5YWtHc3lkUkU
- 7.b.) Unzip XSLT Folder and copy all the files and paste into project home directory
Steps of generating TestNG-XSLT Report using Command Line:
- i. Navigate to Workspace directory where pom.xml file is present (in my case, this must be set in particular).
- ii. Type command — C:\Users\AilaB\workspace\SeleniumHubeleon mvn clean
- iii. Type command — C:\Users\AilaB\workspace\SeleniumHubeleon mvn install
- iV. Type command — mvn –e clean test site org.reportyng-ng:1.2:reporting
Compatibility: For the latest version of selenium-server-standalone-2.53.0 only Mozilla Firefox v <= v.46
There are 3 methods to run a test:
- Directly from src/test/java. Wanted test -> Run As -> TestNG Test
2. Using test suite created in src/test/resources running then xml file. Wanted xml file -> Run As -> TestNG Suite. Using pom.xml file ->Run As Maven test/Maven build case in which all the existing tests will be ran, everything that is under src/test/resources as xml files. pom.xml is the file which includes all the dependencies necessary in this framework: java, testng, selenium. maven.compiler, maven.surefire & maven.failsafe are dependencies used in compiling, unit testing and integration testing maven.surefire includes the suite that will be used in Jenkins integration. Project configuration in Jenkins : is a Maven type project having the following configuration: is ran on a Windows server. The source where the project is located needs to be specified here & the name of the branch. Hour, day when the build will start, xml file that needs to be set with all the dependencies and what suite needs to be built. After the build is finished report with test results is sent to email list.




