Skip to content

Instantly share code, notes, and snippets.

View sahajamit's full-sized avatar

Amit Rawat sahajamit

View GitHub Profile
@sahajamit
sahajamit / testng_retryanalyzer
Last active August 29, 2015 14:14
Sample code for testng retry analyzer to re-run the failed test cases using testng's IRetryAnalyzer listner
package com.testng.practise;
import org.testng.Assert;
import org.testng.IRetryAnalyzer;
import org.testng.ITestResult;
import org.testng.Reporter;
import org.testng.annotations.*;
public class RerunFailedTestCases implements IRetryAnalyzer{
private int retryCount = 0;
private int maxRetryCount = 1;
@sahajamit
sahajamit / TestNGAnnotationTransformer
Last active August 29, 2015 14:14
Testng annotation transformer to apply @test annotation at runtime . Here we are setting the timeout using it.
package com.testng.practise;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import org.testng.IAnnotationTransformer;
import org.testng.ITest;
import org.testng.annotations.ITestAnnotation;
import org.testng.annotations.Test;
import org.testng.IAnnotationTransformer;
@sahajamit
sahajamit / testngxml_with_listener
Last active August 29, 2015 14:14
Sample testng xml to pass the listener information to testng.
<?xml version="1.0"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Phoenix.Equinox.Com Verification" verbose="1">
<listeners>
<listener class-name="com.testng.practise.SeleniumStarterListener"></listener>
</listeners>
<test name="Retry Test">
<classes>
<class name="com.testng.practise.Annotationtransformerexample"></class>
import org.testng.ISuite;
import org.testng.ISuiteListener;
public class SeleniumStarterListener implements ISuiteListener {
public void onStart(ISuite suite) {
}
public void onFinish(ISuite suite) {
}
package com.android.NativeBrowserAutomation;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileBrowserType;
import io.appium.java_client.remote.MobileCapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.MalformedURLException;
import java.net.URL;
/**
import org.testng.ISuite;
import org.testng.ISuiteListener;
import org.testng.IExecutionListener;
public class TestNGExecutionListener implements IExecutionListener {
@Override
public void onExecutionStart() {
System.out.println("TestNG is staring the execution");
}
@Override
/**
* TestRail API binding for Java (API v2, available since TestRail 3.0)
*
* Learn more:
*
* http://docs.gurock.com/testrail-api2/start
* http://docs.gurock.com/testrail-api2/accessing
*
* Copyright Gurock Software GmbH. See license.md for details.
*/
android list targets
android create avd -n <name> -t <targetID> [-<option> <value>] ...
android delete avd -n <name>
To Launch the avd
emulator -avd <name> - to launch the avd
android avd - to launch the avd manager
To know the package name and main activity of an apk:
cd /Users/amit.rawat/Library/Android/sdk/build-tools/21.1.2
./aapt dump badging <Path of apk>
Look for text "package" in the output
Look for text "launchable-activity:
package: name='io.appium.android.apis' versionCode='' versionName='' platformBuildVersionName=''
launchable-activity: name='io.appium.android.apis.ApiDemos' label='' icon=''
@sahajamit
sahajamit / CaptureBrowserScreenShot.java
Created October 8, 2015 14:28
This code will help you to take the screenshot of the complete scrollable page.
package com.mobile.equinox.util;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.imageio.ImageIO;