Posts

Blog on selenium

  Test automation with Selenium WebDriver and pytest     A brief about Selenium WebDriver Selenium is an open-source tool that automates web application testing across numerous platforms such as Windows, Mac, and Linux. With Selenium, you can perform web testing against some of the popular browsers like Chrome, Firefox, Opera, Microsoft Edge, etc. It also supports various programming languages like Python, C#, Ruby, PERL, Java, etc. Selenium WebDriver is one of the core components of the Selenium framework. It is a collection of open-source APIs that are used to automate the testing of a web application. It allows test automation to open a browser, then sends clicks, type keys, scrape text, and finally exit the browser cleanly. There are particular drivers for the browsers that include Chrome, Firefox, Opera, Microsoft Edge.   driver = Chrome() - Chrome() initializes the ChromeDriver instance using the default options on your local machine. driver.impli...

Blog on Pytest

  Testing Python Applications with Pytest     Pytest is a testing framework and test runner for Python. In this guide, we will look at the most useful configuration and usage, including several pytest plugins and external libraries.   Pytest basics  Pytest will automatically scan our codebase for test modules, files following the file name convention test_*.py or *_test.py , and scan them for functions named test_*() . If we want to run tests defined as methods inside classes, we need to prefix the class names with Test . Pytest will also automatically pick up any tests written using unittest module.   Standard test functions and test runs from python_pytest . basics import add def test_add_can_add_numbers ( ) : # given num = 3 num2 = 45 # when result = add ( num , num2 ) # then assert result == 48 By default, fixtures are function-scoped, meaning that a fixture's lifetime is t...

Unittest

Unit Testing in Python  Unit Testing is the first level of software testing where the smallest testable parts of a software are tested.  This is used to validate that each unit of the software performs as designed. import unittest     class SimpleTest(unittest.TestCase):        def test( self ):                  self .assertTrue( True )     if __name__ = = '__main__' :      unittest.main()  This is the basic test code using unittest framework, which is having a single test. This test() method will fail if TRUE is ever FALSE.   There are three types of possible test outcomes : OK – This means that all the tests are passed. FAIL – This means that the test did not pass and an AssertionError exception is raised. ERROR – This means that the test raises an exception other than AssertionError.    EXAMPLE : import...

Assert in testcases

  Unit Testing in Python – Unittest What is Unit Testing? Unit Testing is the first level of software testing where the smallest testable parts of a software are tested. This is used to validate that each unit of the software performs as designed.   import unittest     class SimpleTest(unittest.TestCase):          # Returns True or False.       def test( self ):                  self .assertTrue( True )     if __name__ = = '__main__' :      unittest.main()   assertEqual() function  assertEqual() in Python is a unittest library function that is used in unit testing to check the equality of two values. This function will take three parameters as input and return a boolean value depending upon the assert condition. If both input values are equal assertEqual() will return true else retur...

Annotations in Java

Image
  Annotations in Java :             Annotations are used to provide additional information about a program.  Annotations start with @ Annotations do not change the action of a compiled program. Annotations help to associate metadata (information) to the program elements i.e. instance variables, constructors, methods, classes, etc. Annotations are not pure comments as they can change the way a program is treated by the compiler. Annotations basically are used to provide additional information, so could be an alternative to XML and Java marker interfaces.   Example 1 :   package java ; public class ann { public void display (){ System. out .println( "hell0 children" ) ; } } class ch1 extends ann{ @Override public void display () { super .display() ; // System.out.println("hello"); } public static void main (String[] args) { ch1 c1 = new ch1() ; c1.display() ; @SuppressWar...

Queue in Java

Image
  Queue Interface In Java :   The Queue interface present in the java.util package and extends the Collection interface is used to hold the elements about to be processed in FIFO(First In First Out) order.  It is an ordered list of objects with its use limited to insert elements at the end of the list and deleting elements from the start of the list, (i.e.), it follows the FIFO or the First-In-First-Out principle.       queue needs a concrete class for the declaration and the most common classes are the PriorityQueue and LinkedList in Java.   Queue is an interface, objects cannot be created of the type queue. We always need a class which extends this list in order to create an object   Example : import java.util.LinkedList ; import java.util.Queue ; public class q { public static void main (String[] args) { Queue<Integer> qu = new LinkedList<>() ; for ( int i = 0 ; i < 5 ; i++) ...

Method Over riding in Java

Method Overriding in Java : If subclass (child class) has the same method as declared in the parent class, it is known as method overriding in Java . In other words, If a subclass provides the specific implementation of the method that has been declared by one of its parent class, it is known as method overriding.   Usage of Java Method Overriding Method overriding is used to provide the specific implementation of a method which is already provided by its superclass. Method overriding is used for runtime polymorphism   Rules for Java Method Overriding The method must have the same name as in the parent class The method must have the same parameter as in the parent class. There must be an IS-A relationship (inheritance).   // normal parent and child class usage class  Vehicle{      void  run(){System.out.println( "Vehicle is running" );}   }     //child class    class  Bike  exte...

Method Over loading in Java

 Method Overloading in Java :    If a class has multiple methods having same name but different in parameters, it is known as Method Overloading   If we have to perform only one operation, having same name of the methods increases the readability of the  program . If we have to perform addition of the given numbers but there can be any number of arguments, if you write the method such as a(int,int) for two parameters, and b(int,int,int) for three parameters then it may be difficult for you as well as other programmers to understand the behavior of the method because its name differs.    Method overloading increases the readability of the program.     two ways to overload the method in java By changing number of arguments By changing the data type   1) Method Overloading: changing no. of arguments In this example, we have created two methods, first add() method performs addition of two numbers and second add method performs additio...

OOPS in Java

Object Oriented Programming Object-oriented programming has several advantages over procedural programming: OOP is faster and easier to execute OOP provides a clear structure for the programs OOP makes it possible to create full reusable applications with less code and shorter development time     What are Classes and Objects? Classes and objects are the two main aspects of object-oriented programming.   class is a template for objects, and an object is an instance of a class. When the individual objects are created, they inherit all the variables and methods from the class.     Create an Object In Java, an object is created from a class. We have already created the class named Main , so now we can use this to create objects. To create an object of Main , specify the class name, followed by the object name, and use the keyword new : Example public class Main { int x = 5 ; public static void main ( String [ ] args ) { Main ...