How to find app package name from android device??

1)We can connect your device to system via USB and execute "adb shell pm list packages -3" on cmd
2)We can install following android app to get all package name which installed into device
"ÄppInfo"d

Selenium Wait Types

1)Explicit wait
  try {
        driver.findElement(By.linkText("data")).click();
        WebElement message = new WebDriverWait(driver, 5)
 .until(new ExpectedCondition() 
       {
   public WebElement apply(WebDriver d) 
             {
         return d.findElement(By.id("page4"));
      }
       });
       assertTrue(message.getText().contains("message"));
       } finally {
           driver.quit();
       }

2)Implicit Wait
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

How to executes script on different browser?

1) In Mozilla Firefox
   driver = new FirefoxDriver();
2)In Chrome 
   System.setProperty("webdriver.chrome.driver",Add absolute path of chromedriver.exe");
   driver = new ChromeDriver();
3) In IE
   System.setProperty("webdriver.ie.driver","Add absolute path of IEDriverServer.exe");
   driver = new InternetExplorerDriver();
4) In Edge
   System.setProperty("webdriver.edge.driver",Add absolute path of MicrosoftWebDriver.exe");
   EdgeOptions options = new EdgeOptions();
   options.setPageLoadStrategy("eager");
   driver = new EdgeDriver(options);
5) In Opera
   System.setProperty("opera.binary", Add absolute path of opera.exe");
   WebDriver driver = new OperaDriver();
6) In Safari
   System.setProperty("SafariDefaultPath", Add absolute path of Safari.exe");
   WebDriver driver = new SafariDriver();


Best Webdriver Methods tutorial

Genymotion

Best Appium - Selenium Webdriver - Java Tutorial

Mobile Automation Testing using APPIUM, Selenium Webdriver and Java

All things mentioned below is considering Windows 10.
Prerequisite
1)Download and Install JavaDownload here
2)Download and Install eclipseDownload here
3)Download and Install Node JSDownload here
4)Download and Install Android SDK(android-studio-ide-143.3101438-windows.exe) and keep it under C:\ Download here
5)Download and Install Selenium Webdriver(Selenium Standalone Server)Download here
6)Download and Install Appium Java Client Lib(jar)Download here
7)Download and Install APPIUM for Windows(Appium.exe for Windows)Download here

Setup Environment Variable:-
 User Variables:-
 Start->Control Panel\All Control Panel Items\System->Advance system setting->Environments variables->User Variables->New
  for Android:- Variable name: ANDROID_HOME and Variable value:C:\SDK\android-sdk-windows
  for APPIUM:- Variable name: APPIUM and Variable value:C:\Appium\node_modules\.bin
  for Java:- Variable name: JAVA_HOME and Variable value:C:\Program Files\Java\jdk1.8.0_101

 System Variables:-
 Start->Control Panel\All Control Panel Items\System->Advance system setting->Environments variables->system Variables->New
  for Android:- Variable name: ANDROID_HOME and Variable value:C:\SDK\android-sdk-windows
  for APPIUM:- Variable name: APPIUM and Variable value:C:\Appium\node_modules\.bin
  for Java:- Variable name: JAVA_HOME and Variable value:C:\Program Files (x86)\Java\jre1.8.0_101\
  for ADB:- Variable name: ADB_HOME and Variable value:C:\adb.exe

 Set Path:-
  C:\Program Files\nodejs\
  C:\Program Files (x86)\Java\jre1.8.0_101\bin
  C:\Program Files\nodejs\node_modules\.bin
  %APPIUM%
  C:\SDK\android-sdk-windows
  C:\SDK\android-sdk-windows\tools
  C:\SDK\android-sdk-windows\tools\bin
  C:\adb.exe

For TestNG:
  Start eclipse->Help->Install New Software->Works With
     Name:- TestNG
     Location:-Update site for release: http://beust.com/eclipse.
                         Or
     Update site for beta: http://testng.org/eclipse-beta
  Tick checkboxes and follow steps

