TESTEVERYTHING

Thursday, 5 March 2015

Scrolling web page with Webdriver using java

We can scroll the web page using javaScript Executor or You can use the "org.openqa.selenium.interactions.Actions" class to move to an element:


Following classes you required in you java code
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement;
import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.JavascriptExecutor;

1. We may require to scroll to bottom of the page and then perform operations. For this scenario we can use following code
((JavascriptExecutor) driver).executeScript("window.scrollTo(0, document.body.scrollHeight)");

2. Some times, we may require to scroll to particular element and peform operations on that particular element. For this we need to pass the element on which we need to perform operation. For this scenario we ca use following code
WebElement element = driver.findElement(By.linkText("googleMap")); ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", element);
OR
WebElement element = driver.findElement(By.id("my-id"));
Actions actions = new Actions(driver);
actions.moveToElement(element);
actions.perform();

3. We can also use the coordinates to scroll to particular position by passing the coordinates. For this scenario we use following code
((JavascriptExecutor) driver).executeScript("window.scrollBy(0,500)");

Wednesday, 11 February 2015

How to Re-Sign an iOS App from an External Developer/



iReSign allows iDevice app bundles (.ipa) files to be signed or resigned with a digital certificate from Apple for distribution. This tool is aimed at enterprises users, for enterprise deployment, when the person signing the app is different than the person(s) developing it.


If you ever work with 3rd party developers, you know that getting the final project into production can take two different routes. You can either let the developer push the code/project into production or they hand it over to your internal team to release. There are pros and cons for each, but I always prefer to publish things ourselves since it reduces security concerns and gives us more control. The Apple App Store is no different, and it is actually really simple to take a developer app and turn it into an App Store version for submission.

Note: You can use this exact same process to resign the app to your developer certificate and profile, so you can install it on your own registered developer devices.

Step 1: Pull the latest iResign code from Github “$ git clone https://github.com/maciekish/iReSign.git”

Step 2: Build the code from Xcode

Step 3: In the window that appears “Enter the path to valid provisioning profile”, “Leave the fields to .plist file blank” and “Enter the build identifier from application”

Step 4: From the drop-down "Select valid developer profile” and click on "ReSign!” button.



Note: Resigned file will be saved to same directory as of original application.

Advantage:


  • We now have to ask from client just .ipa file for automating on iOS platform, same as we require just .apk file for automating on android platform

Refer the below link for more reference

https://github.com/maciekish/iReSign

http://dev.mlsdigital.net/posts/how-to-resign-an-ios-app-from-external-developers/


Tuesday, 13 January 2015

HOW TO INSTALL PLUGINS IN JENKINS

HOW TO INSTALL PLUGINS IN JENKINS

1.       Navigate to manage Plugins page.

Jenkins>Manage Jenkins>Manage plugins




2.       Select available tab and type plugin name in search field.


                          Buy Mobiles & Tablets from Amazon


HOW TO UNINSTALL JENKINS

How to uninstall Jenkins on Mac system

1.    Execute from terminal
          /Library/Application Support/Jenkins/Uninstall.command
2.    Or use Finder to navigate into that folder and double-click on Uninstall.command.
3.    If the uninstallation script cannot be found, use:
      sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
      sudo rm /Library/LaunchDaemons/org.jenkins-ci.plist
      sudo rm -rf /Applications/Jenkins "/Library/Application Support/Jenkins"     /Library/Documentation/Jenkins
4.    if you want to get rid of all the jobs and builds:
  sudo rm -rf /Users/Shared/Jenkins
5.  to delete the jenkins user and group (if you chose to use them):
       sudo dscl . -delete /Users/jenkins
       sudo dscl . -delete /Groups/jenkins


  Baby Products

Wednesday, 7 January 2015

To know all devices connected to machines / simulator information on mac machine

Open the terminal type following command:

$ instruments -s deivces


Known Devices:
mobileQA’s Mac mini [303FD57A-BA31-5AF8-BBC4-85D1F3FF38A3]
Resizable iPad (8.0 Simulator) [5C7AFC61-6B75-49DE-9B28-4CCD125A1F24]
Resizable iPhone (8.0 Simulator) [D88F397A-98B4-4CE7-A625-230A56730086]
iPad 2 (7.0.3 Simulator) [C2C72D3E-147C-4796-90DD-682E4DBD469E]
iPad 2 (7.1 Simulator) [696557BE-7723-49A3-ADA6-46090B2576FB]
iPad 2 (8.0 Simulator) [3395DD16-17E6-4A69-BAB2-D7414759E04B]
iPad Air (7.0.3 Simulator) [1432341A-C3DD-47B8-95D4-5F17C08BF4A7]
iPad Air (7.1 Simulator) [14C9A977-4D56-404A-897F-F5DE8F5F7208]
iPad Air (8.0 Simulator) [F92E44D9-8E3F-43D2-9124-00C688126AED]
iPad Retina (7.0.3 Simulator) [4FFA8E0D-290A-47BB-B7D6-806641AFAEF7]
iPad Retina (7.1 Simulator) [76F3CC43-0E3A-4ADD-9520-AA1E20F8DD71]
iPad Retina (8.0 Simulator) [DC9C5DFA-988B-40A5-8E81-3F3FB0D11043]


 

Wednesday, 17 December 2014

Mac terminal cursor commands

