Selenium Tutorial 8

Selenium Tutorial 8

Recap:
 

1) Overview on Test Automation

2) Overview on Selenium

3) Selenium Test Process

4) Java for Selenium
--------
5) Java Environment setup

6) Java program structure/Java Syntax

7) Writing comments

8) Java Data types

9) Java Modifiers

10) Java Variables

11) Java Operators

12) Java Conditional statements

13) Java Loop statements

14) String handling in Java

15) Arrays in Java

16) Java Methods - Built-in methods

17) Java Methods - User defined methods

18) Java exception handling
---------------------------------------
Input and Output Operations in Java.
There are three ways available for reading input:
i) Scanner

ii) DataInputStream

iii) BufferedReader
---------------
Using java.util.Scanner is the easier and includes many methods to check input data is valid to read.

Example:
package javaiooperations;
import java.util.Scanner;
public class ReadInput {
public static void main(String [] args){
    Scanner scan = new Scanner(System.in);
   
    System.out.println("Enter Your Name");
    String s1 = scan.nextLine();
    System.out.println("Your Name is: " + s1);
   
    System.out.println("Enter Your City Name");
    String s2 = scan.next();
    System.out.println("Your City Name is: " + s2);
   
    System.out.println("Enter Your Number");
    int a = scan.nextInt();
    System.out.println("Your Number is: " + a);
   
    System.out.println("Enter Your City Name");
    double b = scan.nextDouble();
    System.out.println("Value is: " + b);
    scan.close();
}
}
-------------------------------------------
File handling in Java
Two categories of File System Operations

i) High level operations / External operations

Create a folder

delete a folder

create a text file

delete a text file etc...

ii) Low level operations / Internal operations

Read data

Write data etc...
------------------------
Using File Class we can perform High level operations

Examples:
1) Create a Folder
package javaiooperations;

import java.io.File;

public class CreateFolder {
   
    public static void main(String [] args){
        File fileObject = new File("C:/Users/G C Reddy/Desktop/Selenium");
        fileObject.mkdir();
        }
}
---------------------------------
2) Check the existence of Selenium Folder


public static void main(String [] args){
        File fileObject = new File("C:/Users/G C Reddy/Desktop/UFT");
        boolean a = fileObject.exists();
        System.out.println(a);
        }
-------------------------------------
3) Delete a Folder
public static void main(String [] args){
        File abc = new File ("C:/Users/G C Reddy/Desktop/Selenium");
        abc.delete();
        boolean a = abc.exists();
        //System.out.println(a);
        if (a == true) {
            System.out.println("Folder exists");
        }
        else{
            System.out.println("Folder doesn't exist");   
        }
        }
-----------------------------------
4) Create a Text file
public class CreateFolder {
   
    public static void main(String [] args){
        File abc = new File ("C:/Users/G C Reddy/Desktop/Selenium.txt");
        try {
            abc.createNewFile();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
-------------------------------------------
5) Delete a text file


    public static void main(String [] args){
        File abc = new File ("C:/Users/G C Reddy/Desktop/Selenium.txt");
        abc.delete();
       
    }
------------------------------------               
Java OOPS
Inheritance

Polymorphism

Abstraction

Encapsulation
-------------------------------------------
Java Inheritance
> It is a process of inheriting (reusing) the class members 9variables and methods) from one class to another class is called Inheritance.

> Non static (object level) class members only can be inherited.

> The class from where the class members are getting inherited is called as Super class/ Parent class/base class

> The class to which the class members are getting inherited is called
Sub class/ Child class / Derived class.

> The Inheritance between Super class and Sub class is achieved using "extends" keyword.

Syntax:

Class SubClass extends SuperClass {
//body
}
They are three types of Inheritance:

i) Single Inheritance
Ex:

Class B extends Class A
---------------------------
ii) Multi level inheritance:
Ex:

Class B extends Class A

Class C extends Class B

iii) Multiple Inheritance (*Java doesn't support)

Ex:

Class B extends Class A

Class C extends Class B

In Class C
add method
-----------------------------
Class C extends Class D
-------------------------------

0 comments:

Post a Comment