Start First APPIUM Test for Android Native App
 1)Start Eclipse, Create new java project (File->New->Other->Java Project->Enter Project name
 2)Add Selenium and TestNG Jar( right click on project folder->build Path->Configure build path->Libraries->Add 
 external jars (browse your jar files form computer(java-client-3.2.0 and selenium-server-standalone-3.0.0-beta2 JAR files)
 3)Add TestNG JAR( right click on project folder->build Path->Configure build path->Libraries->Add Library ->select 
 TestNG Lib and follow steps.
 4)Create Java class file(Right Click on Project Folder->New->Class->Enter Package and Class name)
 5) Write following code for first Test Case for App Orientation check (Make Sure Twitter app should be installed into 
 Your Android Devices)
 Demo Code
        package example;

        import io.appium.java_client.android.AndroidDriver;
        import java.io.IOException;
        import java.net.MalformedURLException;
        import java.net.URL;
        import java.util.concurrent.TimeUnit;
        import org.apache.commons.exec.CommandLine;
        import org.apache.commons.exec.DefaultExecuteResultHandler;
        import org.apache.commons.exec.DefaultExecutor;
        import org.openqa.selenium.remote.DesiredCapabilities;
        import org.testng.Assert;
        import org.testng.annotations.AfterTest;
        import org.testng.annotations.BeforeTest;
        import org.testng.annotations.Test;
        
        public class CheckElementPresent 
        {
        AndroidDriver driver;

              @BeforeTest
              public void setUp() throws MalformedURLException 
              {
                   DesiredCapabilities capabilities = new DesiredCapabilities();
                   capabilities.setCapability("deviceName", "VPK");
                   capabilities.setCapability("browserName", "Android");
                   capabilities.setCapability("platformVersion", "5.2");
                   capabilities.setCapability("platformName", "Android");
                   capabilities.setCapability("appPackage", "com.twitter.android");
                   capabilities.setCapability("appActivity","com.twitter.android.LoginActivity");
                   driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
                   driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
              }

              @Test
              public void performOrientation() throws InterruptedException 
              {
     
                   System.out.println("Current screen orientation Is : " + driver.getOrientation());
                   driver.rotate(org.openqa.selenium.ScreenOrientation.LANDSCAPE);
                   System.out.println("Now screen orientation Is : "+ driver.getOrientation());
                   Thread.sleep(5000);
                   System.out.println("Changing screen Orientation to PORTRAIT.");
                   driver.rotate(org.openqa.selenium.ScreenOrientation.PORTRAIT);
                   System.out.println("Now screen orientation Is : "+ driver.getOrientation());
                   Thread.sleep(5000);
              }
 
              @AfterTest
              public void End() throws IOException 
              {
  
                   driver.quit();  
  
              }
        }

  Note(to find App Activity and package name install APK Info appDownload here

How to run:
 1) Right click on code area->Run As-> TestNG Test (Before run it start your appium server and connect your device to 
 computer   via usb(make sure device connected))
 You will get result.(To view HTML result , just right click on project folder->refresh and view test-output 
 folder->open index.html file in browser.


For Appium Setting:-Launch Appium server
  Condition 1(If already present into device):
  
  1)Click Android icon->make sure all fields are unchecked 
  2)Click on setting icon-> make sure server address: 127.0.0.1 and Port:4730

  Condition 2(If apk file present into computer):

  1)Click Android icon->Add Applicatipn Path then we will get package and Activity name automatically
  2)Click on setting icon-> make sure server address: 127.0.0.1 and Port:4730

  Click on Launch Button before executes your test script


For Inspect app  Elements use UI Automator
  Path:-C:\SDK\android-sdk-windows\tools open uiautomatorviewer.bat (make sure adb installed properly and devices 
  should be connected to computer)

For Share Mobile screen on Computer. Just Open JAR Download here

Mobile devices screen sizes

How to run apk

Appium Environment Setup

  1. Appium Basics
  2. Appium from begining
  3. Appium Reference url1
  4. Appium Reference url2
Appium Reference url3
Appium Envirnoment setup
Following things need to be installed:- 
1)Java
2)ant
3)maven
4)Node JS
5)GIT
6)cURL
7)UI Automator Viewer
8)Android Studio

Appium for Ubuntu

Testing MindMap and Timer

Appium Tutorial

APPIUM is a freely distributed open source mobile application UI testing 
framework.
Appium allows native, hybrid and web application testing and supports automation
test on physical devices as well as on emulator or simulator both.

