Java:
-----
>It is a High level Programming Language
>It is free
>It is Open Source
>It is Platform Independant (Supports Multiple OS) : WORA : Write Once And Run AnyWhere
>Supports OOP's Concepts
>Secure
>Supports Multi-Threading (At a time Multiple Programms can be run)
Configuration Needed in Your System:
------------------------------------
1.JDK (Java development Kit) : It tells your System what are the protocols (rules & regulations of Java)
JDK = JRE + Developement Tool (Compiler, debugger etc.)
JRE = System Libraries + JVM
You can Download & Install JDK as well as JRE also
2.Editor : The place where we write Code
Notepad, Notepad++, Eclipse, Netbean
------------------------------------------------------------------------------------
Java Programme Execution Process:
---------------------------------
A.java > Compiler > A.class > JVM(Contains Interpreter) > 01001's
High middle level Low Level
Level ByteCode Language
JVM of Window
> JVM(Contains Interpreter) > 01001's
JVM of Linux
> JVM(Contains Interpreter) > 01001's
-------------------------------------------------------------------------------------
You Need to
1.Java Project
2.Create Package(folder)
3.Create Class (Smallest Unit in Java)
---------------------------------------------------------------------------------
Data Types :
-----------
1.int 4 Bytes = 32 bits = 2^32
2.long 8 bytes = 64 bits
3.short 2 bytes
4.float 4 byte
5.double 8 bytes
6.boolean 1 bit
7.char 2 bytes
8.String
----------------
Operators in Java
+
-
*
/
% (Mod) : This gives reminder after taking mod.
5/2 = 2
5%2 = 1
Comparision Operators:
---------------------
> Greater Than
< less Than
>= Greater Than & Equals to
<= less Than & Equals to
== equal to equal to
!= Not Equal to
Logical Operator:
----------------
&& - and Operator
|| - OR Operator
! - Not Operator
----------------------------------------------------------------------------------
Conditional Statement:
----------------------
if
if else
switch : It should be used in case of Multiple option avaibility & You need to Choose Only one out of that.
It does support Comparision operator, Logical Operator( For this you need to use if statement)
Loops are used for performing repitative task multiple time
for(counter initialization ; condition; increament counter){
}
-------------------------------------------------------------------------------
What is Array : It is Collection of Similar Kind of Data
--------------------------------------------------------------------------------
OOPS:
-----
What is Object : Any thing in this world which is having some
1.Properties
2.Behavior
They are called as Object.
Any Object if we try to represent through Programming that will be called as Object Oriented Programming.
PEN:
----
Properties/Noun: > Variables
-----------
BrandName
Color
nipSize
price
bodyMatrial
type
Behavior/Action/Verb: > Methods/functions
---------------------
Writing
Changing Refill
Opening & Closing
Human
Properties :
name
gender
age
height
dob
hairColor
Behavior
Eating
Walking
Running
Sleeping
Dancing
laughing
Human prem =new Human();
prem.eating()
prem.dancing
When You Keep Properties & Behaviors of any object into single Unit then it will be called as Class
Class is Blueprint/template/Architecture of Object
---------------------------------------------------------------------------------------
Scanner sc=new Scanner(System.in)
---------------------------------------------------------------------------------------
Loan Management System:
------------------------
public void Loan{
300 lines of Code which is common to all
}
public PLoan extends Loan public void VLoan extends Loan public void Hloan extends Loan
{ { {
//700 //700 lines //700 lines
} } }
public vodi ELoan extends Loan{
//700
}
LOC
>900 Lines of Code is Saved
>less Devlopment Hours will be required.
>Code will be Easy Change(Maintain)
IS-A RelationShip
Every Personl Loan IS-A loan
Every Education Loan IS-A loan
Every Loan is-A Personal Loan
Loan Class is A Parent Class
Education Loan, Personal Loan is Child Classes
-------------------------------------------------------------------------------------
Two_Wheeler
Three_Wheeler
Four_Wheeler
HeavyVehicles
For Common things you need to create a Parent Class
--------------------------------------------------------------------------
PolyMorphism:
-------------
Poly - Many
Morphism - Many Forms
assertEquals is example of PolyMorphism.
There will be multiple methods with same name but different implementation
1.Method OverLoading
2.Method Overriding
(We need two Classes with Parent & Child Relationship)
And One Method will be there which will be common in Parent as well as Child also
-------------------------------------------------------------------------------
Class is called blueprint of any Object
And It is collection of States/Properties/variable & behavior/actions/verbs/methods
Human prem=new Human()
prem.dance()
--------------------------------------------------------------------------------
Inheritance :
Taking properties from Parent to Child
Class Parent
{
}
Class Child extends Parent
{
}
Advantage:
1.LOC is Saved
2.Easy to Change
3.Development Hours also required less
-------------------------------------------------------------------------------------
PolyMorphism :
Poly Means Many
Morphism : Forms
Many Forms
1.Method Overriding
> We need two Classes which Parent & Child Relationship
2.Method Overloading
---------------------------------------------------------------------------
Encapsulation :
---------------
1.If Combine methods/Behavior & Variables(Data Member) into Single unit then it will consider as Encapsulation
2.Data/Variable Hinding ( To Increase liitle Security)
3.Tight Encapsulation:
It happens when you keep all variables as Private & with the help of getter & Setter you access to them .
Abstraction :
-------------
It is showing necessary things.
-----------------------------------------------------------------------------
Interface
Abstract Class:
----------------------------------------------------------------------------
Interface: In general, It is set of guidelines/ rules which need to be followed for
globalization
---------------------------------------------------------------------------------
Samsung
in_call
outgoing call
incoming sms
outgoing sms
D1 D2 D3 D4
Galaxy Eseries Jseries Guru
in_call i_call() incoming_call in_calling
{
10 loc
}
in_sms o_call outgoing_call out_calling
out_sms o_sms outgoing_sms in_smsing
out_call i_sms incoming_sms out_smsing
Inteface Declares Methods Name & Every Classes must follows those Names.
Interface is Set of Abstract Methods
1.You can not make Object of Interface
2.If follow Parent p=new Child > It will hide All Child Specific Method
3.If you use Parent p=new Child then It can hold Object of Any Child
WebDriver driver=new OperaDriver
WebDriver is Interface & ChromeDriver, FirefoxDriver, OperaDriver, SafariDriver are Classes.
Then WebDriver is Parent & ChromeDriver, FirefoxDriver, OperaDriver, SafariDriver
are Child
WebDriver driver=new OperaDriver
1.Using above Code driver can hold Object of Any Child
2.Extra Functions of Child will get hide automatically.
----------------------------------------------------------------------------------
Interface: Abstract Class:
--------- ---------------
1.It is 100% abstract 1.Method may have Body or may not have
2.It uses 'implements' keyword 2.It used abstract Keyword
3.use: 3.Use
When dev/lead wants make protocol When developer knows Partial
/rule or they don't know coding implementation (Means coding of some
/implementation of any method methods devlopers knows
)
----------------------------------------------------------------------------------
Why Exception Handling is Needed ?
-----------------------------------
To have normal termination(Smooth Execution without stopping programme in between) of Programme.
----------------------------------------------------------------------------------------
What is Selenium ?
------------------
>It is Functional Testing tool designed only for Web Application Testing
>It is free
>it is Open Source
>Platform Independant( Supports Multiple OS i.e Windows, Linux, MAC etc)
>Supports Multiple Browsers i.e Chrome, Firefox, Opera etc.
>Supports OOP's Languages i.e java, c#, ruby, python etc.
>It is Best Suited for Regression Testing( Since It is repitative)
Test Suite - Collection of Test Cases
Selenium Suite:
1.Selenium IDE: (Not in Use)
>Available as Firefox & Chrome Plug-in(It get installed as Extension )
>It has very powerful feature of Record & PlayBack
>Easy to Learn
>Easy to install
>No programming Skills are required
>Best Tool for Fresher tester to Start with Automation Testing.
> One Machine +2 Browsers are there
DisAdvantage:
>Code re-usability Concept is there due to lack of Programming Support
>Communication with dataBase & Excel is not Supported
>No Proper Sharable report is generated in case of Selenium IDE
>Supports Testing only on two browser(Chrome & Firefox)
2.Selenium RC/Selenium 1.0 (OutDated since It is Slow)
> One Machine +Multiple Browsers are there
DisAdvantage :
--------------
1.Selenium RC server act as middle man which adds delay in Script Execution
2.RC server need to started & Stopped evevry time which also consumes time
Above 2 reason makes Selenium RC slow hence it is outdated
3.Selenium WebDriver | Selenium 2.0 | Selenium 3.0 |Selenium 4.0 (about to come)
>Both Support Multiple Browser i.e Chrome, Firefox, Opera, ie etc.
>Both Support Multiple OOPs Labguage i.e Java, C#, Ruby, Python etc.
>Both are Test Design(Writing Test Cases) + Test Execution
>Selenium WebDriver is Faster than Selenium RC
> One Machine +Multiple Browsers are there
4.Selenium Grid
>Multiple Machine +Multiple Browsers are there
>Various Browser & OS Combination can be Checked
>One System will act as Master/Hub & Other System will act as Slave/Node
Master will control Execution all other System.
>Using Selenium Grid Parallel testing on Multiplen OS is possible Hence It Saves your Execution Time.
> It is just a Test Execution Tool (It is Not a Test Designing Tool)
Test Designing/Scripting Supported using WebDriver only
----------------------------------------------------------------------------------
In 2004 , Jason Huggins engineer at thoughtwork was Performing Regression Tesing on WebApplication, And By Performing Regression Testing he understood that regression testing is repitative in nature.
Hence Json written one Java Script having capacity of Record & Playback named as JavaScriptTestRunner later it is renamed as Selenium
-----------------------------------------------------------------------
Configuration Needs:
---------------------
1.JDK
2.Eclipse
3.Selenium Java Libraries
4.Browser Drivers are need
Chrome - ChromeDriver
Firefox- GeckoDriver
package sel_day1; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; public class FirstScript { public static void main(String[] args) throws Exception{ //WebDriver is interface & ChromeDriver, FirefoxDriver, OperaDriver etc. are Classes /*which implements WebDriver WebDriver is Parent & ChromeDriver, FirefoxDriver, OperaDriver are classes*/ //Setting the path of Executable Driver System.setProperty("webdriver.gecko.driver", "C:\\Users\\Bhajan\\Desktop\\SelJars\\geckodriver-v0.28.0-win64\\geckodriver.exe"); WebDriver driver=new FirefoxDriver();// ChromeBrowser will Start By this> Parent p=new Child //Opening URL driver.get("http://selenium.dev"); //Getting title String title=driver.getTitle(); System.out.println("You are on "+title+" Page"); Thread.sleep(3000); driver.quit(); // Browser will get Close } }
Day 2: OrangeHrm
package sel_day2; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class OrangeHrm { public static void main(String[] args) throws Exception { System.setProperty("webdriver.chrome.driver", "C:\\Users\\Bhajan\\Desktop\\SelJars\\chromedriver_win32\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("https://opensource-demo.orangehrmlive.com/index.php/auth/login"); driver.findElement(By.id("txtUsername")).sendKeys("admin"); driver.findElement(By.id("txtPassword")).sendKeys("admin123"); driver.findElement(By.id("btnLogin")).click(); Thread.sleep(2000); driver.findElement(By.id("welcome")).click(); Thread.sleep(2000); driver.findElement(By.linkText("Logout")).click(); } }
Day 2: SeleniumHQ
package sel_day2; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class SeleniumHQ { public static void main(String[] args) throws Exception { System.setProperty("webdriver.chrome.driver", "C:\\Users\\Bhajan\\Desktop\\SelJars\\chromedriver_win32\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("http://selenium.dev"); //Find the Object using findElement Function & Then Click driver.findElement(By.linkText("Downloads")).click(); String title = driver.getTitle(); System.out.println("You are on " + title + "Page"); driver.findElement(By.name("search")).sendKeys("SQUAD"); Thread.sleep(3000); driver.quit(); } }
Day 3: CSS_Example
package sel_day3; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class CSS_Example { public static void main(String[] args) throws Exception{ System.setProperty("webdriver.chrome.driver", "C:\\Users\\Bhajan\\Desktop\\SelJars\\chromedriver_win32\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("https://opensource-demo.orangehrmlive.com/index.php/auth/login"); //tagname#id driver.findElement(By.cssSelector("input#txtUsername")).sendKeys("admin"); //tagname[name/type/value/other property='value of that property'] driver.findElement(By.cssSelector("input[type='password']")).sendKeys("admin123"); driver.findElement(By.cssSelector("input[value='LOGIN']")).click(); // tagName.className driver.findElement(By.cssSelector("a.panelTrigger")).click(); Thread.sleep(3000); driver.findElement(By.cssSelector("a[href='/index.php/auth/logout']")).click(); } }
Day 3: FrontAcc_css
package sel_day3; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; public class FrontAcc_css { public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\\Users\\Bhajan\\Desktop\\SelJars\\chromedriver_win32\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("http://demo.frontaccounting.eu/index.php"); driver.findElement(By.cssSelector("input[name='user_name_entry_field']")).clear(); driver.findElement(By.cssSelector("input[name='user_name_entry_field']")).sendKeys("demouser"); driver.findElement(By.cssSelector("input[type='password']")).clear(); driver.findElement(By.cssSelector("input[type='password']")).sendKeys("password"); driver.findElement(By.cssSelector("input[type='submit']")).click(); driver.findElement(By.cssSelector("a[href='./access/logout.php?']")).click(); } }
Day 4: DropDown
package sel_day4; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.Select; public class DropDown { public static void main(String[] args) throws Exception { System.setProperty("webdriver.chrome.driver", "C:\\Users\\Bhajan\\Desktop\\SelJars\\chromedriver_win32\\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.get("http://blazedemo.com"); WebElement E = driver.findElement(By.name("fromPort")); Select dep = new Select(E); // When ever you want to work with dropdown make object of Select Class dep.selectByVisibleText("Boston"); Thread.sleep(2000); dep.selectByIndex(6); Thread.sleep(2000); dep.selectByValue("Portland"); driver.findElement(By.xpath("/html/body/div[3]/form/div/input")).click(); } }
Only required information’s., Great blog to check out.
ReplyDeleteSelenium Course in Chennai
Software Testing Course in Chennai