Pages

Monday, 20 March 2023

Coding Standards for Automation QA- SDET?

 


How to install JDK and set Java Home path in Windows and MacOs ?

Ans: Click here for Steps

Java Interview question Set-1:  SET-01 1-10

Java Interview question Set-2:  SET-02 10-20

Java Interview question Set-3:  SET-03 21-30

How to Call a method in JAVA?


Generic Coding Standards for Automation

  • Use SoftAssertion instead of multiple asserting statements.

  • ReadMe should have all the detailed steps on how to run the Automation Suite.

  • Classes should not have too many "static" imports
  • "private" and "final" methods that don't access instance data should be "static"
  • "Thread.sleep" should not be used in tests
  • Duplication of assertion should be avoided
  • The functionality is good for the users of the code.
  • All UI changes are sensible and look good.
  • Avoid using numbers inside the Xpath.
  • All parallel programming is done safely.
  • The code isn’t more complex than it needs to be.
  • The author isn’t implementing things they might need in the future,
    but don’t know they need now.
  • The developer used clear names for everything.
  • Comments are clear and useful, and mostly explain why instead of what.
  • The code is appropriately documented.
  • The code conforms to the style guides.
  • Take a screenshot of the failed investigation.
  • Refactor to make sure that no duplication is tolerated
  • Redundant parenthesis
  • Constants should always be all-uppercase, with underscores to separate words
  • Use of Constant class and not specific classes

Java Standards for Test Script Design

Java coding standards for automation testing are similar to general coding standards, with some additional considerations specific to automation testing. Here are some general coding standards for automation testing using Java:

  1. Naming Conventions:
    Use meaningful names for classes, methods, and variables. Use CamelCase for class names, and start with a lowercase letter for variable and method names. Use descriptive names that accurately reflect their purpose.

  2. Code Formatting:
    Follow a consistent code formatting style, such as the one recommended by Oracle. Use consistent indentation, avoid excessive line length, and add comments where necessary to explain complex code.

  3. Error Handling:
    Handle exceptions properly in your code. Use try-catch blocks to handle exceptions, and add descriptive error messages that help you understand what went wrong when the code fails.

  4. Modularity:
    Write code that is modular, reusable, and maintainable. Break up your code into smaller, reusable functions, and create classes that encapsulate specific functionality. Use inheritance and polymorphism to create a more modular and maintainable codebase.

  5. Test Design:
    Write code that is easy to test. Use design patterns like Page Object Model (POM) to create code that is easy to test, maintain, and update. Write test cases that are independent, atomic, and repeatable.

  6. Assertions:
    Use assertions in your test code to validate that the application under test is behaving as expected. Use descriptive error messages in your assertions to help you understand what went wrong when the code fails.

  7. Code Review:
    Have a code review process in place to ensure that your code follows established standards, is maintainable, and is easy to test. Review your code with your team and get feedback to improve your coding practices.

