Tuesday 14 June 2016

simple way to read data from excel

If you added jars of poi properly then below code is simpler way you can use to read excel



private static XSSFCell Cell;

    private static XSSFRow Row;
      public static final String Path = System.getProperty("user.dir")+"\\src\\testData\\TestData.xlsx";
      public static final String SheetName = "Sheet1";

FileInputStream ExcelFile = new FileInputStream(Path);

            // Access the required test data sheet

            ExcelWBook = new XSSFWorkbook(ExcelFile);

            ExcelWSheet = ExcelWBook.getSheet(SheetName);
            Cell = ExcelWSheet.getRow(RowNum).getCell(ColNum);
            System.out.println(Cell); //data from specific row

Sunday 12 June 2016

ANT setup for xslt report using testNg in selenium

for xslt reprt user should have ANT with machine 

so 1st ANT installation we will see,

Step 1- Navigate to below mention url
step 2- Extract zip file
Step 3- Once we extract the zip file then we need to set environment variable
Step 4- ANT_HOME should get added in path
Step 5- Now verify that Ant is installed properly- Open CMD 
ant -version
Note- if it is install properly then in output console we will get build.xml not found-build failed
Step 5- add below build.xml to your project, from below url




<project name="TestAutomation" basedir=".">
    <property name="LIB" value="${basedir}/lib" />
    <property name="BIN" value="${basedir}/bin" />
    <path id="master-classpath">
        <pathelement location="${BIN}" />
        <fileset dir="${LIB}" includes="*.jar"/>
    </path>
    
    <target name="Report">
        <delete dir="${basedir}/testng-xslt">
        </delete>
        <mkdir dir="${basedir}/testng-xslt">
        </mkdir>
        <xslt in="${basedir}/test-output/testng-results.xml" style="${basedir}/testng-results.xsl" out="${basedir}/testng-xslt/index.html">
            <param expression="${basedir}/testng-xslt/" name="testNgXslt.outputDir" />
            <param expression="true" name="testNgXslt.sortTestCaseLinks" />
            <param expression="FAIL,SKIP,PASS,CONF,BY_CLASS" name="testNgXslt.testDetailsFilter" />
            <param expression="true" name="testNgXslt.showRuntimeTotals" />
            <classpath refid="master-classpath">
            </classpath>
        </xslt>
    </target>

</project>











Step 6- now again check Ant version, successful message will come
Step 7-Add saxon 2 jars for your reports to your project
Step 8- as per your build.xml, run command from cmd after coming to your project directory, ant Report(from build.xml)
Step 9- this will create xslt reoprt folder under YOUR PROJECT
STEP 10-For reports check index.html
Step 7- after this run your code, and get xslt reports with pass fail diagrams, for this TestNg should have install with you in eclipse


Monday 6 June 2016

Maven setup for selenium



1)Set JAVA_HOME from environment variable(My computer -advanced setting)

2) add to path which added as JAVA_HOME till bin folder

3) Download ANT from Apache maven website, go for "bin" version for maven

4) unzip folder

5) set MAVEN_HOME and M2_HOME from advance setting

6) add to path which added as MAVEN_HOME till bin folder

7) go to cmd check mvn -version (verify maven install it proper or not)

8) If 7th step failed, then you are wrong with enviorment setting or java version

9) go to eclipse, add new software->http://download.eclipse.org/technology/m2e/releases as maven

10) go to project , right click and configure as maven

11) now go to project-pom.xml add dependancy as per your need, eg below dependancy for latest selenium jars

<dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.53.0</version>
    </dependency> 

So this is how you can add maven to your selenium project

Sunday 5 June 2016

iphone and android crash log

Getting Crash Logs Directly From a Device Without Xcode
Your users can retrieve crash reports from their device and send them to you via email by following these instructions.
(It is not possible to get device console logs directly from a device)
1) Open Settings app
2) Go to Privacy, then Diagnostics & Usage
3) Select Diagnostics & Usage Data
4) Locate the log for the crashed app. The logs will be named in the format:
5) Select the desired log. Then, using the text selection UI select the entire text of the log. Once the text is selected, tap Copy
6) Paste the copied text to Mail and send to an email address as desired Getting Crash Logs and Console Output From a Device Using Xcode
Even though you won't be able to run the app in Xcode's debugger, Xcode can still give you all the information you need to debug the problem. Using Xcode 6
1) Plug in the device and open Xcode
2) Choose Window -> Devices from the menu bar
3) Under the DEVICES section in the left column, choose the device
4) To see the device console, click the up-triangle at the bottom left of the right hand panel
5) Click the down arrow on the bottom right to save the console as a file
6) To see crash logs, select the View Device Logs button under the Device Information section on the right hand panel
7) Find your app in the Process column and select the Crash log to see the contents.
8) To save a crash log, right click the entry on the left column and choose "Export Log"
9) Xcode 6 will also list low memory logs here. These will be shown with a Process name "Unknown" and Type "Unknown". You should examine the contents of these logs to determine whether any of these are caused by your app. For more information about low memory logs, see Understanding and Analyzing iOS Application Crash Reports. Using Xcode 5
1) Plug in the device and open Xcode
2) Open the Organizer window and select the Devices tab
3) Under the DEVICES section in the left column, expand the listing for the device
4) Select Device Logs to see crash logs or select Console to see Console output Back to Top Enabling App Store Diagnostic Reporting
Crash logs are automatically collected from customers who have opted in to sending diagnostic and usage information to Apple.
Beginning with Xcode 6.3, crash logs from App Store customers running at least iOS 8.3 and TestFlight beta testers can be found in the Xcode Organizer. To obtain these crash logs:
1) Open the Organizer window in Xcode 6.3 and above
2) Select "Crashes" at the top. The available crash logs can then be found within this window.
The App Distribution Guide contains further information about the Crash Reporting service.
Crash reports from customers running older iOS versions may be found in iTunes Connect.
If someone is reporting a crash, and you do not see a corresponding report in iTunes Connect, you should direct them to the following knowledge base articles for Mac or for Windows so they can opt-in to sending you crash reports.

for android -user can use monitor file from sdk folder else using adb logcat he can check logs in command prompt

appium swipe by text and appium jars

swipe by text- scorllToExact is function 1 can use for swipe- driver.scrollToExact("text")


Appium jars-http://mvnrepository.com/artifact/io.appium/java-client/2.1.0

only 1 jar needed for appium named -java-client

Thursday 2 June 2016

compile error come when user import project in eclipse

for this situation , user should add libraries from properties, same like adding jars

network connection using appium-interruptive testing

The Selenium Mobile JSON Wire Protocol Specification supports an API for getting and setting the network connection for a device. The API works through a bitmask, assigning an integer to each possible state:
Value (Alias) Data Wifi Airplane Mode
0 (None) 0 0 0
1 (Airplane Mode) 0 0 1
2 (Wifi only) 0 1 0
4 (Data only) 1 0 0
6 (All network on) 1 1 0

iOS

Unfortunately, at the moment Appium does not support the Selenium network connection API for iOS.

Android

Choose the setting you would like to use, and then send the correct bitmask from the table above.
// javascript
// set airplane mode
driver.setNetworkConnection(1)

// set wifi only
driver.setNetworkConnection(2)

// set data only
driver.setNetworkConnection(4)

// set wifi and data
driver.setNetworkConnection(6)