Wednesday

AngularJS vs PolymerJS Testing



What is Angular?

Angular is a complete framework for building web apps. It has high-level APIs for things like services, routing, server communication.
Here are some features that Angular offers:

  1. Directives 
  2. Dependency injection
  3. Testing support
  4. Routing
  5. Services
  6. Server communication

What is Polymer?

Polymer is a library for creating Web Components, which are a set of W3C standards and upcoming browser APIs for defining your own custom HTML elements.
Here are some features that Polymer offers:

  1. Declare custom elements
  2. Widgets
  3. Polyfills for new web platform features
  4. Encapsulation for the DOM
  5. Built on emerging web standards

Even though Angular and Polymer aim to do different things, there is currently some overlap. Web components and Angular’s element directives are very similar, and if there’s a comparison to be made it should be between Polymer’s Custom Elements and Angular’s directives.

Summary - Angular, a MVC framework, and Polymer, polyfills and enhancements for custom elements built on top of Web Components, can live harmoniously in the same app.
But from a testing perspective its definitely angular that wins hands down with it's Protractor testing framework for AngularJS 

Monday

Box full of testing mindmaps




Here is the best collection of testing Mind-Maps I have seen :

http://apps.testinsane.com/mindmaps/

Have fun browsing!

Tuesday

Unable to charge the iPad using USB


Now here is a scenario where I am automating applications on an iPad. The iPad is connected to the usb port of a machine which has all other testing devices connected.

Problem: There is a known issue with iPad not charging and if you search forums you will notice the solution that says "Charge via a wall outlet if your computer USB port does not support high power output...most older computers do not have high power USB ports, and some of the new models still lack those ports."

This was not a viable solution as I had multiple users accessing this machine and the test devices had to be plugged into the system round the clock.

Solution: What I finally did and that helped -

ASUS came up with a software to deal specifically with charging issues related to Apple devices. It works by simply increasing the USB port’s power output.
This should work with all motherboards and computers (Windows platform only) as claimed by ASUS.
Step 1: Download the software from here ASUS Ai Charger
Step 2: Unzip the downloaded file “AiCharger_V10006_XpVistaWin7.zip” and run. At the end you will be prompted to restart your computer.
Step 3: Once the computer has been restarted, you should now be able to see the ASUS Ai Charger icon in your bottom-right taskbar.
Happy iOS testing!

Monday

Parameterize properties file in Java



If you are using a properties file and passing key value pairs, there are instances when you would want to parameterize the values passed. In my case the dynamic xpaths need to be parameteized for more flexibility

Solution: MessageFormat

Steps to achieve this :


  1. Your properties file should have the key value as :
    1. HomePage.DynamicObject.Button=//*[@text=''{0}'' and @width>0] 
  2. In the above statement {0} is the parameter 
  3. In your class file that calls the property
    1. Properties obprop = new Properties();
    2. String Locator= MessageFormat.format(obprop.getProperty(Object_Identifier), params);
    3. where Object_Identifier is HomePage.DynamicObject.Button
    4. and params is the parameter you want to pass

Note:  Within a String, a pair of single quotes can be used to quote any arbitrary characters except single quotes. For example, pattern string "'{0}'" represents string "{0}", not a FormatElement. ...

Any unmatched quote is treated as closed at the end of the given pattern. For example, pattern string "'{0}" is treated as pattern "'{0}'".

Tuesday

Cheatsheet Git

Here is an awesome cheatsheet for the git repo:



P.S: Download the file for clarity

Remove duplicate lines from a file



Problem:

You have two files that you have merged but now there are duplicate lines you want to omit.

Solution:

There are many ways to do this but the easiest is to use this utility:
http://textmechanic.com/Remove-Duplicate-Lines.html

Monday

Eclipse Referenced Libraries disappear



Automating using Java Eclipse? 

Problem:  In Java projects in Eclipse sometimes the folder "Referenced Libraries" disappears from the "Project Explorer" view. All third party jars are shown directly in the root of the project folder

Solution 1:  Bring up the "Package Explorer" view (instead of the "Project Explorer" view).

Solution 2:  Click on the little "down arrow" icon in the top-right corner of the Package Explorer view. In the context menu that appears, one of the items on the menu is "Show 'Referenced Libraries' Node." Click on that menu item.

Thursday

Eclipse Cucumber Plugin - Syntax highlighting not working feature file

If you have just installed the eclipse plugin for cucumber and the feature file steps are not colored then here is the simple solution.