By following these Java coding standards for automation testing, you can create more maintainable, reusable, and testable code, which can lead to more efficient and effective automation testing.

  •    How to convert List to array and array to list?

          Click here for Answer

    General rules

    1. Follow standard conventions.
    2. Keep it simple stupid. Simpler is always better.
      Reduce complexity as much as possible.
    3. Boy scout rule. Leave the campground cleaner than you found it.
    4. Always find root cause. Always look for the root cause of a problem.

    Design rules

    1. Keep configurable data at high levels.
    2. Prefer polymorphism to if/else or switch/case.
    3. Separate multi-threading code.
    4. Prevent over-configurability.
    5. Use dependency injection.
    6. Follow Law of Demeter. A class should know only its direct dependencies.

    Understandability tips

    1. Be consistent. If you do something a certain way,
      do all similar things in the same way.
    2. Use explanatory variables.
    3. Encapsulate boundary conditions.
      Boundary conditions are hard to keep track of.
      Put the processing for them in one place.
    4. Prefer dedicated value objects to primitive type.
    5. Avoid logical dependency.
      Don't write methods which works correctly depending on something
      else in the same class.
    6. Avoid negative conditionals.


    Names rules

    1. Choose descriptive and unambiguous names.
    2. Make meaningful distinction.
    3. Use pronounceable names.
    4. Use searchable names.
    5. Replace magic numbers with named constants.
    6. Avoid encodings. Don't append prefixes or type information.

    *******************************************************************
    For any doubts or career guidance from me, reach out here : https://topmate.io/sidharth_shukla

    ********************************************************************

    These commands cover a range of basic UI interactions and are a good starting point for building automated tests with Cypress.

    Do remember that knowing Linux is one of the most important aspect to work as an SDET.

    Basic Linux Commands for Automation QA


    ****************************************

    TOP 15 BDD - CUCUMBER Interview Q&A


    ************************************************

    ✍️AUTHORLinkedIn Profile

    ************************************************

    Learn (API-Microservice)Testing+ Selenium UI Automation-SDET with Self Paced Videos prepared by FAANG employees and LIVE Doubt Session 

    SDET TRANING VIDEOS AVAILABLE with Live Doubt Session(course-1 below,API TRaining Videos With Class Notes and Coding Set) and (API+UI, both course-1 & 2 below) Check Training Page for Course Content or reach out @whatsapp +91-9619094122. 
    This includes classnotes, 300+ interview questions, 3 projects, Java Coding question set for product companies along with career guidance from FAANG employees for Automation and SDET.

    For more details whatsapp : https://lnkd.in/dnBWDM33

    *************************************************

    SeleniumWebdriver Automation Testing Interview Questions:

    https://automationreinvented.blogspot.com/search/label/SeleniumWebdriver

    API Testing Interview Question Set:

    https://automationreinvented.blogspot.com/2022/03/top-80-api-testing-interview-questions.html

    DevOps Interview Q&A:

    https://automationreinvented.blogspot.com/2021/11/top-11-devops-interview-questions-and.html 

    Kubernetes Interview Question Set

    https://automationreinvented.blogspot.com/search/label/Kubernetes

    Docker Interview Question Set

    https://automationreinvented.blogspot.com/Docker

    Linux Interview question Set

    https://automationreinvented.blogspot.com/search/label/Linux

    Automation Testing/SDET Framework Design

    https://automationreinvented.blogspot.com/search/label/FrameworkDesign

    Java Related Interview Question Set

    https://automationreinvented.blogspot.com/search/label/Java

    GIT Interview Question Set:

    https://automationreinvented.blogspot.com/2021/09/top-40-git-interview-questions-and.html

    Coding Interview Question Set:

    https://automationreinvented.blogspot.com/search/label/Coding%20Questions

    Mobile Testing Interview Question Set:

    https://automationreinvented.blogspot.com/search/label/Mobile%20Testing

    Python Interview Question Set for QAE - SDET - SDE:

    https://automationreinvented.blogspot.com/search/label/Python

    Friday, 17 March 2023

    What changes were introduced in Cypress Version 12?

     



    SDET Interview Question and Answers
    .  


    Jenkins Interview Questions and Answers

    Appium Interview Questions and Answers

    Selenium Interview Questions and answers

    GIT Interview Questions and Answer


    What is Cypress?

    Cypress is a purely JavaScript-based front-end testing tool built for the modern web. It aims to address the pain points developers or QA engineers face while testing an application. Cypress is a more developer-friendly tool that uses a unique DOM manipulation technique and operates directly in the browser.


    INSTALL CYPRESS

    If you haven't installed Cypress yet then refer to this link on:


    Introduction: 

    Cypress is an end-to-end testing framework that enables developers to test their web applications efficiently. It has gained popularity over the years due to its powerful testing capabilities and ease of use. Recently, Cypress released version 12 with several changes that will enhance the testing experience for developers. In this blog, we will take a closer look at the changes in Cypress version 12.

    1. Automatic retries:

      One of the most significant changes in Cypress version 12 is the introduction of automatic retries. When a test fails, Cypress will automatically retry it up to three times before marking it as a failure. This feature will save developers time by eliminating the need to rerun tests manually. Additionally, developers can customize the number of retries and the wait time between retries.

    2. Improved performance:

      Cypress version 12 also comes with improved performance. The framework now has a faster startup time, and the test runner is more responsive. These changes will significantly reduce the time it takes to run tests and provide a smoother testing experience for developers.

    3. Network stubbing improvements:

      Cypress version 12 has also improved network stubbing capabilities. Developers can now intercept and modify responses from the server using the cy.intercept() command. This feature will enable developers to test edge cases and error handling scenarios more effectively.

    4. New plugin system:

      Another significant change in Cypress version 12 is the introduction of a new plugin system. The new system is more flexible and provides developers with more control over how they use Cypress. Developers can now create their custom plugins and share them with the community. Additionally, developers can install plugins from the Cypress plugin registry, making it easier to add new features to their tests.

    Conclusion:

    Cypress version 12 comes with several changes that will make the testing experience more efficient and effective for developers. With automatic retries, improved performance, network stubbing improvements, and a new plugin system, developers will have more control over how they use Cypress. These changes will enable developers to create more robust tests and ensure that their web applications are functioning correctly.


    Top 11 Cypress Commands for Automation




    *******************************************************************
    For any doubts or career guidance, reach out to me 


    ********************************************************************

    These commands cover a range of basic UI interactions and are a good starting point for building automated tests with Cypress.

    Do remember that knowing Linux is one of the most important aspect to work as an SDET.

    Basic Linux Commands for Automation QA


    ****************************************

    TOP 15 BDD - CUCUMBER Interview Q&A


    ************************************************

    ✍️AUTHORLinkedIn Profile

    ************************************************

    Learn (API-Microservice)Testing+ Selenium UI Automation-SDET with Self Paced Videos prepared by FAANG employees and LIVE Doubt Session 

    SDET TRANING VIDEOS AVAILABLE with Live Doubt Session(course-1 below,API TRaining Videos With Class Notes and Coding Set) and (API+UI, both course-1 & 2 below) Check Training Page for Course Content or reach out @whatsapp +91-9619094122. 
    This includes classnotes, 300+ interview questions, 3 projects, Java Coding question set for product companies along with career guidance from FAANG employees for Automation and SDET.

    For more details whatsapp : https://lnkd.in/dnBWDM33

    *************************************************

    SeleniumWebdriver Automation Testing Interview Questions:

    https://automationreinvented.blogspot.com/search/label/SeleniumWebdriver

    API Testing Interview Question Set:

    https://automationreinvented.blogspot.com/2022/03/top-80-api-testing-interview-questions.html

    DevOps Interview Q&A:

    https://automationreinvented.blogspot.com/2021/11/top-11-devops-interview-questions-and.html 

    Kubernetes Interview Question Set

    https://automationreinvented.blogspot.com/search/label/Kubernetes

    Docker Interview Question Set

    https://automationreinvented.blogspot.com/Docker

    Linux Interview question Set

    https://automationreinvented.blogspot.com/search/label/Linux

    Automation Testing/SDET Framework Design

    https://automationreinvented.blogspot.com/search/label/FrameworkDesign

    Java Related Interview Question Set

    https://automationreinvented.blogspot.com/search/label/Java

    GIT Interview Question Set:

    https://automationreinvented.blogspot.com/2021/09/top-40-git-interview-questions-and.html

    Coding Interview Question Set:

    https://automationreinvented.blogspot.com/search/label/Coding%20Questions

    Mobile Testing Interview Question Set:

    https://automationreinvented.blogspot.com/search/label/Mobile%20Testing

    Python Interview Question Set for QAE - SDET - SDE:

    https://automationreinvented.blogspot.com/search/label/Python

    Wednesday, 15 March 2023

    How to handle StaleElementException in Selenium?

     


    SDET Interview Question and Answers.  

    Jenkins Interview Questions and Answers

    Appium Interview Questions and Answers

    Selenium Interview Questions and answers

    GIT Interview Questions and Answer


    Automation Metrics is very imp for Automation QA and SDET, if you are trying for SDET role do check out our post on SDET Job Roles & Responsibilities


    How to handle staleelementexeception


    StaleElementException is a common exception that can occur in web automation testing when an element on the web page has changed or become stale since it was first located by the WebDriver. This can happen when the page is refreshed or updated dynamically.


    To handle StaleElementException in your automation tests, you can use one of the following methods:



    1. Retry mechanism: You can use a retry mechanism to refresh the page and retry the action that caused the exception. This can be done by wrapping the action in a try-catch block and retrying it a certain number of times until it succeeds.

    int retryCount = 0; while (retryCount < 3) { try { WebElement element = driver.findElement(By.id("elementId")); element.click(); break; } catch (StaleElementException e) { driver.navigate().refresh(); retryCount++; } }

    In this example, the code attempts to click on an element with the ID "elementId". If a StaleElementException is caught, the page is refreshed and the action is retried. The retry mechanism is limited to three attempts in this example, but you can adjust the retry count to fit your needs.


    1. PageFactory: You can use PageFactory to automatically handle StaleElementException for you. This can be done by annotating the WebElement with @CacheLookup and initializing the PageFactory with the org.openqa.selenium.support.PageFactory class.

    public class MyPage { @CacheLookup @FindBy(id = "elementId") private WebElement element; public MyPage(WebDriver driver) { PageFactory.initElements(driver, this); } public void clickElement() { element.click(); } }


    In this example, the @CacheLookup annotation tells PageFactory to cache the element when it is first located, and to use the cached element instead of locating it again when it is accessed later. This can prevent StaleElementException from occurring. The PageFactory.initElements method initializes the page object and its elements. You can then use the clickElement method to click on the cached element without worrying about StaleElementException.



    1. Explicit Wait: You can use an explicit wait to wait for the element to become stale and then re-locate it. This can be done using the ExpectedConditions.stalenessOf method.

    WebElement element = driver.findElement(By.id("elementId")); WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.stalenessOf(element)); element = driver.findElement(By.id("elementId")); element.click();

    In this example, the code first locates the element with the ID "elementId". The WebDriverWait object waits for up to 10 seconds for the element to become stale, and then re-locates the element before clicking on it. This can prevent StaleElementException from occurring.

    Overall, the best way to handle StaleElementException depends on the specific situation and your testing needs. It's important to consider the performance impact of each approach and choose the one that works best for your application.


    To calculate Test Estimation, check the link below:
    Automation Test Estimation


    What are the Types of APIs ?


    Gmail Automation with Cypress & JavaScript


    *******************************************************************
    For any doubts or career guidance, reach out to me 


    ********************************************************************





    Do remember that knowing Linux is one of the most important aspect to work as an SDET.

    Basic Linux Commands for Automation QA


    ****************************************

    TOP 15 BDD - CUCUMBER Interview Q&A


    ************************************************

    ✍️AUTHORLinkedIn Profile

    ************************************************

    Learn (API-Microservice)Testing+ Selenium UI Automation-SDET with Self Paced Videos prepared by FAANG employees and LIVE Doubt Session 

    SDET TRANING VIDEOS AVAILABLE with Live Doubt Session(course-1 below,API TRaining Videos With Class Notes and Coding Set) and (API+UI, both course-1 & 2 below) Check Training Page for Course Content or reach out @whatsapp +91-9619094122. 
    This includes classnotes, 300+ interview questions, 3 projects, Java Coding question set for product companies along with career guidance from FAANG employees for Automation and SDET.

    For more details whatsapp : https://lnkd.in/dnBWDM33

    *************************************************

    SeleniumWebdriver Automation Testing Interview Questions:

    https://automationreinvented.blogspot.com/search/label/SeleniumWebdriver

    API Testing Interview Question Set:

    https://automationreinvented.blogspot.com/2022/03/top-80-api-testing-interview-questions.html

    DevOps Interview Q&A:

    https://automationreinvented.blogspot.com/2021/11/top-11-devops-interview-questions-and.html 

    Kubernetes Interview Question Set

    https://automationreinvented.blogspot.com/search/label/Kubernetes

    Docker Interview Question Set

    https://automationreinvented.blogspot.com/Docker

    Linux Interview question Set

    https://automationreinvented.blogspot.com/search/label/Linux

    Automation Testing/SDET Framework Design

    https://automationreinvented.blogspot.com/search/label/FrameworkDesign

    Java Related Interview Question Set

    https://automationreinvented.blogspot.com/search/label/Java

    GIT Interview Question Set:

    https://automationreinvented.blogspot.com/2021/09/top-40-git-interview-questions-and.html

    Coding Interview Question Set:

    https://automationreinvented.blogspot.com/search/label/Coding%20Questions

    Mobile Testing Interview Question Set:

    https://automationreinvented.blogspot.com/search/label/Mobile%20Testing

    Python Interview Question Set for QAE - SDET - SDE:

    https://automationreinvented.blogspot.com/search/label/Python

    Wednesday, 8 March 2023

    Explain different types of variables in Java with examples?

     

    SDET Interview Question and Answers.  

    Java Interview Question SET-01

    Java INterview Question Set-02 ARRAY

    Java INterview Questiona Set-03 MAP

    Java INterview Question Set-04


    In Java, there are three types of variables: local variables, instance variables, and class/static variables.  Here's an explanation of each type with examples:

    1. Local Variables:

      These are variables that are declared inside a method, constructor, or block. They are only accessible within the scope of the method, constructor, or block in which they are declared. Local variables must be initialized before they can be used.

    Example:


    public class LocalVariablesExample {
        public static void main(String[] args) {
            int x = 5; // local variable
            System.out.println(x); // prints 5
        }
    }


    1. Instance Variables:


      These are variables that are declared within a class, but outside of any method, constructor, or block. They are also known as non-static variables, as they are associated with an instance of a class. Instance variables can be accessed and modified using the instance of the class.

    Example:


    public class InstanceVariablesExample {
        int x; // instance variable

        public static void main(String[] args) {
            InstanceVariablesExample obj = new InstanceVariablesExample();
            obj.x = 5; // assigning a value to the instance variable
            System.out.println(obj.x); // prints 5
        }
    }


    1. Class/Static Variables:

      These are variables that are declared within a class, but outside of any method, constructor, or block, and are marked as static. Class variables are associated with the class itself, rather than with an instance of the class. They can be accessed and modified using the class name.

    Example:

    public class StaticVariablesExample {
        static int x = 5; // class variable

        public static void main(String[] args) {
            System.out.println(StaticVariablesExample.x); // prints 5
        }
    }


    In this example, x is declared as a static variable within the StaticVariablesExample class. We can access and modify this variable using the class name, rather than an instance of the class. We can see this in the main method where we use StaticVariablesExample.x to access the value of x.


    4. Reference Variable


    In Java, a reference variable is a variable that stores the memory address of an object rather than the object itself. When you create an object in Java, it is stored in the heap memory and the reference to that object is stored in the stack memory.

    Reference variables are used to access and manipulate objects in Java. You can think of them as pointers in other programming languages. Unlike primitive data types (such as int, float, double, etc.), which hold the actual data value, reference variables hold a reference to the memory location where the object is stored.

    Here is an example of a reference variable in Java:


    public class ReferenceVariableExample {
        public static void main(String[] args) {
            // Create a new String object
            String str = new String("Hello World");

            // Assign the reference of the String object to a reference variable
            String strRef = str;

            // Print the values of the original reference variable and the new reference variable
            System.out.println("Original Reference Variable: " + str);
            System.out.println("New Reference Variable: " + strRef);
        }
    }

    In this example, we create a new String object and assign its reference to the str reference variable. We then assign the same reference to a new reference variable strRef. Both reference variables point to the same object in memory. When we print the values of the two reference variables, we get the same output, which is the value of the String object: Hello World.




    To calculate Test Estimation, check the link below:
    Automation Test Estimation


    What are the Types of APIs ?


    Gmail Automation with Cypress & JavaScript


    *******************************************************************
    For any doubts or career guidance, reach out to me 


    ********************************************************************





    Do remember that knowing Linux is one of the most important aspect to work as an SDET.

    Basic Linux Commands for Automation QA


    ****************************************

    TOP 15 BDD - CUCUMBER Interview Q&A


    ************************************************

    ✍️AUTHORLinkedIn Profile

    ************************************************

    Learn (API-Microservice)Testing+ Selenium UI Automation-SDET with Self Paced Videos prepared by FAANG employees and LIVE Doubt Session 

    SDET TRANING VIDEOS AVAILABLE with Live Doubt Session(course-1 below,API TRaining Videos With Class Notes and Coding Set) and (API+UI, both course-1 & 2 below) Check Training Page for Course Content or reach out @whatsapp +91-9619094122. 
    This includes classnotes, 300+ interview questions, 3 projects, Java Coding question set for product companies along with career guidance from FAANG employees for Automation and SDET.

    For more details whatsapp : https://lnkd.in/dnBWDM33

    *************************************************

    SeleniumWebdriver Automation Testing Interview Questions:

    https://automationreinvented.blogspot.com/search/label/SeleniumWebdriver

    API Testing Interview Question Set:

    https://automationreinvented.blogspot.com/2022/03/top-80-api-testing-interview-questions.html

    DevOps Interview Q&A:

    https://automationreinvented.blogspot.com/2021/11/top-11-devops-interview-questions-and.html 

    Kubernetes Interview Question Set

    https://automationreinvented.blogspot.com/search/label/Kubernetes

    Docker Interview Question Set

    https://automationreinvented.blogspot.com/Docker

    Linux Interview question Set

    https://automationreinvented.blogspot.com/search/label/Linux

    Automation Testing/SDET Framework Design

    https://automationreinvented.blogspot.com/search/label/FrameworkDesign

    Java Related Interview Question Set

    https://automationreinvented.blogspot.com/search/label/Java

    GIT Interview Question Set:

    https://automationreinvented.blogspot.com/2021/09/top-40-git-interview-questions-and.html

    Coding Interview Question Set:

    https://automationreinvented.blogspot.com/search/label/Coding%20Questions

    Mobile Testing Interview Question Set:

    https://automationreinvented.blogspot.com/search/label/Mobile%20Testing

    Python Interview Question Set for QAE - SDET - SDE:

    https://automationreinvented.blogspot.com/search/label/Python