Android apps to use in appium android test examples

Breaking

Tuesday, June 12, 2018

TestNG Framework for Selenium


TestNG Framework for Selenium

1) Introduction to TestNG Framework
2) Install TestNG as well as write outset TestNG Test Case
3) Create multiple Test cases as well as Run.
4) Create as well as execute multiple Programs / Classes using XML
5) Grouping Test Cases as well as Run
6) Parallel Test Execution
7) Data Driven Testing using DataProvider 
--------------------------------------------------
1) Introduction to TestNG Testing Framework

In Selenium using Java at that spot are 2 Testing frameworks available,

i) JUnit

ii) TestNG
-------------------------
Note:

Java - JUnit, TestNG
C# - NUnit, haskell
PHP - Behat + Mink
Ruby - Rspec, Test::Unit
Python - Pyunit, Py.test Etc...
------------------------------------------------------------
TestNG Framework Features

> TestNG is a Testing Framework designed to simplify, a wide arrive at of Testing needs from Unit Testing to System Testing.
> Initially developed for Unit Testing, similar a shot used for all kinds of Testing
> TestNG is an opened upward root framework, where NG stands for Next Generation.
> TestNG inspered past times JUnit (Java Platform), as well as NUnit (.NET platform) but introduced simply about novel functionalities.
--------------------------------------------------------
Advantages of TestNG:

i) TestNG Annotations are slowly to practise Test Cases
ii) Test cases tin hold out grouped as well as prioritized to a greater extent than easily.
iii) Supports Parameterization.
iv) Execute multiple programs / classes using XML.
v) Generate HTML Reports.
vi) Parallel Test Execution.
--------------------------------------------------------
2) Install TestNG as well as write outset TestNG Test Case.

In Eclipse IDE,

> Help menu
> Select "Install novel Software"
> Click "Add"
> Enter Name "TestNG"
> Enter URL every bit "http://beust.com/eclipse/"
> Click "OK"
> Select "TestNG"
> Next > Next > induce got the agreement> Finish
------------------------------------------------
Write outset TestNG Test Case.

Manual Test case:

Test Case Name: Verify Page Title (Google)

Test Steps:
i) Launch the Browser
ii) Navigate to Google Homepage (www.google.com)

Verification Point:
Capture the Page Title as well as Compare with expected.

Expected: Google

Status:
-----------------------------------------------------
TestNG Test Case
Note:
i) principal method is non used inward TestNG Programs.
ii) TestNG programme contains solely Methods that incorporate @Test (Annotation)
iii) If nosotros don't write @Test Annotation as well as then the method is non going to hold out executed.
---------------------------------------------------------------
TestNG program/TestNG

public shape Amitha {
@Test
public void verifyTitle(){
WebDriver driver = novel FirefoxDriver();
driver.get("https://www.google.com");
Assert.assertEquals("Google", driver.getTitle());
driver.close();
}
}
-------------------------------------------------------------
3) Create multiple Test cases as well as Run.

Create multiple Test Cases inward a programme / Class as well as Run

Notes:

Test Cases every bit per Program:
i) launchBrowser()
ii) verifyTitle()
iii) closeBrowser()
--------------------------------
Note: TestNG Test Cases are executed inward Alphabetical order.

Test Cases every bit per Alphabetical gild inward this TestNG Program
i) closeBrowser()
ii) lanuchBrowser()
iii) verifyTitle()
-------------------------------
Example:
public shape TestCase2 {
public static WebDriver driver;
@Test
public void launchBrowser(){
driver = novel FirefoxDriver();
}
@Test
public void verifyTitle(){
driver.get("https://www.google.com");
String pageTitle = driver.getTitle();
Assert.assertEquals("Google", pageTitle);
}
@Test
public void closeBrowser(){
driver.close();
}
}
------------------------------------------------------------
Use priority Attribute to command the Test Execution, 
If nosotros usage priority Attribute, as well as then programme volition Run every bit priority (Small Number to Big Number)