Obviously you have already checked the following:

  1. Plugin Installed correctly
  2. Extension of this file is correct.

Solution: 
What went wrong is that you have accidentally opened the file with 'Text Editor'. All you need to do is change the default to "Editor" 


Monday

Device Enablement in SeeTest



The new feature of device enablement has made iOS mobile automation easy. Now we do not need a provisioning profile !!

Here are the steps tried first hand:

When you add a new device and select the checkbox for instrumented device, you now see a message:


Choose the option for device enablement and click ok, you will see an automated mail sent to you 


 Once you have received the email on confirmation another email will be sent to the support as a request:

Within a few hours you will receive a link to download the .def file!


Happy iOS automation!!!

Friday

Key Events in Android Device Automation


If you are looking to automate your android device there are instances when the automation tool/scripts need to run the adb shell commands to achieve the actions:

If you are using seeTest one of them is:
client.run("adb shell input keyevent 26");

For more commands look at:
http://developer.android.com/reference/android/view/KeyEvent.html


Happy Android automation!


Thursday

Node Grunt error enoent stat roaming npm


If you are working on protractor or any similar application, the prerequisite is to install node and grunt. Installing node is a child's play but if you are trying to install grunt

npm install -g grunt-cli

It bombs and says  Error: ENOENT, stat 'C:\Users\Ady\AppData\Roaming\npm'

Solution: Manually creating a folder named 'npm' in the path that it specifies , in this case C:\Users\Ady\AppData\Roaming\npm

Reason: a bug in latest NodeJS for Windows installable

Tip: Run the command prompt as administrator.

Wednesday

PhantomJS Selenium Webdriver Java - setup and Error trying to find element with xpath



If you have a Selenium Webdriver framework that is working at its best!
All you now need is  a headless browser like PhantomJS to test your web applications that make the functional tests faster. (According to their website PhantomJS is “a headless WebKit with JavaScript API.” Webkit is the layout engine used by a few browsers, such as Chrome and Safari. So PhantomJS is a browser, but a headless one.)

Here are simple steps to add this capability in your selenium scripts:


  1. Download PhantomJS and extract the package. or windows its an exe file and for Mac its just a zip package you will need to extract. 
  2. Extract the phantomjs-1.9.x-windows.zip folder and locate phantomjs.exe file. 
  3. Copy this file to a common location where the framework libs are stored.(In my case I used the same space as ChromeDriver and IEDriver) 
  4. Add the following imports to your code:
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.phantomjs.PhantomJSDriver; import org.openqa.selenium.phantomjs.PhantomJSDriverService;


  1. In the place where you initialize WebDriver driver = new FirefoxDriver

  caps.setJavascriptEnabled(true); caps.setCapability(“takesScreenshot”, true);        caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,”C:\\Users\\\\Desktop\\Automation\\JavaLib\\PhantomJS\\phantomjs-1.9.2-windows\\phantomjs.exe”);   WebDriver driver = new PhantomJSDriver(caps);

  1. Continue coding as before with screenshots :) 
  driver.navigate().to("http://www.xyz.com");
  driver.manage().window().setSize( new Dimension( 1124, 850 ) );
  File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);     FileUtils.copyFile(scrFile, new File(“C:\\<savePath>\\iamnotadumbass+”.png”));

Note:  An issue I faced and was confused before I realized that this error message "Error trying to find element with xpath" does not really mean that but instead you need to be using http and not a https protocol for your webpage.

Alternative solution: 
The problem is most likely due to SSL certificate errors. If you start phantomjs with the --ignore-ssl-errors=yes option
phantomjs --ignore-ssl-errors=yes [phantomOptions] script.js [scriptOptions]
If that does not work try:
1. change user-agent
2. ssl-protocol that worked was tlsv1 or --ssl-protocol=any

Happy headless testing!

Monday

Schedule a Java ANT program on windows



This is the easiest way to schedule a ANT build.xml script that you want to Run on any machine

  1. Make sure you can navigate to the path where you have the build.xml stored and run the ant command from command prompt
  2. Once confirmed that you are able to run the script from the command line
  3. Create a .bat file with just one word ant in it. This does not do any exception handling
  4. Open the control panel -> System and Security -> Power Options  and make sure that the computer never sleeps option is set (you need admin rights)
  5. Open the control panel -> System and Security -> Administrative Tools -> Task Scheduler
  6. Create a new task and navigate to the path of the .bat file in the Actions Tab under start a program
  7. Make sure the "Start In (Optional)" field has the absolute path to the file (without quotes)
  8. The final change is assigning the "Full Control" permission explicitly to .bat file for the account running the task.

