Learn Selenium and Java for Selenium

Tuesday, 27 March 2018

Practice Club


Hello All,

Introduction:
Most of us studied everything related Autoamtion Testing,but could not get chance to implement.So,We are here with Practice Club.
In this club,we have designed some realtime assignmets for you.Adding more to that we have some automation experts they will review your assignments and provide review comments based on successful implementation and coding standard.

Pointer Structure:
After each assignment completion you will be getting 10 points. Of course there will be some rewards for candidate who has maximum pointers.

Steps:
1)Fill the below given Form
2)Within max 2 days you will recevie Assignment on your email Id
3)Submit your assignments
4)Within max 2 days you will recevie review comments
5)Implement review comments


Let's Start
Please fill up below form.It will just take 1 min.We will be sending assignment to your email id.
https://goo.gl/forms/x0scMISmY1PX90E63

Still any query ,Please feel to write to 'ashvelapure@gmail.com' (Note:Email subject name should start with 'Practice Club')

Sunday, 2 July 2017

Mobile automation using APPIUM

Mobile automation using APPIUM

Author : Ashwini Velapure (Test Automation Engineer)https://www.linkedin.com/in/ashwinivelapure


Hello everyone, Before we go for the mobile automation, we should be familiar with atleast core  JAVA and Selenium web driver.
Lets start!!
We have to follow 5 steps for achieving the complete mobile automation setup.
1.Android Setup and connecting android device to PC
2.Installtion of Appium
3. Required java code  and Modifications the as per mobile device model.
4.Run the Java Application
5.Inspect Mobile element.

1.Android Setup and connecting android device to PC
  1. a.Download latest android SDK for Windows. Following folders should be there.

  1. B.Open SDK manager.Install all the API.As appium support only above android 4.2.
It will take  more time.




Set environment variable
Right click on ‘My Computer’  Go to ‘Properties’

Go to Advanced system settings and Go to Environment variables TAB
.
ANDROID_HOME  will be pointing toward your Android SDK folder.

  1. Go ‘Command Prompt’.Type %ANDROID_HOME%. It will open Android SDK folder.

  1. Set PATH variable.
You just need to concatenate below String for your existing PATH.
;%ANDROID_HOME%\tools;%ANDRIOD_HOME%\platforms-tools



  1. Now Connect your android phone to laptop in Debug mode.
f.Go to ‘Command Prompt’.change directory to ‘Android SDK\platform-tools’
Type ‘ adb devices’
You will get attached devices.
(In screen shot,as my SDK is on D drive. I have changed the drive)


Here You done with Android Set up.

2.Installtion of Appium

 1: Downoad Appium From  http://appium.io/
Note:Extract  file and Install Appium.(If you are getting .NET frame work related error message,)


3.Required java code  and Modifications the as per mobile device model.
Java Code
package Ashwini;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import io.appium.java_client.android.AndroidDriver;

public class Appium {
      
       public static void main(String[] args) throws Exception {
             
             
              AndroidDriver driver;

       DesiredCapabilities capabilities = new DesiredCapabilities();
       //1
       capabilities.setCapability("deviceName","Redmi");
       capabilities.setCapability("platformName","Android");
       capabilities.setCapability("platformVersion","6.0.1");
//2
    File file=new File("C:\\Users\\ASHWINI1\\workspace\\Blog\\Apache POI\\src\\Ashwini\\first2.apk");
    capabilities.setCapability("app", file.getAbsolutePath());
//3
   
 driver=new AndroidDriver(new URL("http://192.168.1.103:4723/wd/hub"),capabilities);

WebElement ele=driver.findElementByAccessibilityId("Login");
 ele.click();
}
      


}

1.Here we are defining ,which android device we connecting to PC.You can get phone details from ‘Settings->Abpout Phone’. Give the android version which is present in ur mobile.

2.Here we giving apk file detail,which we are going to install on our phone
3.We need to give URL where appium is running.For getting this URL please follow below steps:
a)  Run cmd and type ip config
b)  Go to Appium General Settings.
.
c)  Give the server address same as machine ip


4.Run the Java Application
a.Launch the appium
b.Connect phone in USB debug mode.(also check device is connected propery by adb devices command)
c.Check the checkbox “No Reset”.(It will does not install android app on your phone,As its already intalled)

d.Start the Appium Node server.
c.Run the java application


5.Inspect Mobile element.
For inspecting mobile element,We need UiAutomaterViewer.This batch file is present in ‘Tools’Folder in the android SDK.
Connect your android phone to PC.Open android app in your phone,in which you are supposed to inspect element.


