GroTechMinds

Automation testing with Java and Selenium
Automation Testing All Differences from Java and Selenium
This Calling Statement Super Calling Statement
It is use in the case of constructor overloading It is use in the case of inheritance
It should be written explicitly It can be written both ways
It is use to call from one constructor to another constructor within class It is use to call from one one constructor of one class to another constructor of another class
It should be the first line in any constructor It should be the first line in any constructor and we can’t have combination of this and super calling statement in any constructor
This keyword Super Keyword
Whenever global variable and your method parameter are same then we can use this keyword It is use only in the case of method overriding if you need parent class implementation along with child class implementation
This keyword can be written only in the case of non static method Super keyword can be written only in the case of non static method
Abstract Class Interface
   
Abstract class can have abstract and non-abstract methods. Interface can have only abstract methods. Since Java 8, it can have default and static methods also.
Abstract class doesn’t support multiple inheritance. Interface supports multiple inheritance.
Abstract class can have final, non-final, static and non-static variables. Interface has only static and final variables.
Abstract class can provide the implementation of interface. Interface can’t provide the implementation of abstract class.
The abstract keyword is used to declare abstract class. The interface keyword is used to declare interface.
An abstract class can extend another Java class and implement multiple Java interfaces. An interface can extend another Java interface only.
An abstract class can be extended using keyword “extends”. An interface can be implemented using keyword “implements”.
A Java abstract class can have class members like private, protected, etc. Members of a Java interface are public by default
It can have constructors and static methods also.  
Throw keyword Throws keyword
   
Used within a method (or constructor) Used with method (or constructor) signature
Used to throw an exception explicitly Used to declare exceptions
Can only throw a single exception Can declare multiple exceptions
Followed by a throwable instance Followed by an exception class name
Cannot be used to propagate checked exceptions by itself Can be used to propagate checked exceptions by itself
Local Variable Global Variable
   
Definition: It is present within any method It is present outside any methods but within the class.
Scope: WIthin method From the beginning of class and til the end of clas
cannot classify them into static and non static It can be static and non static
it will not have any default value Global Variable will have its own default value
It has to be initialized before utilising them. Can be utilised without even initializing it
Final Keyword Finally Keyword
   
It can be used with variable,Class and methods. It is keyword to be used in exceptional handling concept of Java.
Any variable which is final will not change its value Finally keyword to be used only after try and catch block.
Any method which is final cannot be overridden Since we are not sure if try will execute or catch will execute but we are sure that finally will execute for sure.
Any class which is final can never be inherited.  

 

Arrays Collection
Can store only homogeneous value It can store both homogeneous and heterogeneous value.
Arrays are known for its fixed size-we cannot increase or decrease the size of an array at run time here we can increase or decrease the size of a collection at run time
Arrays is a in built feature of java but we have to develop the logic Collection framework is an API which provides classes,methods and interfaces in it
Syntax:
String name[]=new String[3];
or
String name[]={“RAM”,”Vishnu”,”Sham”};
Syntax:
ArrayList a1=new new ArrayList();
This Calling Statement Super Calling Statement
It is use in the case of constructor overloading It is use in the case of inheritance
It should be written explicitly It can be written both ways
It is use to call from one constructor to another constructor within class It is use to call from one one constructor of one class to another constructor of another class
It should be the first line in any constructor It should be the first line in any constructor and we can’t have combination of this and super calling statement in any constructor
FindElement FindElements
Return type is WebElement Return Type is List<Webelement>
If element is not found it will give NoSuchElementException If element is not found it will give empty list
Implicit Wait Explicit wait
Here we don’t specify any condition Here we specify condition
If specify time is over then it will throw NoSuchelementException If time is over it will throw Timeout exception
Once written it can be use for all FE and FE’s in the script Whichever method you wish to synchronized just above that use this
Syntax: Syntax:
driver.manage().timeouts.implicitlywait(10,TimeUnit.Seconds) WebdriverWait wait=new WedDriverWait(driver,10);
GetWindowHandle GetWindowHandles
Return type is String Return type is set of string
It will retrieve the id of the current browser It will retrieve the id of all the browser including parent and child.
Static Non Static
If you don’t want to store results in the server or when you just want to send response based on user request we can choose static methods. When we want to store results we can choose non static methods.
Declared using static keyword Declared without using static keyword
Can be access directly in the class with its method name or can also be accessed using classname.methodname Can be accessed by creating an Object
Can access only other static methods Can access both static and non static methods
Memory allocation is just one copy Each object has its own copy
Static methods cannot be overridden Non static methods can be overridden
It consumes less memory It consumes more memory
Static variables can be accessed by static and non static methods Non static variables cannot be accessed inside a static method.
Cannot use “this” keyword and “super” keyword in static method Can use “this” keyword and “super” keyword in non static method only
Static methods can’t be used for abstraction and inheritance. Non static methods should be used for abstraction and inheritance.
List Interface Set Interface
List is an Index based data Structure. Set is not an index based data Structure. It stores the data according to hashcode values.
List Can Store Duplicate Elements. Set does not allow to stores duplicate elements.
List can store any number of null values. Set can store only one null value in it.
List follows the insertion order. Set does not follow the insertion order.
We can iterate (get) the list element by Iterator and ListIterator. We can Iterate the set elements by Iterator only.
ArrayList, LinkedList, Vector and Stack are implemented classes of List. HashSet, LinkedHashSet, TreeSet are implemented classes of Set.
Iterator ListIterator
   
Iterator cursor can be used with any Collection object. ListIterator cursor can be used with only List implemented classes. i.e. ArrayList, LinkedList, Vector & Stack.
Iterator Methods are: hasNext(), next(), remove(). ListIterator Methods are: hasNext(), next(), hasPrevious(), previous(), remove(), set().
By using Iterator cursor, We can retrieve the elements only in forward direction. By using ListIterator cursor, We can retrieve the elements in forward & backward direction.
By using Iterator cursor, We can read & remove the elements. By using ListIterator cursor, We can read, remove, replace & add the elements.
We can get Iterator cursor by iterator() method. Iterator itr=l.iterator(); We can get ListIterator cursor by listIterator() method. ListIterator litr=l.listIterator();
ArrayList LinkedList
ArrayList acts as List LinkedList acts as List & Deque.
The underline data-structure of ArrayList is growable and resizable array. The Underline data-structure of LinkedList is “Doubly LinkedList” OR “Circular LinkedList”.
Memory efficient. It only stores the object in the list. Memory inefficient. It stores the object and the pointers to next and previous nodes.
ArrayList are good for retrieval operations. LinkedList are good for insertion or deletion operation.
ArrayList are worst for insertion or deletion operation. LinkedList are worst for retrieval operations.

Conclusion: In conclusion, understanding the differences between Java and Selenium in automation testing is important for improving the efficiency and efficacy of your testing operations. By combining the distinct features and capabilities of Java and Selenium, you can construct powerful and dependable automated tests that verify your product runs correctly.

Upskill Yourself
Consult Us