Git Product home page Git Product logo

sharathn27 / snj-selenium-java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sanoj-s/joq-web-sel

0.0 0.0 0.0 315 KB

This is a test automation framework for the web applications on different browsers like Google Chrome, Mozilla Firefox, Microsoft Edge, Internet Explorer and Safari in real-time. It provides rich features like Test Execution, Test Reporting, and Test details sharing via mail.

Java 100.00%

snj-selenium-java's Introduction

snj-selenium-java

This is a test automation framework for web applications on different browsers like Google Chrome, Mozilla Firefox, Microsoft Edge, Internet Explorer and Safari in real-time. It provides rich features like Test Execution, Test Reporting, and Test details sharing via mail. The automation framework includes 170+ pre-built keywords using which an Automation Engineer can easily perform the web automation.

Salient features of snj-selenium-java

  • Automation support for web applications (in Windows, MAC and Linux platforms).
  • Automation support for Google chrome, Mozilla Firefox, Microsoft Edge, Internet Explorer and Safari browsers.
  • Automation support for headless execution of test scripts.
  • Automation support for electron applications.
  • Support for parallel execution on different browsers.
  • Support for fully distributed remote executions (Selenium Grid 4).
  • Support for Lighthouse audit on website with different categories such as performance, accessibility, seo, best-practices, pwa.
  • Support for accessibility testing on website to track the violations, violation impact, and help details to solve the violations.
  • Support to collect the page load time for better performance tracking of an application.
  • Support to generate the video report for the automation execution flow.
  • Support to compare the images and generate image comparison report.
  • Support database validation.
  • Support API testing and response validation.
  • Support mock geolocation, simulate device mode, simulate network speed.
  • Good reporting - framework generates HTML report.
  • Email collaboration - send an email with details of automation execution and HTML attachment.
  • Well defined keyword document, get from src/main/resources -> keywords folder of the project structure.

    Steps to develop and execute automation scripts using snj-selenium-java

  • Set up Java, Eclipse/IntelliJ IDEA and dependent softwares.
  • Import the snj-selenium-java framework into Eclipse/IntelliJ IDEA from this repository (master).
  • Configure details in automation_framework_config and email_config properties files inside the src/main/resources of the framework.
  • Configure details in automation_test_config and database_config properties files inside the src/test/resources of the framework.
  • Manage TestRunner class inside the snj.selenium.runner package
  • Manage Test Suite Class inside the snj.selenium.testcases package and Test Helper class inside snj.selenium.testhelpers package.
  • Manage Test Object Class inside the snj.selenium.testobjects package.
  • Create testng.xml and map test suite classes to it.
  • Run the testng.xml file and view the execution reports which generate in the \Reports\Automation folder of the project structure.

    Manage TestRunner class
    Once the TestRunner class ready under snj.selenium.runner package, you can use below code snippet in TestRunner class:

    @Listeners(AutomationReport.class)
    public class TestRunner extends AutomationEngine {
    @BeforeClass
    @Parameters({ "browserName", "gridIP", "gridPort" })
    public void setup(String browserName, String gridIP, String gridPort) throws Exception {
    	startBrowser(browserName, gridIP, gridPort);
    }
    @AfterSuite
    public void tearDownMethod() throws AutomationException, InterruptedException {
    	WebActions webObj = new WebActions();
    	webObj.closeBrowser(driver);
    }
    }
    

    Manage Test Suite Class
    You can create multiple test suite classes under snj.selenium.testcases package, you can use below code snippet as sample test case in test suite class:

    public class SampleTest extends TestRunner {
    public SampleTest() throws AutomationException {
    	super();
    }
    @Test(enabled = true)
    public void TC001_sampleTestCase() throws AutomationException {
    	new WebActions().loadWebApplication(driver, "https://www.google.com");
    	new UIActions().type(driver, SampleObjects.txt_searchbox, "JourneyOfQuality");
    	new AutomationReport().trackSteps("Data Entered");
    }
    }
    

    Manage Test Helper Class
    You can create multiple test helper classes under snj.selenium.testhelpers package. Test helper class can hold the actual automation step flow based on the application feature. Test helper methods should be re-usable in other test suite classes. Once you create the methods in test helper class, you can call those methods in test suite classes.

    Manage Test Object Class
    You can create multiple test object classes under snj.selenium.testobjects package. Test Object class can hold the object locator values like XPath, Id etc. These object creation based on your application page/screen. You can use the objects in test helper class to perform the actions on the object. Following is a sample snippet:

    public class SampleObjects {
    	public static String txt_searchbox = "//input[@title='Search']";
    }
    

    Manage testng.xml
    You can use the following code in testng.xml file:

    <?xml version="1.0" encoding="UTF-8"?>
        <!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
        <suite name="Suite">
     <test thread-count="5" name="Execution for Test Suites">
    	<parameter name="browserName" value="chrome" />
    	<parameter name="gridIP" value="xxx.xxx.xxx.xxx" />
    	<parameter name="gridPort" value="xxxx" />
    	<classes>
    	   <class name="snj.selenium.testcases.SampleTest" />
    	</classes>
     </test> <!-- Test -->
        </suite> <!-- Suite -->
    

    NOTE: If you need run on different browsers, you can mention firefox or edge or ie or safari or headless for the browserName parameter in the above testng.xml code. If you need to run as Selenium Grid mode, just specify the values for gridIP and gridPort. For local execution, you just leave gridIP and gridPort as blank but need the browserName parameter value. For more about Selenium Grid setup, please visit https://journeyofquality.com/2022/01/26/a-variant-selenium-grid-4/

    Perform Lighthouse Audit
    This automation framework supports the lighthouse audit on the website with different categories such as performance, accessibility, SEO, best practices, and PWA. You can use startLighthouseAudit keyword of the UtilityActions class. Once the audit is completed the framework will generate the audit report in the \Reports\Lighthouse_Audit folder of the project structure. The prerequisites for the Lighthouse audit is to install the lighthouse node module package on your system. For more details about Lighthouse setup, please visit https://journeyofquality.com/2021/12/21/turn-on-your-lighthouse/. Below is the sample code for reference:
    new UtilityActions().startLighthouseAudit(driver.getCurrentUrl(), "performance,seo", "no");

    Perform Accessibility Testing
    This automation framework supports the accessibility testing on website to track the violations, violation impact, and help details to solve the violations. You can use startAccessibilityAudit keyword of the UtilityActions class in the test suite class to start the track violations. Once the execution is completed the framework will generate the accessibility test summary report in the \Reports\Accessibility_Audit\Summary folder of the project structure. In addition to the summary report, there are detailed text and JSON reports will generate in the \Reports\Accessibility_Audit\Details folder of the project structure.

    Collect Page Load Performance
    This automation framework support to collect the page load time for a better performance tracking of an application. You can use collectLoadTime keyword of the UtilityActions class in the test suite class to collect the page load time. Once the execution is completed the framework will generate the performance test summary report in the \Reports\Performance_Audit folder of the project structure.

    Image Comparison
    This automation framework support to compare the actual image against the expected image at runtime. You can use compareImages keyword of the ValidationActions class in the test suite class to compare the images. Once the execution is completed the framework will generate the image comparison report in the \Reports\Image_Comparision folder of the project structure. More details at https://journeyofquality.com/2023/01/13/image-comparison-during-automation/

    Video Recording
    This automation framework support to generate the video recording of the automation workflow. You can use startRecording keyword of the UtilityActions class in the test suite class to start the recording and stop the recording by using the keyword stopRecording of the UtilityActions. Once the execution is completed the framework will generate the video report in the \Reports\Automation_Videos folder of the project structure.

    I hope this automation framework will help to kickstart your automation scripting from the base level.

    Get your latest releases from https://github.com/sanoj-s/snj-selenium-java/releases

    make it perfect!

  • snj-selenium-java's People

    Contributors

    sanojqa avatar sanoj-s avatar

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google โค๏ธ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.