Using multiple types of locators you can automate your mobile application.








Tuesday, 24 May 2016

Automation Framework


Author : Ashwini Velapure (Test Automation Engineer) https://www.linkedin.com/in/ashwinivelapure

What is Automation Framework?
In simple words ,it is nothing but structure of code.
While starting for Automation Testing ,we need to have clear understanding for different types of  automation framework.
Types of Automation Framework:

  • Linear  FrameWork:
It is just sequential code. Steps  are collected one by one. More hard coding of values is one of the  drawback  of linear framework.
In selenium IDE, we can record flow. If we extract testcase,We will get  the java  code.You will get piece of code,which we can say linear automation framework.
For example, if we are automating Login application.Within linear frame work we will follow below steps:
a) Open URL for login page.
b) Enter the details.
c)  Click on Login.
d) Verify the home page

  • Modular Framework
In modular framework,there is dedicated doe for particular functionality, which can be called as ‘Module’.
For achieving this modularity, we are using JAVA,VB etc.
For example, if we are automating Login application and we need to save screenshots.
Within Modular frame work we will have separate  module for take Screenshot. This module will have code for taking screenshot and saving it on desire location
Whenever we land on page we will call take Screenshot  module
Steps :
a)Load Login Page
b)Call take Screenshot
c) Enter the details.
d) Click on Login.
e) Call takes Screenshot

  • Data Driven Framework:
When an application need to test with different set of data, Data driven Frame wok comes into picture.
For example:
If we are automating any login application and we need to check with different username and password. In this scenario we can keep separate data sheet for username  and password. Here we can use JXL/Apache POI for reading data sheet

  • Keyword Driven Framework:
It is similar data driven. Here we are reading keyword from data sheet instead of test data. This keyword may have one of the module associate with it.

  • Hybrid Framework
Hybrid Framework is combination of Data Driven framework and Modular Framework. This is commonly used framework.

  • TestNG Framework
This is advanced framework. It is famous for its reporting feature. We had  already had discussion on the previous blogs

Why Automation  Framework?
Definite structure of code  is very important ,below are some advantages:

  • Reusability
  • Maintainability
  • Readability
  • Scalability
How to select Type of Framework?

  • Based on Complexity of Web Application
This complexity can be determined  by number of pages and their web elements.
Also Number of scenarios incorporated for particular web application workflows.
So, for less complex application we can go with Data Driven FrameWork and for more complex application we can Hybrid framework

  • Based on Reporting requirement
Most of the Business people are not bother with code sctructure.They are only interested in Output.
So, reporting comes into the picture.TestNG  framework gives excellent reporting feature.





Sunday, 22 May 2016

TestNG| Creating the First Case

How to create Test Case using TestNG?

Creating TestCase is simple using TestNG. The main motive to create a Test Case using TestNG is because of it powerful framework and to avoid main() method.

Steps to create a TestNG  Test case

  • Ensure TestNG is correctly configured in Eclipse(Install TestNG)
  • Import the Package import org.testng.annotations.* in the respective Class
  • Use Annotation @ Test to run a particular Test Case
  • Run the Program  as TestNG
Running the Program as a TestNG


The below diagram depicts the flow of Running of Test Cases in accordance to Annotations used

Flow of Running the Test NG Cases 

 import java.io.File;  
 import java.io.IOException;  
 import org.apache.commons.io.FileUtils;  
 import org.openqa.selenium.By;  
 import org.openqa.selenium.JavascriptExecutor;  
 import org.openqa.selenium.OutputType;  
 import org.openqa.selenium.TakesScreenshot;  
 import org.openqa.selenium.WebDriver;  
 import org.openqa.selenium.WebElement;  
 import org.openqa.selenium.chrome.ChromeDriver;  
 import org.openqa.selenium.firefox.FirefoxDriver;  
 import org.testng.annotations.*;  
 public class TestNGProgram {  
      public WebDriver driver;  
      @BeforeClass   
      public void setup()  
      {  
           this.driver=new FirefoxDriver();  
      }  
      @AfterClass  
      public void teardown()  
      {  
           this.driver.quit();  
      }  
      @Test  
      public void loadpage()  
      {  
           driver.get("https://www.facebook.com/");  
           String s =driver.getTitle();  
           System.out.println(s);  
      }  
 }  



Notes
  1. this is a keyword in Java that can be used to refer current class instance variable hence it used to access the driver variable.
  2. Order of execution of above tests annotation is @BeforeClass>@test>@AfterClass
  3. There is no need to write main() method
  4. Title of facebook page is fetched using getTitle() method