public shape TestCase2 {
public static WebDriver driver;
@Test (priority = 1)
public void launchBrowser(){
driver = novel FirefoxDriver();
}
@Test (priority = 2)
public void verifyTitle(){
driver.get("https://www.google.com");
String pageTitle = driver.getTitle();
Assert.assertEquals("Google", pageTitle);
}
@Test (priority = 3)
public void closeBrowser(){
driver.close();
}
}
----------------------------------------------------------
We tin give whatever expose for priority, but it volition execute from Small Number to Big Number.
public shape TestCase2 {
public static WebDriver driver;
@Test (priority = -4)
public void launchBrowser(){
driver = novel FirefoxDriver();
}
@Test (priority = 2)
public void verifyTitle(){
driver.get("https://www.google.com");
String pageTitle = driver.getTitle();
Assert.assertEquals("Google", pageTitle);
}
@Test (priority = 13)
public void closeBrowser(){
driver.close();
}
}
----------------------------------------------------------
Prioritize Test Cases:

Using priority Attribute nosotros tin command the Test Execution
Or
Using DependsOnMethods Attribute nosotros tin command the Test Execution

Syntax:

@Test (priority = number)
@Test (DependsOnmethods = "BeforeMethod")

Using priority Attribute:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.Test;

public shape TestCase2 {
public static WebDriver driver;
@Test (priority = 1)
public void launchBrowser(){
driver = novel FirefoxDriver();
}
@Test (priority = 2)
public void verifygoogleTitle(){
driver.get("https://www.google.com");
String pageTitle = driver.getTitle();
Assert.assertEquals("Googlea", pageTitle);
}
@Test (priority = 3)
public void verifyyahooTitle(){
driver.get("https://in.yahoo.com/");
String pageTitle = driver.getTitle();
Assert.assertEquals("Yahoo", pageTitle);
}
@Test (priority = 4)
public void closeBrowser(){
driver.close();
}
}
---------------------------------------------
Using DependsonMethods Attribute:

public shape TestCase2 {
public static WebDriver driver;
@Test 
public void launchBrowser(){
driver = novel FirefoxDriver();
}
@Test (dependsOnMethods = "launchBrowser")
public void verifygoogleTitle(){
driver.get("https://www.google.com");
String pageTitle = driver.getTitle();
Assert.assertEquals("Google", pageTitle);
}
@Test (dependsOnMethods = "verifygoogleTitle")
public void verifyyahooTitle(){
driver.get("https://in.yahoo.com/");
String pageTitle = driver.getTitle();
Assert.assertEquals("Yahoo", pageTitle);
}

@Test (dependsOnMethods = "verifyyahooTitle")
public void closeBrowser(){
driver.close();
}
}
-------------------------------------------------------
public shape TestCase2 {
public static WebDriver driver;
@Test 
public void launchBrowser(){
driver = novel FirefoxDriver();
}
@Test (dependsOnMethods = "verifyyahooTitle")
public void verifygoogleTitle(){
driver.get("https://www.google.com");
String pageTitle = driver.getTitle();
Assert.assertEquals("Google", pageTitle);
}
@Test (dependsOnMethods = "launchBrowser")
public void verifyyahooTitle(){
driver.get("https://in.yahoo.com/");
String pageTitle = driver.getTitle();
Assert.assertEquals("Yahoo", pageTitle);
}

@Test (dependsOnMethods = "verifygoogleTitle")
public void closeBrowser(){
driver.close();
}
}
-----------------------------------------------------
public shape TestCase2 {
public static WebDriver driver;
@Test 
public void launchBrowser(){
driver = novel FirefoxDriver();
}
@Test (dependsOnMethods = "verifyyahooTitle")
public void verifygoogleTitle(){
driver.get("https://www.google.com");
String pageTitle = driver.getTitle();
Assert.assertEquals("Google", pageTitle);
}
@Test (dependsOnMethods = "launchBrowser")
public void verifyyahooTitle(){
driver.get("https://in.yahoo.com/");
String pageTitle = driver.getTitle();
Assert.assertEquals("Yahooa", pageTitle);
}

@Test (dependsOnMethods = "verifygoogleTitle")
public void closeBrowser(){
driver.close();
}
}
-------------------------------------------------------------------
Note:

If nosotros usage "priority" attribute as well as then all Test Classes tin hold out executed.

If nosotros usage "DependsOnMethods" attribute, as well as then it volition skip the exam example execution whenever DependsOnMethods Test case
fails, if you lot desire to execute the exam example forcibly as well as then us "alwaysRun attribute.