·         Meta-d to delete a word starting from the current cursor position
·         Ctrl-a to jump to start of the line
·         Ctrl-e to jump to end of the line
·         Ctrl-k to kill the line starting from the cursor position
·         Ctrl-y to paste text from the kill buffer
·         Ctrl-r to reverse search for commands you typed in the past from your history
·         Ctrl-s to forward search (works in zsh for me but not bash)
·         Ctrl-f to move forward by a char

·         Ctrl-b to move backward by a char

Automation Testing of Android app on device using Appium


1)      Run the setup using the below provided location using the URL as :
and click on installer_r24.0.1-windows.exe for windows.

2)      Agree to the terms of service and licence from google and download the installer.
3)      Download the Appium for windows latest version from http://appium.io/ .
4)      Download java-client version for the same latest from location http://appium.io/downloads.html
5)      Set ANDROID_HOME as environment variable providing the path for the SDK till the SDK path
6)      Set the path for platform tools and tools folder specifically like below :
D:\Mobiletesting\MobileSDK\sdk\platform-tools;D:\Mobiletesting\MobileSDK\sdk\tools;




7)      Once the path for tools and platform-tools is set check if the configurations are correct by opening the command prompt and entering the command as
adb devices
If the configurations are correct then the device will be listed as a result of the response for command as above in the screen.
List of devices attached
ZX1B32DBJ3      device
Here ZX1B32DBJ3       is the device connected to the 32 bit machine having SDK setup.
8)      Have an apk file of the application to be tested ready and open appium.exe by running the utility for launching the appium window.
9)      Configure Appium like in the below screenshot :
Application path: Path for the apk file to be tested.
Other fields such as package,launch activity platform version ,automation name,device name all fields will be populated by default.
 
Click on start the appium node server button at the right corner of the window and we can see the below mentioned activity listed when the server is launched.
 
Create a java project using the Android eclipse toolkit and set the properties such as below.

package com.testng;

import io.appium.java_client.AppiumDriver;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.junit.AfterClass;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;

public class  WhatsApp {


WebDriver dr;
   
@Test
public void testApp() throws Exception
{
    //WebDriver dr;
    String contact ="shreekantpandey@gmail.com";
    File app = new File("D:\\Mobiletesting\\WhatsApp.apk");
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("browserName","Chrome");
    capabilities.setCapability("deviceName","ZX1B32DBJ3");
    capabilities.setCapability("platformVersion","4.4");
    capabilities.setCapability("platformName", "Android");
    //capabilities.setCapability("app",app.getAbsolutePath());
    //capabilities.setCapability("appPackage","com.testng");
    //capabilities.setCapability("appActivity","com.testng.WhatsApp");
   
    dr= new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    dr.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
   
    dr.get("http://www.apple.com");
   
    dr.quit();

   
}
@AfterClass
public void teardown(){
    //close the app
    dr.quit();
}
}



Where details specific to device and platform are :

DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("browserName","Chrome");
    capabilities.setCapability("deviceName","ZX1B32DBJ3");
    capabilities.setCapability("platformVersion","4.4");
    capabilities.setCapability("platformName", "Android");


and driver are :

dr= new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    dr.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);


Once we have the browser handle we can navigate to any page of our choice like the content here being navigated to
dr.get("http://www.apple.com");

___________________________________________________


2. For Android application related project creation having a launching activity are:
package com.testng;

import io.appium.java_client.AppiumDriver;
import java.io.File;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.junit.AfterClass;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class  NewClass {


WebDriver dr =null;
   
@BeforeMethod
public void setup() throws Exception

{
     File appDir = new File("D://Mobiletesting");
     File app = new File(appDir, "MakeMyTrip_Flights_Hotels_Bus.apk");
     
     
     DesiredCapabilities capabilities = new DesiredCapabilities();
     capabilities.setCapability("app-package", "com.makemytrip");
     capabilities.setCapability("app-wait-activity", "com.mmt.ui.activity.Splashactivity");
     capabilities.setCapability("app-activity", "com.mmt.ui.activity.Splashactivity");
  
    capabilities.setCapability("deviceName","ZX1B32DBJ3");
    capabilities.setCapability("platformVersion","4.4");
    capabilities.setCapability("platformName", "Android");
  
   
    //capabilities.setCapability("browserName","Chrome");

    //capabilities.setCapability("app-activity","com.mmt.ui.activity.Splashactivity");
//    capabilities.setCapability("app",app.getAbsolutePath());
//    capabilities.setCapability("appPackage","com.makemytrip");

   
    dr= new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    dr.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
   
}
@Test
public void loginTest() throws Exception {
    String text;   
    Thread.sleep(5000);

       
     
      dr.findElement(By.className("android.widget.Button")).click();
     
      dr.findElement(By.id("com.makemytrip:id/login_activity_emailId_edt")).sendKeys("shreekant1282@gmail.com");
      dr.findElement(By.id("com.makemytrip:id/login_activity_password_edt")).sendKeys("3093005");
      //dr.findElement(By.id("id/login_activity_password_edt")).sendKeys("3093005");
      dr.findElement(By.id("com.makemytrip:id/login_activity_login_btn")).click();
      WebDriverWait wait = new WebDriverWait(dr,80);
      text = dr.findElement(By.className("android.widget.TextView")).getText();
      if (text.equals("User not valid!"))
      {
          System.out.println("test passed");
      }
      else
      {
          System.out.println("test failed");
      }
      //dr.quit();

      }
@AfterTest
public void teardown(){
    //close the app
    dr.quit();
    //dr.close();
}
}

Where details are for same device but with different .apk file having different launching activity as in the screenshot below.




Sample makemytrip.apk file can be downloaded from anywhere over the internet.


    

Translate







Tweet