It offers cross-platform application testing i.e. single API works for both A
ndroid and iOS platform test scripts.

It has NO dependency on Mobile device OS. Because, APPIUM has framework or 
wrapper that translate Selenium Webdriver commands into UIAutomation (iOS) 
or UIAutomator (Android) commands depending on the device type not any OS type.

Appium supports all languages that have Selenium client libraries like- Java, 
Objective-C, JavaScript with node.js, PHP, Ruby, Python, C# etc. 

Appium Official Page

Limitations using APPIUM

    Appium does not support testing of Android Version lower than 4.2
    Limited support for hybrid app testing. eg: not possible to test the switching 
    action of application from the web app to    native and vice-versa.
    No support to run Appium Inspector on Microsoft Windows.


Prerequisite to use APPIUM(Windows)

    ANDROID SDK Link
    JDK (Java Development Kit) Link
    TestNG Link
    Eclipse Link
    Selenium Server JAR Link
    Webdriver Language Binding Library Link
    APPIUM For Windows Link
    APK App Info On Google Play Link
    Node.js (Not Required - Whenever Appium server is installed, it by default 
    comes with "Node.exe" & NPM. It's included in Current version of Appium.)


Prerequisite to use APPIUM(MAC OS)

    
    JDK (Java Development Kit) Link
    Xcode 
    Command Line tools 
    APPIUM For MAC OS Link
    Node.js (Not Required - Whenever Appium server is installed, it by default 
            comes with "Node.exe" & NPM. It's included in Current version of Appium.)


APPIUM Inspector:-

Similar to Selenium IDE record and playback tool, Appium has an 'Inspector' to
record and Playback. It records and plays native application behavior by inspecting 
DOM and generates the test scripts in any desired language. However, currently there 
is no support for Appium Inspector for Microsoft Windows. In Windows, it launches the 
Appium Server but fails to inspect elements. However, UIAutomator viewer can be used 
as an option for Inspecting elements. 


UIAutomatorviewer to inspect android app elements



Download Android SDK->android-sdk_r24.4.1-windows.zip

Then Follow Path ex C:\android-sdk_r24.4.1-windows\android-sdk-windows\tools\uiautomatorviewr.bat  Run this bat file

While using uiautomatorviewer , always open app into mobile device and adb should be installed into computer system

Why APPIUM??

Why Automation Testing Require.
1)Automate your testing procedure when you have lot of regression work.
2)Automate your load testing work for creating virtual users to check load
 capacity of your application.
3)Automate your testing work when your GUI is almost frozen but you have lot 
  of frequently functional changes.
------------------------------------------------------------------------------
Appium is an open-source tool for automating native, mobile web, and hybrid
applications on iOS and Android platforms. Native apps are those written 
using the iOS or Android SDKs. Mobile web apps are web apps accessed using
a mobile browser (Appium supports Safari on iOS and Chrome or the built-in 
‘Browser’ app on Android). Hybrid apps have a wrapper around a “webview” – 
a native control that enables interaction with web content. Projects like
Phonegap, make it easy to build apps using web technologies that are then 
bundled into a native wrapper, creating a hybrid app.
Importantly, Appium is “cross-platform”: it allows you to write tests against
multiple platforms (iOS, Android), using the same API. This enables code reuse
between iOS and Android testsuites.
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).
---------------------------------------------------------------------------------
Appium Philosophy
Appium was designed to meet mobile automation needs according to a philosophy 
outlined by the following four tenets:

    1)You shouldn’t have to recompile your app or modify it in any way in order
      to automate it.
    2)You shouldn’t be locked into a specific language or framework to write and 
      run your tests.
    3)A mobile automation framework shouldn’t reinvent the wheel when it comes to 
      automation APIs.
    4)A mobile automation framework should be open source, in spirit and practice 
      as well as in name!

--------------------------------------------------------------------------------
Appium Design
We don’t need to compile in any Appium-specific or third-party code or frameworks 
to your app. This means you’re testing the same app you’re shipping. The vendor-provided 
frameworks we use are:

    1)iOS: Apple’s UIAutomation
    2)Android 4.2+: Google’s UiAutomator
    3)Android 2.3+: Google’s Instrumentation. (Instrumentation support is provided by 
      bundling a separate project, Selendroid)