Scenario 1: If No functionality dependency with Test Cases inward a TestNG programme  - Use "priority" Attribute.
Scenario 2: If functionality dependency with Test Cases inward a TestNG programme - Use "DependsOnMethods" Attribute
Scenario 3: Functionality Dependency for Some Test Cases solely inward a TestNG programme "DependsOnMethods" as well as "alwaysRun" Attributes.
---------------------------------------------------
public shape TestCase2 {
public static WebDriver driver;
@Test 
public void launchBrowser(){
driver = novel FirefoxDriver();
}
@Test (dependsOnMethods = "verifyyahooTitle", alwaysRun = true)
public void verifygoogleTitle(){
driver.get("https://www.google.com");
String pageTitle = driver.getTitle();
Assert.assertEquals("Googlea", pageTitle);
}
@Test (dependsOnMethods = "launchBrowser")
public void verifyyahooTitle(){
driver.get("https://in.yahoo.com/");
String pageTitle = driver.getTitle();
Assert.assertEquals("Yahooa", pageTitle);
}
@Test (dependsOnMethods = "verifygoogleTitle", alwaysRun=true)
public void closeBrowser(){
driver.close();
}
}
-------------------------------------------------------
Sample TestNG Program:

Test Execution Flow:

i) launchBrowser
ii) verifygoogleTitle
iii) verifyyahooTitle
iv) closeBrowser
------------------------------------------------
TestNG Annotations:

@Test: The annotated method is constituent of a Test case

@BeforeMethod: The annotated method volition hold out run earlier each Test method
@AfterMethod: The annotated method volition hold out run subsequently each Test Method

@BeforeClass: The annotated method volition hold out run the outset Test method inward the electrical current shape is invoked.
@AfterClass: The annotated method volition hold out run subsequently all the Test Methods inward the electrical current shape induce got been run.

@BeforeTest: The annotated method volition hold out run earlier whatever Test Method beloging to classes within the tage is run
@AfterTest: The annotated method volition hold out run subsequently all the Test Methods beloging to classes within the tag.
--------------------------------------------------------------------------------
TestNG Program with "priority"

public shape TestCase2 {
public static WebDriver driver;
@Test (priority =1)
public void launchBrowser(){
driver = novel FirefoxDriver();
}
@Test (priority =2)
public void verifygoogleTitle(){
driver.get("https://www.google.com");
String pageTitle = driver.getTitle();
Assert.assertEquals("Google", pageTitle);
}
@Test (priority =3)
public void verifyyahooTitle(){
driver.get("https://in.yahoo.com/");
String pageTitle = driver.getTitle();
Assert.assertEquals("Yahoo", pageTitle);
}
@Test (priority =4)
public void verifybankofindiaTitle(){
driver.get("http://www.bankofindia.co.in/english/home.aspx");
String pageTitle = driver.getTitle();
Assert.assertEquals("Bank Of Bharat - Home", pageTitle);
}
@Test (priority =5)
public void closeBrowser(){
driver.close();
}
}
--------------------------------------------------------
Test Execution Flow:

launchBrowser
verifygoogleTitle
verifyyahooTitle
verifybankofindiaTitle
closeBrowser
------------------------------------------------------------------------
TestNG Program with BeforeMethod as well as AfterMethod Annotations as well as priority

public shape TestCase2 {
public static WebDriver driver;
@BeforeMethod
public void launchBrowser(){
driver = novel FirefoxDriver();
}
@Test (priority =1)
public void verifygoogleTitle(){
driver.get("https://www.google.com");
String pageTitle = driver.getTitle();
Assert.assertEquals("Google", pageTitle);
}
@Test (priority =2)
public void verifyyahooTitle(){
driver.get("https://in.yahoo.com/");
String pageTitle = driver.getTitle();
Assert.assertEquals("Yahoo", pageTitle);
}
@Test (priority =3)
public void verifybankofindiaTitle(){
driver.get("http://www.bankofindia.co.in/english/home.aspx");
String pageTitle = driver.getTitle();
Assert.assertEquals("Bank Of Bharat - Home", pageTitle);
}
@AfterMethod
public void closeBrowser(){
driver.close();
}
}
---------------------------------------------------------------
Text Execution Flow:

launchBrowser
verifygoogleTitle
closeBrowser

launchBrowser
verifyyahooTitle
closeBrowser

launchBrowser
verifybankofindiaTitle
closeBrowser
--------------------------------------
TestNG Program with BeforeClass as well as AfterClass Annotations as well as priority

Text Execution Flow:

