My blog gives important brief for Interviews related to SAP Security, SAP Migration ,AWS and Automation.
Friday, 20 September 2013
Friday, 13 September 2013
Burhanpur Train Guide [Android Application]
Hi Burhanpur,
Below is the link to download the app. Just download it and install in your Android SmartPhones.
http://www.swoopshare.com/file/0d79f9309e97f95fc856bcbdedee35d2/MyTown.apk.html
Wednesday, 21 August 2013
5 different ways to refresh a webpage using Selenium Webdriver
1.Using sendKeys.Keys method
2.Using navigate.refresh() method
3.Using navigate.to() method
4.Using get() method
5.Using sendKeys() method
- driver.get("https://accounts.google.com/SignUp");
- driver.findElement(By.id("firstname-placeholder")).sendKeys(Keys.F5);
- driver.get("https://accounts.google.com/SignUp");
- driver.navigate().refresh();
- driver.get("https://accounts.google.com/SignUp");
- driver.navigate().to(driver.getCurrentUrl());
- driver.get("https://accounts.google.com/SignUp");
- driver.get(driver.getCurrentUrl());
- driver.get("https://accounts.google.com/SignUp");
- driver.findElement(By.id("firstname-placeholder")).sendKeys("\uE035");
Wednesday, 29 May 2013
create multiple sheets in excel via java code
package com.ReadAndWriteExcel;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Vector;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.XLSX.ExcelXLSX;
public class Main {
static XSSFWorkbook xssfWorkbook;
static XSSFSheet xssfSheet;
public static void main(String[] args) throws IOException {
int numOfSheet=3;
Vector vectorDataExcelXLSX = new Vector();
Vector<Vector> ParentVector = new Vector<Vector>();
String excelXLSXFileName = "C:\\task\\masterxls\\Config.xlsx";
Workbook wb = new XSSFWorkbook();
FileOutputStream fos = new FileOutputStream("Master.xlsx", true);
File file = new File("C:\\task\\modules");
String[] str = file.list();
String[] SheetNames ={"Test Cases","Test Steps","Test Data"};
for (int var = 0; var < numOfSheet; var++)
{
for (String st : str)
{
vectorDataExcelXLSX = ExcelXLSX.readDataExcelXLSX("C:\\task\\modules\\" + st, var);
ParentVector.add(vectorDataExcelXLSX);
ExcelXLSX.PrintInConsoleDataExcelXLSX(vectorDataExcelXLSX);
}
ExcelXLSX.writeExcelFile(ParentVector, wb, SheetNames[var]);
ParentVector.clear();
}
System.out.println("Excel file has been generated!");
wb.write(fos);
fos.close();
}
}
Read And write Excel:------>
public static Vector readDataExcelXLSX(String fileName,int SheetNumber) {
Vector vectorData = new Vector();
try {
FileInputStream fileInputStream = new FileInputStream(fileName);
XSSFWorkbook xssfWorkBook = new XSSFWorkbook(fileInputStream);
// Read data at sheet 0
XSSFSheet xssfSheet = xssfWorkBook.getSheetAt(SheetNumber);
Iterator rowIteration = xssfSheet.rowIterator();
// Looping every row at sheet 0
while (rowIteration.hasNext()) {
XSSFRow xssfRow = (XSSFRow) rowIteration.next();
Iterator cellIteration = xssfRow.cellIterator();
Vector vectorCellEachRowData = new Vector();
// Looping every cell in each row at sheet 0
while (cellIteration.hasNext())
{
XSSFCell xssfCell = (XSSFCell) cellIteration.next();
vectorCellEachRowData.addElement(xssfCell);
}
vectorData.addElement(vectorCellEachRowData);
}
} catch (Exception ex) {
ex.printStackTrace();
}
return vectorData;
}
public static void writeExcelFile(Vector<Vector> vectorData, Workbook wb,String sheetName) throws IOException {
Row row;
Cell cell;
String[] cellvalue = null;
int t=0;
Sheet sh=wb.createSheet(sheetName);
for (int i = 0; i < vectorData.size(); i++) {
Vector vectorCellEachRowData = (Vector) vectorData.get(i);
for (int j = 0; j < vectorCellEachRowData.size(); j++) {
String str1=vectorCellEachRowData.get(j).toString().replace("[","");
cellvalue =str1.split(",");
row = sh.createRow((short) t);
t++;
for (int k = 0; k < cellvalue.length; k++) {
cell = row.createCell((short) k);
cell.setCellValue(cellvalue[k].replace("]",""));
}
}
System.out.println();
}
}
IMP NOTE---->
Dont Forget to attach POI Jars for XSSf(5 Jars)
Thursday, 23 May 2013
ant build for testng
Ant build file for TestNG:->
Sample Ant build.xml file to run TestNG
<?xml version="1.0" encoding="UTF-8"?>
<!--
Filename: build.xml
Note: You have to change the followings according to your environment:
-<pathelement location="lib/testng/testng-5.14.7.jar"/>
-<pathelement location="bin"/>
-->
<project basedir="." default="testng_nice_report" name="Sample of Ant file for TestNG">
<!-- Define <testng> task -->
<taskdef name="testng" classname="org.testng.TestNGAntTask">
<classpath>
<pathelement location="C:/Selenuim_Automation/Jars and Properties File/jars/testng.jar" />
</classpath>
</taskdef>
<!-- Directory name where the TestNG report will be saved. -->
<property name="testng.output.dir" value="testng_output" />
<!-- Directory path of compiled classes(i.e *.class) -->
<path id="classes">
<pathelement location="C:/Selenuim_Automation/MyAnt/bin" />
<pathelement location="C:/Selenuim_Automation/Jars and Properties File/jars/selenium-server-standalone-2.32.0.jar"/>
<pathelement location="C:/Selenuim_Automation/Jars and Properties File/jars/log4j-1.2.14.jar"/>
</path>
<!--
Target to run TestNG. It will run according to what are defined in testng.xml.
The report will be saved at .../testng_output/index.html.
-->
<target name="runTestNG">
<mkdir dir="${testng.output.dir}" />
<!-- Create the output directory. -->
<testng outputdir="${testng.output.dir}" classpathref="classes">
<xmlfileset dir="." includes="testng.xml" />
</testng>
</target>
<!--
Example for TestNG-XSLT
Run this target only after TestNG had generated the xml resutl file(i.e. testng_output/testng-results.xml).
Change TestNG-XSLT stylesheet path accordingly(i.e. lib/testng-xslt-0.6.2/src/main/resources/testng-results.xsl).
-->
<target name="testng_nice_report" depends="runTestNG" >
<mkdir dir="testng_nice_report" />
<xslt in="testng_output/testng-results.xml" style="C:/Selenuim_Automation/MyAnt/src/com/xsl/testng-results.xsl" out="testng_nice_report/index.html">
<param name="testNgXslt.outputDir" expression="C:/Selenuim_Automation/MyAnt/testng_nice_report" />
<param name="testNgXslt.showRuntimeTotals" expression="true" />
</xslt>
</target>
</project>
Ant testng.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Filename: testng.xml
Note: You have to change the following according to your environment:
-<class name="com.packageName.MyTestClassName" />
-->
<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
<suite name="My Test Suite" >
<test name="My Test1" >
<!-- Add all classes you would like TestNG to run. -->
<classes>
<class name="com.LoginViaTestNG.LoginTestt" />
</classes>
</test>
</suite>
Monday, 20 May 2013
tower of hanoi android code
<<----------------------"TOWER OF HANOI"---------------------->>
Android Source code:--->Emulator with GPU enables ,Target=above 4.0.1 only
1) Download AndEngine from:---->
https://github.com/nicolasgramlich/AndEngine
2) TowerOfHanoiActivity.java:------->
import java.io.IOException;
import java.io.InputStream;
import java.util.Stack;
import org.andengine.engine.camera.Camera;
import org.andengine.engine.options.EngineOptions;
import org.andengine.engine.options.ScreenOrientation;
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.sprite.Sprite;
import org.andengine.input.touch.TouchEvent;
import org.andengine.opengl.texture.ITexture;
import org.andengine.opengl.texture.bitmap.BitmapTexture;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.texture.region.TextureRegionFactory;
import org.andengine.ui.activity.SimpleBaseGameActivity;
import org.andengine.util.adt.io.in.IInputStreamOpener;
import org.andengine.util.debug.Debug;
import com.tutorial.towerofhanoi.gameelements.Ring;
public class TowerOfHanoiActivity extends SimpleBaseGameActivity {
private static int CAMERA_WIDTH = 800;
private static int CAMERA_HEIGHT = 480;
private ITextureRegion mBackgroundTextureRegion, mTowerTextureRegion, mRing1, mRing2, mRing3;
private Stack<Ring> mStack1, mStack2, mStack3;
private Sprite mTower1, mTower2, mTower3;
public EngineOptions onCreateEngineOptions() {
final Camera camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
return new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), camera);
}
@Override
protected void onCreateResources() {
try {
ITexture backgroundTexture = new BitmapTexture(this.getTextureManager(), new IInputStreamOpener() {
@Override
public InputStream open() throws IOException {
return getAssets().open("gfx/background.png");
}
});
ITexture towerTexture = new BitmapTexture(this.getTextureManager(), new IInputStreamOpener() {
@Override
public InputStream open() throws IOException {
return getAssets().open("gfx/tower.png");
}
});
ITexture ring1 = new BitmapTexture(this.getTextureManager(), new IInputStreamOpener() {
@Override
public InputStream open() throws IOException {
return getAssets().open("gfx/ring1.png");
}
});
ITexture ring2 = new BitmapTexture(this.getTextureManager(), new IInputStreamOpener() {
@Override
public InputStream open() throws IOException {
return getAssets().open("gfx/ring2.png");
}
});
ITexture ring3 = new BitmapTexture(this.getTextureManager(), new IInputStreamOpener() {
@Override
public InputStream open() throws IOException {
return getAssets().open("gfx/ring3.png");
}
});
backgroundTexture.load();
towerTexture.load();
ring1.load();
ring2.load();
ring3.load();
this.mBackgroundTextureRegion = TextureRegionFactory.extractFromTexture(backgroundTexture);
this.mTowerTextureRegion = TextureRegionFactory.extractFromTexture(towerTexture);
this.mRing1 = TextureRegionFactory.extractFromTexture(ring1);
this.mRing2 = TextureRegionFactory.extractFromTexture(ring2);
this.mRing3 = TextureRegionFactory.extractFromTexture(ring3);
this.mStack1 = new Stack<Ring>();
this.mStack2 = new Stack<Ring>();
this.mStack3 = new Stack<Ring>();
} catch (IOException e) {
Debug.e(e);
}
}
@Override
protected Scene onCreateScene() {
final Scene scene = new Scene();
Sprite backgroundSprite = new Sprite(0, 0, this.mBackgroundTextureRegion, getVertexBufferObjectManager());
mTower1 = new Sprite(0.241f * CAMERA_WIDTH, 0.133f * CAMERA_HEIGHT, this.mTowerTextureRegion, getVertexBufferObjectManager());
mTower2 = new Sprite(0.5f * CAMERA_WIDTH, 0.133f * CAMERA_HEIGHT, this.mTowerTextureRegion, getVertexBufferObjectManager());
mTower3 = new Sprite(0.756f * CAMERA_WIDTH, 0.133f * CAMERA_HEIGHT, this.mTowerTextureRegion, getVertexBufferObjectManager());
Ring ring1 = new Ring(1, 139, 174, this.mRing1, getVertexBufferObjectManager()) {
@Override
public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
if(this.getmStack().peek().getmWeight() != this.getmWeight())
return false;
this.setPosition(pSceneTouchEvent.getX() - this.getWidth() / 2, pSceneTouchEvent.getY() - this.getHeight() / 2);
if(pSceneTouchEvent.getAction() == TouchEvent.ACTION_UP) {
checkForCollisionsWithTowers(this);
}
return true;
}
};
Ring ring2 = new Ring(2, 118, 212, this.mRing2, getVertexBufferObjectManager()) {
@Override
public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
if(this.getmStack().peek().getmWeight() != this.getmWeight())
return false;
this.setPosition(pSceneTouchEvent.getX() - this.getWidth() / 2, pSceneTouchEvent.getY() - this.getHeight() / 2);
if(pSceneTouchEvent.getAction() == TouchEvent.ACTION_UP) {
checkForCollisionsWithTowers(this);
}
return true;
}
};
Ring ring3 = new Ring(3, 97, 255, this.mRing3, getVertexBufferObjectManager()) {
@Override
public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {
if(this.getmStack().peek().getmWeight() != this.getmWeight())
return false;
this.setPosition(pSceneTouchEvent.getX() - this.getWidth() / 2, pSceneTouchEvent.getY() - this.getHeight() / 2);
if(pSceneTouchEvent.getAction() == TouchEvent.ACTION_UP) {
checkForCollisionsWithTowers(this);
}
return true;
}
};
this.mStack1.add(ring3);
this.mStack1.add(ring2);
this.mStack1.add(ring1);
ring1.setmStack(mStack1);
ring2.setmStack(mStack1);
ring3.setmStack(mStack1);
ring1.setmTower(mTower1);
ring2.setmTower(mTower1);
ring3.setmTower(mTower1);
scene.attachChild(backgroundSprite);
scene.attachChild(mTower1);
scene.attachChild(mTower2);
scene.attachChild(mTower3);
scene.attachChild(ring1);
scene.attachChild(ring2);
scene.attachChild(ring3);
scene.registerTouchArea(ring1);
scene.registerTouchArea(ring2);
scene.registerTouchArea(ring3);
scene.setTouchAreaBindingOnActionDownEnabled(true);
return scene;
}
private void checkForCollisionsWithTowers(Ring ring) {
Stack<Ring> stack = null;
Sprite tower = null;
if(ring.collidesWith(mTower1) && (mStack1.size() == 0 || ring.getmWeight() < mStack1.peek().getmWeight())) {
stack = mStack1;
tower = mTower1;
} else if(ring.collidesWith(mTower2) && (mStack2.size() == 0 || ring.getmWeight() < mStack2.peek().getmWeight())) {
stack = mStack2;
tower = mTower2;
} else if(ring.collidesWith(mTower3) && (mStack3.size() == 0 || ring.getmWeight() < mStack3.peek().getmWeight())) {
stack = mStack3;
tower = mTower3;
} else {
stack = ring.getmStack();
tower = ring.getmTower();
}
ring.getmStack().remove(ring);
if(stack != null && tower !=null && stack.size() == 0) {
ring.setPosition(tower.getX() + tower.getWidth()/2 - ring.getWidth()/2, tower.getY() + tower.getHeight() - ring.getHeight());
} else if(stack != null && tower !=null && stack.size() > 0) {
ring.setPosition(tower.getX() + tower.getWidth()/2 - ring.getWidth()/2, stack.peek().getY() - ring.getHeight());
}
stack.add(ring);
ring.setmStack(stack);
ring.setmTower(tower);
}
}
3) Ring.java:---->
import java.util.Stack;
import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;
public class Ring extends Sprite {
private int mWeight;
private Stack<Ring> mStack; //this represents the stack that this ring belongs to
private Sprite mTower;
public Ring(int weight, float pX, float pY, ITextureRegion pTextureRegion, VertexBufferObjectManager pVertexBufferObjectManager) {
super(pX, pY, pTextureRegion, pVertexBufferObjectManager);
this.mWeight = weight;
}
public int getmWeight() {
return mWeight;
}
public Stack<Ring> getmStack() {
return mStack;
}
public void setmStack(Stack<Ring> mStack) {
this.mStack = mStack;
}
public Sprite getmTower() {
return mTower;
}
public void setmTower(Sprite mTower) {
this.mTower = mTower;
}
}
Thursday, 16 May 2013
selenium webdriver example
Automation of Login Details:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class LoginTest {
public static void main(String[] args) {
//WebDriver driver=new FirefoxDriver();
System.setProperty("webdriver.chrome.driver", "C:\\Selenuim_Automation\\ChromeDriver\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
//Step 1- Opening Ellamoss site
driver.get("http://www.ellamos.com/");
//Step-2 Clicking on My account
driver.findElement(By.xpath("html/body/form/div[6]/div[1]/div/ul/li[1]/a")).click();
//Step-3 Entering Email address in the textbox
driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_email']")).sendKeys("abc@gmail.com");
//Step-4 Entering Password in the textbox
driver.findElement(By.xpath("//*[@id='ContentPlaceHolder1_password']")).sendKeys("pass_123");
//Step-5 Clicking on Signin button
driver.findElement(By.xpath("//*[@id='login']")).click();
//Verifications
//Getting the text from application
String actText=driver.findElement(By.xpath("html/body/form/div[6]/div[3]/table/tbody/tr[2]/td/span[1]/span")).getText();
//Expected text
String expText="abc@gmail.com";
//actText, exptext Comparison
if(actText.equals(expText)){
System.out.println("Strings are equal");
}else{
System.out.println("Strings are not equal");
}
driver.close();
}
}
Subscribe to:
Posts (Atom)