-----------------------------------------------------------------------------------
Reference Links for APPIUM :-
  1. software-testing-tutorials-automation
  2. software-testing-tutorials-automation
  3. 3pillarglobal
  4. guru99
  5. seleniumhq
  6. appium.io

APPIUM Advantages and Disadvantages


APPIUM Advantages:

    Open source (free)  
    Cross-platform  
    Supports automation of hybrids, native and webapps
    Supports any programming languages.
    Support for various frameworks.
    Doesn't require an APK for use,although automating certain apps do.
    Backend is Selenium so u will get all selenium functionality.Selenium webdriver compatible.
    Supports any programming languages.
    Commonly used programming API's can be integrated.
    Can run app through appium server without manipulating the app.
    CI compatible with jenkins, saucelabs(so far from my experience)
    Able to run on selenium grid.
    Doesn't require access to your source code or library. You are testing with which you will 
        actually ship.
    
APPIUM Disadvantage:

    Doesn't support image comparison.
    Limited support for Android < 4.1
    Under Developing stage can't use for big project initially
    Appium documentation is a little weak
    Less availability of tutorial

Why automation required?


Why Automation Testing Require.
1)Automate your testing procedure when you have lot of regression work.
2)Automate your load testing work for creating virtual users to check load capacity of your 
  application.
3)Automate your testing work when your GUI is almost frozen but you have lot of frequently 
  functional changes.

What are the Risks associated in Automation Testing?
1) Do you have skilled resources? 
2) Initial cost for Automation is very high:
3) Do not think to automate your UI if it is not fixed
4) Is your application is stable enough to automate further testing work?
5) Are you thinking of 100% automation?
6) Do not automate tests that run once
7) Will your automation suite be having long lifetime?

Automation provides three business benefits:
1)Increased testing efficiency,
2)Increased testing effectiveness,
3)Faster time to market.

Mobile App Automation tools comparism


Share Mobile screen on PC


  Reference video/a>
  
  https://github.com/Genymobile/scrcpy
  
  Install scrcpy throguh terminal on macbook
  then just hit following command and then u will get your screen on macbook
  
  scrcpy
  

  Note:- ADB should be installed into your macbook to get android device
  

Best Appium Tutorial

Mobile App Test Cases

Andorid 7.0 Nougat Features

1)Over 1500 emoji including 72 new ones
2)Multi Locale language setting
3)Now you can switch between apps with a double tap, and run two apps side by side. 
  So go ahead and watch a movie while texting, or read a recipe with your timer open.
  a)Multi-window view
  b)Quick switch between apps
4)Vulkan™ API is a game changer with high-performance 3D graphics. On supported devices,
  see apps leap to life with sharper graphics and eye-candy effects.
5)With Virtual Reality mode, Android Nougat is ready to transport you to new worlds. 
6)Doze now helps save battery power even when you're on the move. So your device will 
  still go into low power usage while you carry it in your pocket or purse.
7)Custom Quick Settings:-Rearrange your Quick Setting tiles so you can get to what you 
  want faster.
8)Notification Direct Reply:-Mini conversations within your notifications let you reply 
  on the fly – without opening any app.
9)Bundled Notifications:-See what's new at a glance with bundled notifications from apps. 
  Simply tap to expand and view more info without having to open the app.
10)Data Saver:-Limit how much data your device uses with Data Saver. When Data Saver is 
  turned on, apps in the background won't be able to access cell data.
11)Notification Controls:-When a notification pops up, just press and hold to toggle the 
  settings. For instance, you can silence future alerts from an app in the notification itself.
12)Display Size:-Not only can you change the size of the text on your device, but the size 
  of the icons and the experience itself.
13)Seamless Updates:-On select new devices, software updates download in the background, 
  so you won't have to wait while your device syncs with the latest security tools.
14)File-based Encryption:-By encrypting at the file level, Android can better isolate 
  and protect files for individual users on your device.
15)Direct Boot:-Starting your device is faster and apps run securely even before you enter 
  your password.

Mobile testing Negative

First Appium code and environment

Why APPIUM??