launchBrowser
verifygoogleTitle
verifyyahooTitle
verifybankofindiaTitle
closeBrowser
--------------------------------------
public shape TestCase2 {
public static WebDriver driver;
@BeforeClass
public void launchBrowser(){
driver = novel FirefoxDriver();
}
@Test (priority =1)
public void verifygoogleTitle(){
driver.get("https://www.google.com");
String pageTitle = driver.getTitle();
if (pageTitle.equals("Google")){
System.out.println("passed");
}
}
@Test (priority =2)
public void verifyyahooTitle(){
driver.get("https://in.yahoo.com/");
String pageTitle = driver.getTitle();
if (pageTitle.equals("Yahoo")){
System.out.println("passed");
}
}
@Test (priority =3)
public void verifybankofindiaTitle(){
driver.get("http://www.bankofindia.co.in/english/home.aspx");
String pageTitle = driver.getTitle();
if (pageTitle.equals("Bank Of Bharat - Home")){
System.out.println("passed");
}
}
@AfterClass
public void closeBrowser(){
driver.close();
}
}
------------------------------------------------------------
4) Executing multiple Programs / Classes using XML

XML for executing multiple Programs / Classes,

<suite refer = "Suite Name">
<test refer = "Test Name">
<classes>
<class refer = "package.Class1Name"/>
<class refer = "package.Class2Name"/>
</classes>
--------------------------------------------------
Navigation to practise XML file inward Eclipse / TestNG,
In Eclipse IDE,
Select Java projection / parcel > Right Click > New > Others...
> Enter "TestNG" > Select "TestNG Class"
> Enter root as well as parcel names
> Enter XML File refer > Finish
-------------------------------------------------
Test Execution Flow:

login
addVendor
addProduct
addCurrency
logout
login
deleteVendor
deleteProduct
deleteCurrency
logout

Class 1:
@BeforeClass
public void login(){
System.out.println("Login Successful");
}
@AfterClass
public void logout(){
System.out.println("Logout Successful");

@Test (priority =1)
public void addVendor(){
System.out.println("Add Vendor Successful");
}
@Test (priority =2)
public void addProduct(){
System.out.println("Add Product Successful");
}
@Test (priority =3)
public void addCurrency(){
System.out.println("Add Currency Successful");
}
}
--------------------------------------------
Class2:
public shape Class2 {
@BeforeClass
public void login(){
System.out.println("Login Successful");
}
@AfterClass
public void logout(){
System.out.println("Logout Successful");

@Test (priority =1)
public void deleteVendor(){
System.out.println("Delete Vendor Successful");
}
@Test (priority =2)
public void deleteProduct(){
System.out.println("Delete Product Successful");
}
@Test (priority =3)
public void deleteCurrency(){
System.out.println("delete Currency Successful");
}
}
---------------------------------------------
Test execution Flow:

login
addVendor
addProduct
addCurrency
deleteVendor
deleteProduct
deleteCurrency
logout
---------------------------------------------
Class1: 

public shape Class1 {
@BeforeTest
public void login(){
System.out.println("Login Successful");
}
@AfterTest
public void logout(){
System.out.println("Logout Successful");

@Test (priority =1)
public void addVendor(){
System.out.println("Add Vendor Successful");
}
@Test (priority =2)
public void addProduct(){
System.out.println("Add Product Successful");
}
@Test (priority =3)
public void addCurrency(){
System.out.println("Add Currency Successful");
}
}
---------------------------------------------------
public shape Class2 {
@Test (priority =1)
public void deleteVendor(){
System.out.println("Delete Vendor Successful");
}
@Test (priority =2)
public void deleteProduct(){
System.out.println("Delete Product Successful");
}
@Test (priority =3)
public void deleteCurrency(){
System.out.println("delete Currency Successful");
}
}
---------------------------------------------------------------
5) Grouping Test Cases

Test Execution Levels inward Manual Testing,
Smoke Testing / BVT / BAT...
Comprehensive Testing
Sanity Testing / BVT /BAT...
General Regression Testing Cycle1, 2, 3...
Final Regression Testing
--------------------------------------
XML File for grouping Classes,

<suite refer ="Suite Name">
< exam refer = "Test Name">
<groups>
<run>
<include refer = "group name"/>
</run>

<classes>
<class refer = "package.ClassName"/> 
<classes/> 
</groups>
---------------------------------------------------------------
Tags inward 1st File

suite,
test,
classes,
class

Tags inward sec File

suite,
test,
groups,
run,
include,
classes,
class
--------------------------------------------------------------------------
Class File:

@Test (groups = {"sanity", "regression"}, priority =1)
public void login(){
System.out.println("Login Successful");
}
@Test (groups = {"sanity", "regression"}, priority =6)
public void logout(){
System.out.println("Logout Successful");
}
@Test (groups = {"sanity"}, priority = 2)
public void search(){
System.out.println("Search is Successful");
}
@Test (groups = {"regression"}, priority = 3)
public void advancedSearch(){
System.out.println("Advanced Search is Successful");
}
@Test (groups = {"regression"}, priority = 4)
public void billPayment(){
System.out.println("BillPayment is Successful");
}
@Test (groups = {"sanity", "regression"}, priority =5 )
public void prepaidRecharge(){
System.out.println("Prepaid Recharge is Successful");
}
}
-----------------------------------------------------------------
XML File:
<suite name="Suite" >
  <test name="Test">
  <groups>
  <run>
  <include refer = "sanity"/>
  </run>
  </groups>
    <classes>
      <class name="abcd.Class3"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->