Note:
  • Make sure that the task is running as an account that has explicit "Full access" permissions to all these things: The .bat file itself, the folder containing the .bat file, and the target files/folders that are affected by the .bat script. Inherited permissions didn't seem to work for me.
  • Make sure that the account running the task is a member of the local "administrators" group for this machine
  • Make sure that the task is set to "run whether logged on or not"
  • The Task should run successfully with expected output when you right-click on the task and select "run" If it does that then it will run successfully when you are logged off.

Friday

Performance testing with Selenium Webdriver - Navigation Timing API




In continuation to my previous post on performance testing with Selenium Webdriver , I found the "Navigation Timing API" the best way as it has loads of parameters that we can slice and dice the way we want to get different performance parameters like:

"Total Time:"+(loadEventEnd - navigationStart)/1000 + " seconds"+ "

"Server Render Time: "+ (responseEnd - requestStart) + " milliseconds"

"User Experience: "+ (domComplete - requestStart) + " milliseconds"

"Network:"+ (connectEnd - navigationStart)/1000 + " seconds"

"Server:"+ (responseEnd - requestStart)/1000 + " seconds"

"Browser:"+ (loadEventEnd - domLoading)/1000 + " seconds"

The properties you can play with are:


























The meaning of these events is described in Microsoft's performance.timing documentation and more formally in the W3C Recommendation.

Thursday

Performance Testing using Selenium Webdriver



Yes we know that Selenium Webdriver is a functional testing tool and is not a recommended option to do performance! But then there are times that you want to just do a quick performance check and find the bottlenecks in your application, here is how:

The solutions here are organised based on the complexity and detail you want to achieve:

Solution 1:  Measuring performance using a Timer in Selenium WebDriver

We can use the the StopWatch class for measuring the time taken for the page to load or any inbuilt date time calendar feature:


StopWatch pageLoad = new StopWatch();
pageLoad.start();
//Perform your test
pageLoad.stop();
System.out.println("Total Page Load Time: " + pageLoad.getTime() + "milliseconds");

Or

Calendar cal = Calendar.getInstance();
Date d1 = cal.getTime();
//Perform your test
Calendar cal2 = Calendar.getInstance();
Date d2 = cal2.getTime();
long diff = d2.getTime() - d1.getTime();
long diffSeconds = diff / 1000 % 60;  
long diffMinutes = diff / (60 * 1000) % 60;   
System.out.println("Execution Time:",diffMinutes+" minute and "+diffSeconds+"seconds"););

Solution 2:  Measuring performance with the Navigation Timing API

JavascriptExecutor js = (JavascriptExecutor) driver;
long navigationStart = (Long) js.executeScript("return window.performance.timing.navigationStart;");
//Perform your test
long loadEventEnd = (Long) js.executeScript("return window.performance.timing.loadEventEnd;");
System.out.println("Page Load Time is " + (loadEventEnd - navigationStart)/1000 + " seconds.");

Solution 3:  Measuring performance with JMeter
http://seleniummaster.com/sitecontent/index.php/performance-test-menu/selenium-load-test-menu

Solution 4:  Measuring performance with Firebug's Net panel
http://www.softwareishard.com/blog/firebug/automate-page-load-performance-testing-with-firebug-and-selenium/


Hope that helps someone playing with Selenium WebDriver and trying to achieve some basic performance testing!

Tuesday

Happy World Tester's Day!

Now this is a day that I love, though I was introduced to this just three years back and if you are still wondering what is it all about:


On September, 9 1945 the scientists of the Harvard University while testing the computer Mark II Aiken Relay Calculator had found a moth which got stuck between the contacts of the electromechanical relay. 

The work they performed required some description, and the word had been found – «debugging» (literally: disposal of an insect) – and now it is used to describe the process of identifying and eliminating bugs which cause a computer to malfunction. The removed insect was pasted into the computer log with the entry: “First actual case of bug being found”, and was then transferred to the computer museum.

Now that you know, Happy Tester’s day !

Monday

SeeTest Cheatsheet for Mobile test automation

Here is the first of its kind a cheat sheet for SeeTest mobile test automation:






P.S: Click on the image to download a larger copy. You can also email me for an excel version for easier navigation!

Happy Mobile testing!

Friday

Remotely access a Mac machine from windows machine



