Selenium Web Driver 2.0 Setup and Create First Project

For Quick View visit my you tube video –Setup and Create First Project

Introduction

  • Selenium 2 (Selenium WebDriver) = Selenium 1.0 + WebDriver
  • I will not go in detail to explain selenium 1.0. It just include selenium IDE + Selenium RC and Selenium Grid
  • Selenium 2 has included selenium 1.0 + WebDriver
  • Selenium WebDriver is designed in a simpler and more concise programming interface along with addressing some limitations in the Selenium-RC API
  • Support various programing language to write Test Script (ex. Java, Paython, C#,Ruby,Php..)
  • Support various browsers to Test (ex. Chrome, FireFox, IE, Safari)
  • Support on various OS (ex. Windows, Linux, Mac)
  • Selenium-WebDriver was developed to better support dynamic web pages where elements of a page may change without the page itself being reloaded.
  • WebDriver’s goal is to supply a well-designed object-oriented API that provides improved support for modern advanced web-app testing problems.

Setup

Create First Selenium Project

  • Launch the Eclipse IDE
  • Create new project or Open project
  • Configure Build Path (Right click on Project > Build Path > Configure Build Path or Go to Project Properties)
  • Open Libraries tab under Java Build Path
  • Add External Jars ( Selenium xx all Jars)
  • Write Test Script for each Test Step

Test Scenario – Successful Login with valid credential in http://phptravels.net

Test Case – Login with valid username and password

Test Steps :

  1. Open Firefox driver
  2. Open Login page url – http://phptravels.net/login
  3. Enter valid email id – user@phptravels.com
  4. Enter valid password – demouser
  5. Press Login button
  6. Verify that user successfully login into the site and display user name on left top corner – John Smith
  7. Close the browser

Scripts:

package SmokTest;

 

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

import org.testng.Assert;

public class Login {

public static void main(String[] args) throws InterruptedException {

// TODO Auto-generated method stub

System.setProperty(“webdriver.chrome.driver”, “C:\\chromedriver_win32\\chromedriver.exe”);

WebDriver driver = new ChromeDriver(); // Step 1 – Open Firefox Browser

//WebDriver driver = new FirefoxDriver();

driver.get(“http://phptravels.net/login”); // Step 2 – Open Web app URL

System.out.println(“Launches Chrome browser successfully”);

driver.findElement(By.name(“username”)).sendKeys(“user@phptravels.com”); //step 3

driver.findElement(By.name(“password”)).sendKeys(“demouser”); //step 4

driver.findElement(By.xpath(“.//*[@id=’loginfrm’]/div/div[5]/div/div/div[1]/button”)).click(); //step 5

Thread.sleep(5000);

String WelcomeMsg = driver.findElement(By.xpath(“.//*[@id=’top’]/div[5]/div[1]/div[1]/h3”)).getText();

System.out.println(“Welcome :”+WelcomeMsg);

Assert.assertEquals(“Hi, John Smith”, WelcomeMsg, “Not matched Login msg”);

driver.close(); // Close the browser

}

}

Advertisements
Posted in Selenium, Set up | Leave a comment

Selenium integration with Cucumber BDD

Cucumber – a Behavior Driven Development (BDD) framework which is used with Selenium for performing acceptance testing.  It allows automation of functional validation in easily readable and understandable format (like plain English) to Business Analysts, Developers, Testers, etc.

Behavior Driven Development is extension of Test Driven Development and it is used to test the system rather than testing the particular piece of code.

I am using eclipse – Eclipse Java EE IDE for Web Developers. Version: Indigo Service Release 2

  1. Create new Java Project. Enter Project Name and click on Next
  2. Click on “Add External Jar” button and add all cucumber jars mention below        Cucumber1
  3. Add Selenium Jar – selenium-server-standalone-2.53.0.jar
  4. Add cucumber plugin in selenium
    1. Help > Install New Software
    2. http://cucumber.github.com/cucumber-eclipse/update-siteCucumber2
  5. Now add new file in project with extension .featureCucumber3
    1. Feature Files: Feature files are essential part of cucumber which gives information about the high level business functionality. Everybody should be able to understand the intent of feature file by reading the first Feature step.
    2. Scenario: Basically a scenario represents a particular functionality which is under test.By seeing the scenario user should be able to understand the intent behind the scenario and what the test is all about. Each scenario should follow given, when and then format. This language is called as “gherkin”.
      1. Given: As mentioned above, given specifies the pre-conditions. It is basically a known state.
      2. When: This is used when some action is to be performed. As in above example we have seen when the user tries to log in using username and password, it becomes an action.
      3. Then: The expected outcome or result should be placed here. For Instance: verify the login is successful, successful page navigation.
      4. Background: Whenever any step is required to perform in each scenario then those steps needs to be placed in Background. For Instance: If user needs to clear database before each scenario then those steps can be put in background.
      5. And: And is used to combine two or more same type of action.Example:Feature: Facebook Login FunctionalityScenario: Test Valid Facebook Login Functionality
        Given user navigates to facebook.com

        When user logs in using Username as “USER”
        And password as “password”
        Then login should be successful
        And Home page should be displayed

    3. Junit Runner:To run the specific feature file cucumber uses standard Junit Runner and specify tags in @Cucumber.import org.junit.runner.RunWith;
      import cucumber.api.CucumberOptions;
      import cucumber.api.junit.Cucumber;

      @RunWith(Cucumber.class)
      @CucumberOptions(
      features = “features”,
      glue = {“stepDefination”},
      plugin={“html:target/cucumber-html-report”}
      )
      public class TestRunner {

      }

    4. Implement feature file:public class smokeTest {WebDriver driver;

      @Given(“^Open firefox and start Gmail$”)
      public void Open_firefox_and_start_application() throws Throwable {

      System.setProperty(“webdriver.chrome.driver”,”C://chromedriver_win32//chromedriver.exe”);
      driver = new ChromeDriver();
      driver.manage().window().maximize();
      driver.get(“http://www.gmail.com”);
      }

      @When(“^Enter valid Gmail username and password$”)
      public void Enter_valid_username_and_password() throws Throwable {
      // Write code here that turns the phrase above into concrete actions
      driver.findElement(By.name(“Email”)).sendKeys(“LoginUserName”);
      driver.findElement(By.name(“Passwd”)).sendKeys(“LoginPassword”);
      driver.findElement(By.id(“submit”)).click();
      }

      @Then(“^user should be able to login successfully$”)
      public void user_should_be_able_to_login_sccussfully() throws Throwable {
      // Write code here that turns the phrase above into concrete actions
      driver.quit();
      }

  6. Data Driven Testing in cucumber using Scenario Outline: Scenario outlines are usedwhen same test has to be performed with different data set. Let’s take the same example. We have to test login functionality with multiple different set of username and password.

                  Feature: Facebook Login Functionality
                  Scenario: Test Valid Facebook Login Functionality
                  Given user navigates to facebook.com
                  When Enter valid Gmail “<username>” and “<password>”
                   Then login should be successful

Examples:

|username         |password          |

|TestUser1          |password         |

|TestUser2          |password2        |

|TestUser3           |password3        |

Examples are used to pass different arguments in tabular format. Vertical pipes are used to separate two different columns. Examples can contain many different columns.

To implement the Feature file with Examples need to update its implementation with parametrize:

@When(“^Enter valid Gmail \”([^\”]*)\” and \”([^\”]*)\”$”)

public void Enter_valid_username_and_password(String uname,String pwd) throws Throwable {

// Write code here that turns the phrase above into concrete actions

driver.findElement(By.name(“Email”)).sendKeys(uname);

driver.findElement(By.name(“Passwd”)).sendKeys(pwd);

driver.findElement(By.id(“signIn”)).click();
}

 

Posted in Selenium, Set up | Leave a comment

Maven Integration in eclipse

Steps to install Maven [m2eclipse] in Eclipse

Maven1

  • Choose ‘Select All‘ and click Next
  • Accept the terms of the license agreement‘ and Finish
  • And it will start installing the plugi n
  • Finally restart your eclipse to take effect the environment

Create new Maven Project in Eclipse
File > New Project > Maven Project > Next
Select ‘Create a simple project’ > Next
Enter Group Id, Artifact id – ex. MavenCucumberDemoClick Finish
Once Maven project is created, is creates the project hierarchy as below

Maven3

you can give the all project dependency in pom.xml. Maven will automatically download all dependent jar files as shown below for cucumber project

Maven2

 

 

Posted in Build Automation, Selenium | Leave a comment

Python Setup with Example

Python is simple to use, but it is a real programming language, offering much more structure and support for large programs than shell scripts or batch files can offer. On the other hand, Python also offers much more error checking than C, and, being a very-high-level language

Python is an interpreted language, which can save you considerable time during program development because no compilation and linking is necessary

Python enables programs to be written compactly and readably. Programs written in Python are typically much shorter than equivalent C, C++, or Java programs, for several reasons:

  • the high-level data types allow you to express complex operations in a single statement;
  • statement grouping is done by indentation instead of beginning and ending brackets;
  • no variable or argument declarations are necessary.

Installation

Download 32bit or 64bit exe from https://www.python.org/downloads/windows/

Setup environment variable ex. in the path variable add

C:\Python35;C:\Python35\Scripts;

To verify open cmd and type pip

Install selenium

cmd > pip install selenium

installpythonselenium

Open python shell to play with some useful commends

python_shell

Installing Python in Eclipse

  1. Unzip eclipse-standard-luna-R-win32.zip, the file that you just downloaded and moved.
    On my machine (running Windows 7), I can
  • Right-click the file.
  • Hover over the IZArc command from the menu of options.
  • Click Extract Here

2. Open Eclipse > Click on Help then click Install New Software… in its pull-down menu, as shown below.

3. Enter the text (or cut/paste from this document) http://pydev.org/updates into the Work with text box and press Enter.

In a few seconds the information under Name should change from
There is no site selected to Pending to

Select only the top PyDev checkbox; do NOT select the PyDev Mylyn Integration (optional) box.
Check before proceeding that the Install pop-up window appears as

4. Click Next >

A new Install pop-up window will appear.

Select the I accept the terms of the license agreement radio button, so the window appears as

5. Check the box labeled Brainwy Software; Pydev; Brainwy.

Check before proceeding that the Install pop-up window appears as

 

  • Click OKThe installation will finish (showing the final progress bars).A Software Updates pop-up window will appear.
  • Click YesEclipse will terminate and restart. As you did in step 3, click OK to the Workspace Launcher pop-up window.
  • Click Window (to the left of Help on the far right of the line below this window’s blue title Java – Eclipse) and then click Preferences in its pull-down menu, as shown below.
  • Drill down to select the interpreter:
    • Disclose PyDev by clicking the + in front of PyDev or double-clicking PyDev (after the +); the + changes to a .
    • Disclose Interpreters by clicking the + in front of Interpreters or double-clicking Interpreters (after the +); the + changes to a .
    • Select Python – Interpreter.

    The Preferences pop-up window should appear as follows

  • Click New… at the top-right of the top windowA Select Interpreter pop-up window appears.Type Python34 in the Interpreter Name text box.
    Type (or cut/paste) C:\Python34\python.exe in the Interpreter Executable text box (or browse to this file).
    The Select Interpreter pop-up window should appear as
  • Click OK.A Selection needed pop-up window will appear.PythoneclipsEnsure that a check appears in all four checkboxes.
  • Click OK.The Preferences pop-up window will be changed to
  • Click OK.A Progress Information pop-up window will appear.During installation, it will show the various operations it is performing and a progress bar for each one. Eventually the installation will terminate.

    If the following pop-up window appears

 

  • Click Window (to the left of Help on the far right of the line below this window’s blue title Java – Eclipse SDK), hover over Open Perspective in the pull-down menu and then click Other… in the next pull-down menu.The Open Perspective pop-up window will appear.
  • Double-click PyDev (third from the bottom)The blue label on the Eclipse window will change to PyDev – Eclipse, the Package Explorer in the upper-left tab will change to PyDev Package Explorer, and a PyDev icon will appear to the right of the Java icon.

Congratulation! Eclipse is now installed for Python

 Your first Python program in Eclipse

Select File -> New -> Project. Select Pydev -> Pydev Project.

Create a new project with the name “de.vogella.python.first”. Select Python version 2.6 and your interpreter.

Press finish.

Select Window->Open Perspective ->Other. Select the PyDev perspective.

Select the “src” folder of your project, right-click it and select New -> PyDev Modul. Create a module “FirstModule”.

Create the following source code.

'''
Created on Apr 15, 2016

@author: Samir Patel
'''
def add(a,b):
    return a+b

def addFixedValue(a):
  y = 5
  return y +a
  
print add(1,2)
print addFixedValue(1)

Right-click your model and select Run As -> Python run.

Congratulations! You created your first (little) Python modul and ran it!

 

 

Posted in Python | Leave a comment

Selenium Framework

Introduction to Framework :

A test automation framework is an integrated set of technologies, tools, processes and patterns brings organization of thought and clarity thereby simplifying and enabling a team perform Automation not only effectively but also efficiently.

framework is a hierarchical directory that encapsulates shared resources, such as a dynamic shared library, image files, localized strings, header files, and reference documentation, in a single package. There are various frameworks available for automation, such as:

  • Modular Framework
  • Keyword-Driven Automation Framework
  • Data-Driven Automation Framework
  • Page Object pattern
  • Hybrid Automation Framework

Modular Framework

The main advantage of Page Object Model is that if the UI changes for any page, it don’t require us to change any tests, we just need to change only the code within the page objects (Only at one place).

Keyword-Driven Automation Framework

Keywords are essentially blocks or functions that are named so that they can be consumed for a given functionality.

In this framework, keywords are developed which are equal to a unit level functionality. It is an independent framework which perform automation based on the keywords specified in the excel sheet. Based on the type of application, the number of keywords will be increased to handle different functionalities.

        Advantages:

  • High re-usability can be achieved by re-using across multiple test cases.
  • Maintainability is easy which doesn’t require any Automation expertise.
  • Debugging is easy.

        Disadvantages:

  • Requires a complicated framework than the data driven framework.
  • Test cases grow longer and complex and this is due to the greater flexibility

 Data-Driven Automation Framework

In this methodology, test data is separated from test scripts and results are returned against the test data. And finally if all the test data combinations are pass, then only the test case is treated as “PASS”. If any one of the test data combination is failed, then the entire test case will be treated as “FAIL”

        Advantages:

  • It is suitable for test cases with multiple test data combinations.
  • It reduces the number of test scripts needed to implement all the test cases.

Disadvantages:

  • It is not suitable for test cases having very simple actions which doesn’t include any test data.

Page Object Pattern

If you think of a web based application as a network of pages that interact with each other AND there are large number of pages in your application that can change nature frequently, this pattern is the most favourable one to use.

Page-objects (or classes) are defined for each page, where a page contains the html locator information and also the methods that can operate on those page elements.

The concept of page object is to be able to have the element initialized by the time we want to interact with it, so that we don’t have to dig into the DOM every time we need to interact with it.

Hybrid Automation Framework

This framework is the combination of both data-driven and keyword driven testing frameworks. It allows data driven scripts to take advantage of the powerful libraries and utilities in a keyword based approach.

Advantages:

The Hybrid framework is build with a number of reusable modules / function libraries that are developed with the following features in mind:

  • Maintainability – Hybrid framework significantly reduces maintenance effort
  • Re-usability – It allows to reuse test cases and library functions
  • Manageability – effective test design, execution, and traceability
  • Accessibility – easy to design, develop, modify and debug test cases while executing
  • Availability – Allows to schedule automation execution
  • Reliability – due to advanced error handling and scenario recovery
  • Flexibility – framework independent of system or environment under test
  • Measurability – customizable reporting of test results ensure the quality output
Posted in Framework, Selenium, Test Automation | Leave a comment

Setup Android and Genymotion into Eclips and Automation Testing with Appium

Good Artical to step by step setup – http://www.software-testing-tutorials-automation.com/2015/09/steps-to-download-and-install-android.html

Download Appium

Before download and install appium in windows, Please make sure bellow given prerequisites are fulfilled.

  1. JDK Installed. View
  2. Android SDK Installed.
  3. Set ANDROID_HOME and Path Environment Variables.
  4. Eclipse ADT Plugin Installed.
  5. Microsoft .Net Framework, Node JS and PDANet+ for Android Installed.

1.Install the Java JDK and set JAVA_HOME to your JDK folder

  • Download from http://www.oracle.com/technetwork/java/javase/downloads/index.html
  • It opens Java SE Development Kit 8 Downloads page. Download jdk-8u31-window-i58.exe and install it
  • Set JAVA_HOME Variable in your windows system environment variable ex. Select advanced tab -> Click on Environment Variables button. It will open Environment Variables dialog.
  • Set Path Variable For Java

2. Install the Android SDK

  1. Download SDK from http://developer.android.com/sdk/installing/installing-adt.html
  2. Set ANDROID_HOME to be your Android SDK path and add the tools and platform-tools folders to your PATH variable.

androidsdk_path

  1. Need to run the ‘android’ tool (included in the SDK) and make sure you have an API Level 17 or greater API installed. Run “ddms” batch file

androidsdk_tools

Download Genymotion

  • Open https://www.genymotion.com
  • Login in
  • Go to Download page and download Genymotion latest version (i.e. 2.8.0) with VirtualBox. It will download the exe (i.e. genymotion-2.8.0.exe)
  • Now run the setup. It will install to default location (C:\Program Files\Genymobile\Genymotion)

Setup plugin in Eclipse

  • Start Eclipse, then select Help > Install New Software.
  • Click Add, in the top-right corner.
  • In the Add Repository dialog that appears, enter “ADT Plugin” for the Name and the following URL for the Location: https://dl-ssl.google.com/android/eclipse/

Install Genymotion plugin into Eclipse

  • Open Eclipse > Help > Install New Software
  • Add Location URL

For Genymotion – http://plugins.genymotion.com/eclipse/

Eclips_ADT_Plugin

  • Click OK.
  • In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
  • In the next window, you’ll see a list of the tools to be downloaded. Click Next.
  • Read and accept the license agreements, then click Finish.
  • If you get a security warning saying that the authenticity or validity of the software can’t be established, click OK.

For Genymotion setup the Preferences in Eclips Window > Preference

Preference_Genymotion

Install Node JS

Download Windows Installer (.msi) file as per your system(32 bit or 64 bit)

https://nodejs.org/en/download/

Capture the Logcat

Option 1 : From Eclipse once you open the emulator we can see the Logs in Logcat Go to Eclipse > Window > Show View > Other and select “LogCat” Eclipse_Logcat Eclipse_Logcat1

Option 2 : Generate the LogCat file From Command prompt (Once set path ..android-sdk-windows\platform-tools

Windows: adb logcat –d > %UserProfile%\Desktop\ellowoyld.txt

Windows: set timestamp=%date:~-4,4%%date:~-7,2%%date:~-10,2%%time:~0,2%%time:~3,2%%time:~6,2%adb logcat –d > “%UserProfile%\Desktop\%timestamp%-logcat.txt” Or

Create .bat file

1) Open notepad, or whatever your preferred text editor is (just not word or an rtf text editor)

2) Paste in your commands: set timestamp=%date:~-4,4%%date:~-7,2%%date:~-10,2%%time:~0,2%%time:~3,2%%time:~6,2% adb logcat –d >”%UserProfile%\Desktop\%timestamp%-logcat.txt” adb logcat –c 3) And save it to your desktop as a “.bat” file with a catchy name

Appium Architecture

Appium

In above figure mention that Client is any IDE (ex. Eclipse) where we write the code to automate an application So client would communicate to Server and Server understand what client will request and communicate with Mobile devices.

Appium is web-server. It follows the client- server architecture. Client would be communicating to server and server would be perform the necessary actions.

Client is initiates the Session. So client would be sending something calls as Desired Capabilities to the server so that server will understand what kind of session does it needs to create. This particular Server would responds back on same Session ID. This session id would be use for all further communication going to made between the client and server.

Appium is returns in Node.js. Appium understand each and every request that is coming form the client so communication is done over the http protocol it uses something call as communication between client and server is done by JSON Wire Protocol. Which means client written in any programming language like JAVA, Ruby, Python etc. and server understand what to do with client request and communicate with mobile devices and response back to client.

Appium communicate with iOS called as UIAutomation. if Android version less than 17, Appium communicate with Android called as Instrumentation and if Android version grater than 17, Appium communicate with Android by UiAutomator.

Appium is an open source, cross-platform test automation tool for native, hybrid and mobile web apps, tested on simulators (iOS, FirefoxOS), emulators (Android), and real devices (iOS, Android, FirefoxOS).https://university.utest.com/how-to-set-up-your-first-android-automation-project-with-appium/

Note – Appium Support from Android API 17 means Support from Android 4.2.2

Setup Appium

https://www.youtube.com/watch?v=WgnusVu9Icg download the JDK, Android SDK, Eclips setup Java and JDK path in environment (Verify in cmd Java -version) setup Android Path Download Appium exe, nodejs Start Appium server – Option 1 – Open appium.exe Option 2 – cmd > go to C:\Program Files (x86)\Appium\node_modules\appium\bin > node appium

  • Download SDK and set-up environment variable

http://developer.android.com/sdk/index.html#Other

Download android-sdk zip file for window or Mac OS

SDK

Extract zip file and Click on SDK Manager.exe

Set up the Environment Variables and path

ANDROID_HOME D:\android-sdk-windows

Add D:\android-sdk-windows\platform-tools and D:\android-sdk-windows\tools under  path after semicolon(;)

Open cmd and type ‘adb’ to test it

  • Download and Setup Nodejs

https://nodejs.org/en/download/

run .msi only it will automatically detect and set the path

  • Download Appium

http://appium.io/downloads.html

Just run the appium-installer setup or run appium server it will automatically download latest version

  • Download Java Client

http://appium.io/downloads.html

Click on Java link under Appium Client Libraries

Download jar ex. 3.4.1

  • PDANet(optional)

http://pdanet.co/

User-full to identify the missing driver to connect your mobile device with PC via USB

  • Download Genymotion

https://www.genymotion.com

Appium_Start

Install APK in mobile device

Run your virtual device or connect mobile device with USB

Open cmd and type adb devices to see connected device

cmd

now type commend ‘adb install <apkpath> <Filename.apk>’ to install apk in connected device

InstallApk

Setup the test apk path in appium before start it

appium

Once Start appium server package and launch activity value set and disable

appiumstart

click on start button on right top corner Find the webelement and xpath from uiautomatorview open the cmd > uiautomatorviewer

How to find the Webelement or xpath of application using uiautomatorview 

Open application in emulator or in real device and start uiautomatorviewer

Press the Device Screen shot button on top2

uiautomateview

driver.findElement(By.id(“io.selendroid.testapp:id/my_text_field”)).sendKeys(“Test”);

Create Appium First Test project in Eclips (https://www.youtube.com/watch?v=Jgqd7oYWx-Y)

 

uiautomatorview

 

 

public class desiredcapb

{

public AndroidDriver driver;

@Before

public void setUp() throws MalformedURLException

{

File appDir = new Faile(“src”); File app = new File(appDir, “app.apk”); DesiredCapabilities cap = new DesiredCapabilities(); cap.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID); cap.setCapability(MobileCapabilityType.DEVICE_NAME, MobileDevices.find(“emulator-5554”)); cap.setCapability(MobileCapabilityType.APP_PACKAGE, “com.sportlobster.android.debug”); cap.setCapability(MobileCapabilityType.APP_ACTIVITY,”com.sportlobster.android.main.MainActivity”); driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub&#8221;), cap);

}

@Test

public void test() throws Exception { WebElement btn_me = driver.findElement(By.id(“bottomBarMeButton”)); btn_me.click();

}

}

How to find APP_PACKAGE and APP_ACTIVITY for apk file

  1. Download and install SDK.
  2. Inside SDK Manager download Tools (Android SDK build-tools) and APIs for recent versions of Android.
  3. Open SDK folder and go to build-tools folder.
  4. Open any folder (example: 21.1.2).
  5. Open a command prompt window in this folder ( Shift+ right click – Open command window here).
  6. Run command “aapt list -a <path_to_apk_we_need_to_test> >manifest.txt” ( this command will write the app manifest in manifest.txt file inside the same folder).
  7. Open the manifest.txt txt file.
  8. At the beginning of the file there should be details about the package including name ( example: com.example.android.contactmanager).
  9. At the end of the file there should be details about activity including name ( example: ContactManager).

appium3 appium4

OR

Install and Run the application in emulator

Open hierarchyviewer.bat from android-sdk\tools

You can see application APK package and main activity to use in script

Find_APK_Pkg_Activity

OR

from Command prompt – Open your application in Device or in Emulator – type command > adb shell >  dumpsys window windows | grep -E ‘mCurrentFocus|mFocused App’ It will give you your application package and main activity of current applicaton e.x   mCurrentFocus=Window{11266800 u0 com.cns.rd/com.realtydaddy.ui.user.AuthenticationActivity}

So APP_PACKAGE = com.cns.rd and APP_ACTIVITY = com.realtydaddy.ui.user.AuthenticationActivity

@Test
public void ValidLoginTest() throws Exception {
WebElement Login = driver.findElement(By.id(“authActivity_btn_SignIn”));
Login.click();
WebElement LoginUserName = driver.findElement(By.id(“fragSignIn_et_emailOrUserName”));
LoginUserName.sendKeys(“buyer”);
WebElement LoginPassword = driver.findElement(By.id(“fragSignIn_et_password”));
LoginPassword.sendKeys(“admin123”);
WebElement SignIn = driver.findElement(By.id(“fragSignIn_btn_SignIn”));
SignIn.click();

}

Issue : Using uiautomatorviewer to quickly get resource-ids as mention in above code but noticed that sometime resource-id field is no longer present in uiautomatorviewer

Solutions : Visibility of the resource id is dependent on Adnroid version. Its supported from Android version 4.3 or later/ from API level 18.

Reference Tutorial

http://www.guru99.com/introduction-to-appium.html

Posted in Android, Appium | Leave a comment

Agile Scrum with Test Driven Development (TDD)/BDD

I would like to share my new experience in Agile Development which follow the Test Driven Development model. Even after having longer experience in software testing always facing some new challenges when you adopt the new environment, new team and different approach of following development and testing life cycle. But new things always gives new challenges and new challenges always gives your opportunity to learn new things and make you more confident day by day.

First let me brief about Agile Methodology Scrum

Agile_Scrum

In the Scrum team Product Owner, BA, QA, Dev will involved

Epic – Epic define as web application or software or tool or library to develop. For epic we create number of user stories in the product backlog.

Product backlog – prioritize user stories and push stories in Sprint Backlog and define the sprint.

Estimate Sprint – Sprint can be 1 week and maximum of 4 weeks. Estimate the story points. Story points represent the complexity ex. 1 story point for configuration changed, 2 story points for small code change, 3 for small code change, 5 story points for learning, implementation+ Unit Testing, 8 for investigation+ learning, implementation+ Unit Testing, 13 for initial setup for development and so on.

Deliverables – Once sprint is started, during the sprint do standup every day and get status from each development for developing stories. In the standup each developer will quickly share progress, any showstoppers or any dependency with other team members.

Production – In the development environment developer take copy of master development and start developing their assigned stories. At end of development review their code from other developer then marge the code with master code base. marge master code into test environment and start integration, regression and acceptance testing.

In the end once all testcases are successful then deploy delivers into production environment

So, in Production environment the software is not fully development but its working software with limited set of features so at every sprint we get working software with limited features.

End of sprint conduct retrospective What went well, wrong, what shouldn’t be continue or not so it always looks for suggestion for improvement

When the product back log is empty in that case you will get complete fully developed software

Benefits

  • Transparency
  • Early Delivery
  • Easy Estimation
  • Product Backlog Refining/Refactoring
  • Features Prioritization
  • Quality improvement

Challenges

  • Many Developer, One Master Codebase
  • Conflicts/Errors/Bugs
  • External and Internal Dependencies
  • Rework at various stages
  • Inability to design for future requirements
  • Partially ready to use product
  • Quality, Cost, Time and Scope

Approaches like TDD/BDD are used to understand the requirements clearly without any ambiguities and help to write tests in a way that makes code execution successful. These methods enable testers to think of solutions using a bottom up approach that helps prevention of defects in the later stages.This approach also helps clarify any ambiguities in the requirements early on in the software development lifecycle, before coding actually begins.With an increased level of understanding of the features and requirements, developers know what exactly needs to be coded, as also what needs to be included or excluded in the code, thereby preventing leakage of defects into the code in the later phases of development lifecycle.

However, it has been realized that implementation of TDD/BDD practices in the initially slowing down the software development process. but it helps in the maintenance of the code, increases the defect removal efficiency, and also reduces the time to market of the product. The TDD/BDD approach is also best suited for applications where the requirements undergo progressive elaboration. The frequently tested code has lesser defects and enables faster delivery of working software to the clients.

A seamless implementation of both approaches identifies defects early on in the SDLC process, reduce risks, and reduce cost of rework which is a significant cost in software development process. Requirement traceability is also enhanced when test cases are traced back to the requirements giving a picture of test coverage functionally.

Major Benefits

  • Reduce issues/surprises/incidents in the production
  • Help teams stay focused on Continuous Delivery
  • Help teams stay focused on Continuous Delivery
Posted in Agile | Leave a comment