------------------------------------------------------
In this Grouping XML,

1) Sanity Group,

login
search
prepaidRecharge
logout

2) Regression Group,

login
advancedSearch
prepaidRecharge
billPayment
logout
---------------------------------------------------------------
6) Parallel Test Execution

Parallel Testing using Selenium Grid

we usage multiple (2 or 3) computers to execute Tests,

Parallel Testing using TestNG Testing Framework,

we usage unmarried Computer to execute Tests,
--------------------------
Thread - Influenza A virus subtype H5N1 Theard is a cuncurrent unit of measurement of execution,

1) Parallel Test execution (Methods)
XML file for parallel Testing

<suite refer = "SuiteName" parallel = "methods" thread-count="2">
<test refer = "TestName">
<classes>
<class refer = "package.ClassName"/>
<classes/>
</test>
</suite>
-------------------------------------------------------------
XML File:

<suite name="Suite" parallel="methods" thread-count="2">
  <test name="Test">
    <classes>
      <class name="abcd.Class1"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->
--------------------------------------------
Class File:

public shape Class1 {
@Test
public void testCase1(){
long id = Thread.currentThread().getId();
System.out.println("Test Case i Successful "+ "Thread Count is " + id);
}
@Test
public void testCase2(){
long id = Thread.currentThread().getId();
System.out.println("Test Case 2 Successful "+ "Thread Count is " + id);
}
@Test
public void testCase3(){
long id = Thread.currentThread().getId();
System.out.println("Test Case three Successful "+ "Thread Count is " + id);
}
@Test
public void testCase4(){
long id = Thread.currentThread().getId();
System.out.println("Test Case four Successful "+ "Thread Count is " + id);
}
}
-------------------------------------------------------------------
2) Parallel Test execution (Classes)
<suite name="Suite" parallel="classes" thread-count="2">
  <test name="Test">
    <classes>
      <class name="abcd.Class1"/>
      <class name="abcd.Class2"/>
      <class name="abcd.Class3"/>
      <class name="abcd.Class4"/>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->
-------------------------------------

import org.testng.annotations.Test;

public shape Class1 {
@Test
public void testCase1(){
long id = Thread.currentThread().getId();
System.out.println("Test Case i Successful "+ "Thread Count is " + id);
}
@Test
public void testCase2(){
long id = Thread.currentThread().getId();
System.out.println("Test Case 2 Successful "+ "Thread Count is " + id);
}
@Test
public void testCase3(){
long id = Thread.currentThread().getId();
System.out.println("Test Case three Successful "+ "Thread Count is " + id);
}
@Test
public void testCase4(){
long id = Thread.currentThread().getId();
System.out.println("Test Case four Successful "+ "Thread Count is " + id);
}
}
-------------------------------------------
import org.testng.annotations.Test;

public shape Class2 {
@Test
public void testCase5(){
long id = Thread.currentThread().getId();
System.out.println("Test Case five Successful "+ "Thread Count is " + id);
}
@Test
public void testCase6(){
long id = Thread.currentThread().getId();
System.out.println("Test Case vi Successful "+ "Thread Count is " + id);
}
@Test
public void testCase7(){
long id = Thread.currentThread().getId();
System.out.println("Test Case seven Successful "+ "Thread Count is " + id);
}
@Test
public void testCase8(){
long id = Thread.currentThread().getId();
System.out.println("Test Case 8 Successful "+ "Thread Count is " + id);
}
}
-------------------------------------------------------------
Parallel Testing methods option,