Output



Saturday, 21 May 2016

Reading a Excel File using Apache POI


Author : Ashwini Velapure (Test Automation Engineer) https://www.linkedin.com/in/ashwinivelapure

Steps to Read the Excel File

  • Specify the Location of File
  • Load WorkBook
  • Load Sheet: Sheet can be loaded via getSheetAt() method , sheet name /index can be passed as argument.By default Sheet1 has zero index and so on
  • Load Cell: There are 2 methods offered by XSSFSheet class , one is get row() and the other is get Cell() ,the row number and the column number are passed as an argument respectively
  • Read Data
 import java.io.File;  
 import java.io.FileInputStream;  
 import java.io.IOException;  
 import java.util.Iterator;  
 import org.apache.poi.ss.usermodel.Row;  
 import org.apache.poi.xssf.usermodel.XSSFCell;  
 import org.apache.poi.xssf.usermodel.XSSFRow;  
 import org.apache.poi.xssf.usermodel.XSSFSheet;  
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;  
  public class ReadFile {  
      public static void main(String[] args) throws IOException {  
           // TODO Auto-generated method stub  
           FileInputStream file = new FileInputStream(new File("C:\\Users\\Ashish Banka\\Downloads\\Test1.xlsx"));  
           XSSFWorkbook workbook = new XSSFWorkbook(file);    
           XSSFSheet sheet = workbook.getSheetAt(0); //Read Sheet 1,   
           String S= sheet.getRow(0).getCell(0).getStringCellValue();  
           System.out.println(S);  
      }  
 }  

Notes

1-Eclipse support one forward slash or two backward slash ,so we have used two backword slash in order to locate the file
2- XSSFWorkbook is a class so we have created one reference variable "workbook" in order to access the method of this class which is getSheetAt()
3- As we know XSSFWorkbook is a class, its object can be created via new XSSFWorkbook(File)
4-getStringCellValue () method return a string value of Cell so we have stored in a string called "s"

Output


Output of Excel File displaying Row 0 and Column 0 value

Excel Sheet


Excel File used for Reading


Friday, 20 May 2016

What is Apache POI and how to Download it


Author : Ashwini Velapure (Test Automation Engineer) https://www.linkedin.com/in/ashwinivelapure

APACHE POI

What is Apache POI?
Apache POI is a powerful Java library to work with different Microsoft Office file formats such as Excel, Power point, Visio, MS Word etc.

In this API we can handle different types of excel files. Most of the interviewer don’t satisfied with only JXL.It is good to know about APACHE POI
Here, we go for Apache POI.


STEPS FOR GETTING APACHE POI:
  • Download ‘poi-bin-3.14.tar’ file from https://poi.apache.org/download.html

  • Extract the above .tar file to any folder
  • Right Click on Eclipse Project->Build Path->Configure Build Path->Libraries->Add external jar.
  • The following jar files needs to be added
    
    • Under ooxml-lib folder
         
    • Under lib folder
            
  • Brows all the above the poi jar file and add it
  • Here you can access the all Apache POI classes.



Friday, 6 May 2016

TestNG :Annotations Basic Concept

Annotations and its usage in Test NG

TestNG supports a series of annotations which are invoked when running the code. The Annotations is the powerful feature provided by TestNG in order to avoid using the Main() method.

Following are most commonly used annotations in Test NG

@BeforeSuite :-Annotates methods that will be run before any method in a given is run.

@BeforeGroups:-Annotates methods that will be run before the first method in any of the specified groups is run.

@BeforeClass:- Annotates methods that will be run before the first method on the current test class is run.

@BeforeTest:- Annotates methods that will be run before any method in a given is run

@BeforeMethod:-Annotates methods that will be run before each test method

@AfterMethod:-Annotates methods that will be run after every test method.

@AfterTest:-Annotates methods that will be run after all the test methods in a given have been run.

@AfterClass:- Annotates methods that will be run after the last test method on the current class is run.

@AfterGroups:-Annotates methods that will be run after the last test method belonging to the groups specified in its value attribute has been run. The annotated method is automatically put into these specified groups.

@AfterSuite:- Annotates methods that will be run after all the test methods in a given have been run.

@ Test : Annotates method as a Test Case

Note: While Running a Test Case with @ Test Annotation there is no need to write main() method


Popular Posts

Recent Posts



Newsletter

Join our newsletter to get secret tips directly in your inbox!


*We Hate Spam!

Powered by Blogger.