There are many tools that allow you to remotely log-in either between two Windows / two MAC machines. There are five tools that I evaluated while choosing which one is the best to
remotely access apple Mac OS X from Windows. 

  1. TeamViewer
  2. LogMeIn
  3. RealVNC
  4. Vine Server
  5. Remote Management
The best tool that I thought when it comes to automation is the free version of LogMeIn. The reason being the refresh rate and the connectivity. You can write a small script that can even help you schedule tests on the remote machine!

  • LogMeIn is Free 
  • Web interface or the Firefox plugin. 
  • Easy steps 
    • First you will need to create a free account
    • Login from the Mac computer and click the Add Computer button to download the LogMeIn Installer. 
    • After installation, you can access that computer from any other computer by logging in to LogMeIn.

Thursday

Modify the IP headers on the iPhone / Bypass or change the ip on any device

Problem: If we need to test an application which is outside the network or with a different IP address how do we do that? we need to be able to use a proxy server that bypasses or replaces some properties that can be then used to modify the way the application is accessed.


Solution:
Here is an example of how to do that on an iPhone (You can do this for any device) :

  1. Go to settings in iPhone and modify the manual IP address. Give it the same IP address as that of the local machine where the proxy server would run and select a valid port : say 8080
  2. To set the IP headers or proxy download the Burp Free edition from here: http://portswigger.net/burp/download.HTML
  3. Go to the Intercept tab and make sure it is off.
  4. Go to Options tab and edit the Proxy listeners to local ip of the machine:
  5. Scroll down to Match and Replace Pick a Request header not in use and modify that:
    In our case “Client-Version” to
  6. Now check the HTTP history tab to confirm that the header is replaced while surfing applications.

Monday

How do I get my Nexus 7 to show up in the adb devices list ?




Problem:
  • Nexus 7 that I'm trying to connect to Windows computer for automation over adb
  • No device driver for nexus 7 ?
What did not work:
  • I did click on the build number 7 times to get the developer options enabled
  • Tried connecting both as a Media device (MTP) and as a Camera (PTP). ("Connected as a media device" up at the top left corner, de-selecting Media Device (MTP) and then checking Camera (PTP).)
  • downloaded this usb driver: http://dlcdnet.asus.com/pub/ASUS/EeePAD/nexus7/usb_driver_r06_windows.zip
  • Go to the device manager , right click the nexus device and choose properties, choose "hardware" and then choose update your driver , choose manualy and pick the folder you opend the zip file to and press apply.
What worked for me:

The universal adb driver installer worked for me. Download the universal driver exe Run with the device connected and it will give you an option to install. http://adbdriver.com/
Install that and you will now see the option on your tablet to connect to the computer :)

Update: What worked on Windows 8.1


If the device is listed in Device Manager as Other devices -> Android but reports an error code 28:
  • Google USB Driver didn't work for me. You could try your corresponding OEM USB Drivers, but in my case my device is not listed there.
  • So, install the latest Samsung drivers: SAMSUNG USB Driver v1.5.33.0
  • Restart the computer (very important)
  • Go to Device Manager, find the Android device, and select Update Driver Software.
  • Select Browse my computer for driver software
  • Select Let me pick from a list of device drivers on my computer
  • Select ADB Interface from the list
  • Select SAMSUNG Android ADB Interface (this is a signed driver). If you get a warning, select Yes to continue.
  • Done!

Happy Android Automation!

Funny way to enable developer options on android



Problem : Toggle on the "USB Debugging" in the "Developer Options" area of Settings in an android device
This is a prerequisite to perform automation.

Solution:
If you do not see "Developer Options"
  1. Go into "About device" in Settings 
  2. Tap on the "Build number" entry seven times, which will unlock "Developer Options".

So it's that simple tapping the build number will make you a developer :P

Thursday

Install eclipse on Mac OS X 10.9 onwards / JRE or JDK must be available in order to run Eclipse.



If you are seeing this error while launching eclipse after an update to your Mac machine:

"A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse."

There are couple of solutions:

  • editing eclipse.ini, adding in
vm /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/bin/java just before the -vmargs
  • editing the Info.plist and adding the full path to the Oracle SDK, checked if syntax was correct by double clicking and succesfully opening it and verified that the path was correct.
  • adding 4 capabilities to the JDK:
                CommandLine