Class
method1
method2
method3
method4
Thread-count -2/4

Parallel Testing classes option,

Class1
method1
method2
method3
method4

Class2
method1
method2
method3
method4

Thread-count -2/4
--------------------------------------------------
7) Data Driven Testing using DataProvider 

i) Read Test Data (String Type) from Excel file as well as perform Data driven testing for Admin Login Functionality.
ii) Read Test Data (Integer Type) from Excel file as well as comport Data driven Testing for Addition functionality
------------------------------------------------------------------
i) Read Test Data (String Type) from Excel file as well as perform Data driven testing for Admin Login Functionality.

Manual Test Case:

Test Steps:
i) Launch the browser
ii) Navigate to gcrShop Admin Interface (http://gcrit.com/build3/admin/)
iii) Enter "Username"
iv) Enter "Password"
v) Click "Login" Button

Verification point:
Capture the URL, as well as compare with Expected (Compare for multiple sets of Test Data)

Test Data:
Username: admin
Password: admin@123

Expected: http://www.gcrit.com/build3/admin/index.php
-----------------------------------------------
Prepare Test Data File:

> Download Excel jounce as well as extract
> Add Excel jounce to Java projection inward Eclipse IDE
-----------------------------------------------
TestNG Program:

public shape DataDriven {
public WebDriver driver;
@Test (dataProvider = "testData")
public void adminLogin (String uname, String pwd){
driver = novel FirefoxDriver();
driver.get("http://gcrit.com/build3/admin/");
driver.findElement(By.name("username")).sendKeys(uname);
driver.findElement(By.name("password")).sendKeys(pwd);
driver.findElement(By.id("tdb1")).click();
String s = driver.getCurrentUrl();
System.out.println(s);
if (s.contains("http://www.gcrit.com/build3/admin/index.php")){
System.out.println("Login Successful");
}
else
{
System.out.println("Login Unuccessful");
}
}
@AfterMethod
public void closeBrowser(){
driver.close();
}
@DataProvider (name = "testData")
public Object [] [] readExcel() throws BiffException, IOException{
File f = novel File ("C:/Users/gcreddy/Desktop/Input.xls");
Workbook w = Workbook.getWorkbook(f);
Sheet s = w.getSheet("Sheet1");
int columns = s.getColumns();
int rows = s.getRows();
//System.out.println(columns +", " + rows);

String inputData [] [] = novel String [rows] [columns];

for (int i=0; i < rows; i++){
for (int j = 0; j < columns; j++){
  Cell c = s.getCell(j, i);
   inputData [i] [j] = c.getContents();
   //System.out.println(inputData[i][j]);
}
}
return inputData;

}
}
-----------------------------------------------
ii) Read Test Data (Integer Type) from Excel file as well as comport Data driven Testing for Addition functionality

public shape Addition {
@Test (dataProvider = "ahalya")
public void improver (String num1, String num2, String num3){
int a = Integer.parseInt(num1);
int b = Integer.parseInt(num2);
int c = Integer.parseInt(num3);
int consequence = a + b + c;
System.out.println(result);
}
@DataProvider(name = "ahalya")
public Object [] [] readExcel() throws BiffException, IOException {
File f = novel File ("C:/Users/gcreddy/Desktop/Input.xls");
Workbook w = Workbook.getWorkbook(f);
Sheet s = w.getSheet(0);

int rows = s.getRows();
int columns = s.getColumns();

String inputData [] [] = novel String [rows] [columns];

for (int i = 0; i < rows; i++){
for (int j = 0; j < columns; j++){
Cell c = s.getCell(j, i);
inputData [i] [j] = c.getContents();
}
}
return inputData;
}
}
-----------------------------------------------
Note 1: Irrespective of fields size (number of fields) nosotros tin usage 2D Array (we are treatment Excel File, excel has 2D Data only)
Note 2: Irrespective of rows as well as columns size (number of Rows as well as Columns) nosotros tin usage nested loop as well as logic...
-----------------------------------------------
 Install TestNG as well as write outset TestNG Test Case TestNG Framework for Selenium

Sumber http://www.gcreddy.com/

No comments:

Post a Comment