GroTechMinds

Automation testing with Java and Selenium
Automation Testing All Differences from Java and Selenium
This Calling StatementSuper Calling Statement
It is use in the case of constructor overloadingIt is use in the case of inheritance
It should be written explicitlyIt can be written both ways
It is use to call from one constructor to another constructor within classIt 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 constructorIt should be the first line in any constructor and we can’t have combination of this and super calling statement in any constructor
This keywordSuper Keyword
Whenever global variable and your method parameter are same then we can use this keywordIt 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 methodSuper keyword can be written only in the case of non static method
Abstract ClassInterface
  
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 keywordThrows keyword
  
Used within a method (or constructor)Used with method (or constructor) signature
Used to throw an exception explicitlyUsed to declare exceptions
Can only throw a single exceptionCan declare multiple exceptions
Followed by a throwable instanceFollowed by an exception class name
Cannot be used to propagate checked exceptions by itselfCan be used to propagate checked exceptions by itself
Local VariableGlobal Variable
  
Definition: It is present within any methodIt is present outside any methods but within the class.
Scope: WIthin methodFrom the beginning of class and til the end of clas
cannot classify them into static and non staticIt can be static and non static
it will not have any default valueGlobal Variable will have its own default value
It has to be initialized before utilising them.Can be utilised without even initializing it
Final KeywordFinally 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 valueFinally keyword to be used only after try and catch block.
Any method which is final cannot be overriddenSince 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. 

 

ArraysCollection
Can store only homogeneous valueIt 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 timehere 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 logicCollection 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 StatementSuper Calling Statement
It is use in the case of constructor overloadingIt is use in the case of inheritance
It should be written explicitlyIt can be written both ways
It is use to call from one constructor to another constructor within classIt 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 constructorIt should be the first line in any constructor and we can’t have combination of this and super calling statement in any constructor
FindElementFindElements
Return type is WebElementReturn Type is List<Webelement>
If element is not found it will give NoSuchElementExceptionIf element is not found it will give empty list
Implicit WaitExplicit wait
Here we don’t specify any conditionHere we specify condition
If specify time is over then it will throw NoSuchelementExceptionIf time is over it will throw Timeout exception
Once written it can be use for all FE and FE’s in the scriptWhichever 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);
GetWindowHandleGetWindowHandles
Return type is StringReturn type is set of string
It will retrieve the id of the current browserIt will retrieve the id of all the browser including parent and child.
StaticNon 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 keywordDeclared without using static keyword
Can be access directly in the class with its method name or can also be accessed using classname.methodnameCan be accessed by creating an Object
Can access only other static methodsCan access both static and non static methods
Memory allocation is just one copyEach object has its own copy
Static methods cannot be overriddenNon static methods can be overridden
It consumes less memoryIt consumes more memory
Static variables can be accessed by static and non static methodsNon static variables cannot be accessed inside a static method.
Cannot use “this” keyword and “super” keyword in static methodCan 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 InterfaceSet 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.
IteratorListIterator
  
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();
ArrayListLinkedList
ArrayList acts as ListLinkedList 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