JNI BundledApp WebStart Applets

  • The eclipse.ini entry must have -vm on a separate line from the path
    -vm 
    /Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home/bin/java

  • All this after installing JDK7 and on my Mac I still see errors!!


    What finally worked:
    Download the jdk-7u60-ea-bin-b15-macosx-x86_64-16_apr_2014.dmg the 64 bit version mostly!
    All set and working!!

    Wednesday

    SeeTest - Launch iOSBridge automatically



    If you are automating your apps on seeeTest + iOS and you see that the iOS Bridge just goes blank and says disconnected. You know that your tests will not run as the prerequisite for any test to run is that you need to have the iOS Bridge running in the background.

    Solution: Manually launch iOS Bridge on your phone. But what if your devices are located on a remote system and cannot be accessed ??

    Solution:  Using the Runtime Application Manager mechanism

    The Application Manager is used primarily to install and instrument applications so that their Native and Web elements/objects can be used to test them .Applications are generally imported from the local disk of the tester's computer.
    1. Click on the 'Application Manager' button in SeeTest located under Applications on the left hand side corner. The icon looks like an import button
    2. The Application manager will then appear on your screen and you need to import the ipa file that is located in <SeeTest InstallationFolder>/bin/native folder. The ipa file is called LaunchAgent.ipa
    3. Once completed it will ask you to install the application
    4. then it would ask you to launch the application
    5. You can now launch the iOS Bridge remotely by either clicking on the icon to launch in SeeTest under applications
    6. In order to Launch an application in the script you can use the 'Launch' command                            Do not use: //client.launch("task:com.experitest.LaunchAgent", true, false);
    7. Use client.openDevice();
    Happy iOS Automation !




    Friday

    Working on iOS Testing and want to add to the classpath on OSX / Mac



    If you want to make a certain set of JAR files (or .class files) available to every Java application on the machine, then your best bet is to add those files to /Library/Java/Extensions.

    Or, if you want to do it for every Java application, but only when your Mac OS X account runs them, then use ~/Library/Java/Extensions instead.


    In OSX, you can also set the classpath from scratch like this:export CLASSPATH=/path/to/some.jar:/path/to/some/other.jar

    Or you can add to the existing classpath like this:export CLASSPATH=$CLASSPATH:/path/to/some.jar:/path/to/some/other.jar



    Happy iOS testing!

    Appium - Mobile test automation on a real device


    If you are looking to perform test automation on a real device (iPhone in my case) and you have had problems with the documentation on the official Appium website , the following post will help you for sure:

    Prerequisites: 

    1. Apple account with valid apple ID 
    2. Download and Install Eclipse on your Mac – A link that might help you with the installation process http://www.cs.dartmouth.edu/~cs5/install/eclipse-osx/
    3. Download and Install Xcode
    4. Download Selenium Jars for java from the Selenium website
    5. Download the java client libraries from http://appium.io/downloads.html
    6. Download and install appiumD
      1. download the latest version from Appium.io.
      2. Mount the disk image.
      3.  Drag Appium.app to your Applications folder
    7. Download and Install brew (The missing package manager for OS X)
      1. It's on the bottom of the Homebrew homepage. http://brew.sh/ (Yeah, it would be helpful if it was listed at the top, instead.)
      2. From a Terminal prompt:  ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
    8. Tip: (Optional) – Install Oh my zsh for a better shell experience https://github.com/robbyrussell/oh-my-zsh
    9. Your apple id has access to a valid iOS Developer portal


    Important points to note:

    1. Appium uses ‘Appium Inspector’ to view the elements similar to what we have as ‘uiautomatorviewer’ tool to view UI components in Android in UI Automator. You can access elements using name , xpath or tagName as visible through appium inspector
    2. Appium Inspector can be launched by clicking on the blue ‘i’ button besides ‘Launch’ button from appium app.
    Setup and Execution:

    The core of what most of the Appium help posts are missing:


    1. Find UDID of the iphone: http://www.innerfence.com/howto/find-iphone-unique-device-identifier-udid
    2. Turn on web inspector on iOS device (**settings > safari > advanced**, only for iOS 6.0 and up) http://appium.io/slate/en/master/?java#toc_80
    3. Note:1.       To be able to run your tests against mobile Safari we use the SafariLauncher App to launch Safari. Once Safari has been launched the Remote Debugger automatically connects using the ios-webkit-debug-proxy.
    4. Setup: Before you can run your tests against Safari on a real device you will need to:   Have the ios-webkit-debug-proxy installed, running and listening on port 27753 
    5. Note: When executing against a real iOS device appium is unable to access the web view directly. Therefore the connection has to be established through the USB lead. To establish this connection we use the ios-webkit-debugger-proxy. http://appium.io/slate/en/master/?java#toc_14
    6. To install the latest tagged version of the ios-webkit-debug-proxy using brew, run the following commands in the terminal:
      1.  ruby -e "$(curl –fsSL https://raw.github.com/mxcl/homebrew/go/install)"
      2. brew update
      3. brew install ios-webkit-debug-proxy
    7. Once installed you can start the proxy with the following command:
      1. Change the udid to be the udid of the attached device and make sure to set the port to 27753 as that is the port the remote-debugger uses:
      2. > ios_webkit_debug_proxy -c 0e4b2f612b65e98c1d07d22ee08678130d345429:27753 –
    8. On Mac                                    i.      Connect your device to your Mac.
    9.                                                              ii.      In the Devices organizer under Devices, select your device.
                                                                  iii.      Click the “Use for Development” or “Add to Member Center” button.
                                                                 iv.      If the device was previously used for development, the “Use for Development” button does not appear. If this happens, click “Add to Member Center” at the bottom of the window instead.
                                                                   v.      In the team dialog that appears, select the checkbox next to your account name, and click Choose.
                                                                 vi.      If a Certificate Not Found dialog appears, click Request.
    10. Create a provisioning profile that can be used to deploy the SafariLauncherApp.
    11. Create a new App Id and select the WildCard App ID option and set it to “*”
      2.       You can only create application IDs in the iOS developer portal. Once you're logged in, choose the "Certificates, Identifiers & Profiles" link:
      3.       On the next screen, choose the "Identifiers" option on the left:
      4.       Now you can click the "+" icon near the top right to create a new App ID:
      5.       The first thing you're asked to do is provide an App ID description:
      6.       Choose an App ID Suffix as “*”
      7.       Complete and submit to get a message – “This App ID is now registered to your account and can be used in your provisioning profiles
    12. Create a new Development Profile and for App Id select the one created in step 1.
      1.       Click on Add new Provisioning Profile
      2.       Choose iOS App Development option
      3.       for App Id select the one created in step 1.
      4.       Select your certificate(s) and device(s) and click next.
      5.       Set the profile name and generate the profile.
      6.       Download the profile and open it with a text editor.
    Make sure you either use XCode and install ios --real-safari –launcher on your device:
    1.                                                                i.      git clone https://github.com/appium/appium.git
                                                                   ii.      install npm using brew – brew install npm
                                                                  iii.      cd appium
                                                                 iv.      ./reset.sh --ios --real-safari –launcher
    2. If unable to install. Open the git project using XCode - build and run the installation
    ExecurtionExecution:
    Execution:
    1. Make sure you have a new terminal and run: ios_webkit_debug_proxy -c 0e4b2f612b65e98c1d07d22ee08678130d345429:27753 –d
    2. Open another terminal and start the appium server:                                                              
                                                                                      i.      cd appium
                                                                                     ii.      node . -U --app ‘safari’


    You are good to start writing your selenium webdriver scripts now




                                   Sample script in Java(JUnit 4)

    package com.test.appium;
    import java.net.URL;
    import java.util.Iterator;
    import java.util.Set;
    import org.junit.After;
    import org.junit.Before;
    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;
    public class FirstTestCase {
    public WebDriver driver = null;
    @Before
    public void setUp() throws Exception {
    // set up appium
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("browserName","Safari");
    capabilities.setCapability("deviceName","iPhone");
    capabilities.setCapability("platformName","iOS");
    //capabilities.setCapability("udid","36d2a431a84fd87e95dcf87914a7c3df386b6d4b");
    capabilities.setCapability("version","7.1");
    System.out.println("Before App launched");
    driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"),capabilities);
    System.out.println("App launched");
    }
    @After
    public void tearDown() throws Exception {
                  driver.quit();
    }
    @org.junit.Test
    public void testCases() throws InterruptedException {
    driver.get("https://test.com");
    Thread.sleep(5000);
    WebElement login = driver.findElement(By.xpath("//*[@class='login_button']"));
    login.click();
    int itr=2;
    String windowHandle=null;
    Set parentWindowHandle = driver.getWindowHandles(); // save the current window handle.
      Iterator windowIterator = parentWindowHandle.iterator();
      while(windowIterator.hasNext() && itr!=0) {
        windowHandle = windowIterator.next();
        itr=itr-1;
      }
      driver.switchTo().window(windowHandle);
      WebElement username = driver.findElement(By.xpath("//*[@id='username']"));
      username.sendKeys("testing");
    }
    }