Why Automation Testing Require.
1)Automate your testing procedure when you have lot of regression work.
2)Automate your load testing work for creating virtual users to check load
 capacity of your application.
3)Automate your testing work when your GUI is almost frozen but you have lot 
  of frequently functional changes.
------------------------------------------------------------------------------
Appium is an open-source tool for automating native, mobile web, and hybrid
applications on iOS and Android platforms. Native apps are those written 
using the iOS or Android SDKs. Mobile web apps are web apps accessed using
a mobile browser (Appium supports Safari on iOS and Chrome or the built-in 
‘Browser’ app on Android). Hybrid apps have a wrapper around a “webview” – 
a native control that enables interaction with web content. Projects like
Phonegap, make it easy to build apps using web technologies that are then 
bundled into a native wrapper, creating a hybrid app.
Importantly, Appium is “cross-platform”: it allows you to write tests against
multiple platforms (iOS, Android), using the same API. This enables code reuse
between iOS and Android testsuites.
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).
---------------------------------------------------------------------------------
Appium Philosophy
Appium was designed to meet mobile automation needs according to a philosophy 
outlined by the following four tenets:

    1)You shouldn’t have to recompile your app or modify it in any way in order
      to automate it.
    2)You shouldn’t be locked into a specific language or framework to write and 
      run your tests.
    3)A mobile automation framework shouldn’t reinvent the wheel when it comes to 
      automation APIs.
    4)A mobile automation framework should be open source, in spirit and practice 
      as well as in name!

--------------------------------------------------------------------------------
Appium Design
We don’t need to compile in any Appium-specific or third-party code or frameworks 
to your app. This means you’re testing the same app you’re shipping. The vendor-provided 
frameworks we use are:

    1)iOS: Apple’s UIAutomation
    2)Android 4.2+: Google’s UiAutomator
    3)Android 2.3+: Google’s Instrumentation. (Instrumentation support is provided by 
      bundling a separate project, Selendroid)

-----------------------------------------------------------------------------------
Reference Links for APPIUM :-
software-testing-tutorials-automation
software-testing-tutorials-automation
3pillarglobal
guru99
seleniumhq
appium.io
    



Appium Tutorial

APPIUM is a freely distributed open source mobile application UI testing 
framework.
Appium allows native, hybrid and web application testing and supports automation
test on physical devices as well as on emulator or simulator both.

It offers cross-platform application testing i.e. single API works for both A
ndroid and iOS platform test scripts.

It has NO dependency on Mobile device OS. Because, APPIUM has framework or 
wrapper that translate Selenium Webdriver commands into UIAutomation (iOS) 
or UIAutomator (Android) commands depending on the device type not any OS type.

Appium supports all languages that have Selenium client libraries like- Java, 
Objective-C, JavaScript with node.js, PHP, Ruby, Python, C# etc. 

Appium Official Page

Limitations using APPIUM

    Appium does not support testing of Android Version lower than 4.2
    Limited support for hybrid app testing. eg: not possible to test the switching 
    action of application from the web app to    native and vice-versa.
    No support to run Appium Inspector on Microsoft Windows.


Prerequisite to use APPIUM(Windows)

    ANDROID SDK Link
    JDK (Java Development Kit) Link
    TestNG Link
    Eclipse Link
    Selenium Server JAR Link
    Webdriver Language Binding Library Link
    APPIUM For Windows Link
    APK App Info On Google Play Link
    Node.js (Not Required - Whenever Appium server is installed, it by default 
    comes with "Node.exe" & NPM. It's included in Current version of Appium.)


Prerequisite to use APPIUM(MAC OS)

    
    JDK (Java Development Kit) Link
    Xcode 
    Command Line tools 
    APPIUM For MAC OS Link
    Node.js (Not Required - Whenever Appium server is installed, it by default 
            comes with "Node.exe" & NPM. It's included in Current version of Appium.)


How to provide path to APPIUM Java code

Option 1:-
capabilities.setCapability("app","Application absolute path");

Option 2:-
Add application into appium->setting->path

Option 3:-
File appDir=new File("Application Path");
File app = new File(appDir, "apk name");
cap.setCapability("app", "apk name");

Option 4:- Remove app from device( Use it before quit server)
driver.removeApp("application package name");