Nowadays, compatibility testing is very important and in demand
as it gives the confidence that our application is usable across multiple
platforms.
One of the most used platforms in the world is Mobile. So
the question is whether your application is usable across different Mobile
platforms?
For that matter there are many mobile devices and
platforms like android and iOS in which we can test the compatibility of our
application.
There are n number of Mobile devices available
with x resolutions having y operating systems. So practically,
it’s not feasible to have all the n*x*y number of devices to do a
compatibility test on.
There are again two different ways we look at the mobile compatibility
Using
Mobile WebDriver
As our objective is to test the web application on mobile,
we can either do it on the mobile emulators or on the actual devices.
That’s the reason Mobile simulators have come into the
picture so if I have to test my application on that many devices, I can do it
by simulating the required features.
We have android webdriver which helps us test
the application and run the tests to ensure our website working as expected
when viewed from android browser.
It supports all the core webdrive apis
and many user interactions like taps, flicks, scroll etc. To interact with the
web page android driver uses the native touch and key events.
Step 1:
Download
the android SDK here
Download the Latest ADT bundle from the below Location
System Settings :
Set the ANDROID_HOME
Ex: C:\Android\adt-bundle-windows-x86-20131030\adt-bundle-windows-x86-20131030\sdk
Set Path variable for
the Android
Ex: % ANDROID_HOME%\platform-tools; %ANDROID_HOME%\tools;
Step
2:
Create
an Android virtual device AVD. Follow the instructions given here.
Step 3:
Download the android webdriver apk file (here)
and install on the virtual device using the command below in command prompt
Command:
adb install android-server-2.38.0.apk
Step 4:
To get the
emulators or devices connected
Command: adb devices
List
of devices attached
emulator-5554 device
Start the webdriver app install using the command below
Command:
adb -s emulator-5554
shell am start -a android.intent.action.MAIN -n
org.openqa.selenium.android.app/.MainActivity
Forward the tcp port to send the selenium commands to
emulator
Command: adb –s emulator-5554 forward tcp:8080
tcp:8080
Step 5:
Use
the eclipse and create a Java project
Create
a java class with the below code
import junit.framework.TestCase;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.android.AndroidDriver;
public class OneTest extends TestCase {
public void testGoogle() throws Exception {
WebDriver driver = new AndroidDriver();
// And now use this to visit Google
driver.get("http://www.google.com");
// Find the text input element by its name
WebElement element = driver.findElement(By.name("q"));
// Enter something to search for
element.sendKeys("Selenium Mobile Testing");
// Now submit the form. WebDriver will find the form
for us from the element
element.submit();
// Check the title of the page
System.out.println("Page title is: " +
driver.getTitle());
driver.quit();
}
}
Run the program as simple Junit test, now the application is
opened on the mobile browser and executed
Using
Selendroid WebView
Selendroid is an automation framework which drives of UI
of android native, hybrid and mobile web application tests. It uses JSON Wire
Protocol to run webdriver test scripts on emulators or devices. No modification
or need source code is required to automate application.
Step 1:
Download
the android SDK here
Step
2:
Create
an Android virtual device AVD. Follow the instructions given here.
Step 3:
Download
the Selendroid standalone server jar here
Step 4:
Start the
emulator using AVD manager and to get the emulators or devices connected
Command: adb devices
List
of devices attached
emulator-5554 device
Start the Selendroid server using the below command
Command: java -jar
selendroid-standalone-0.11.0-with-dependencies.jar
The default port the selendroid server runs in 4444. If we want
to change the port use the command
Command: java -jar
selendroid-standalone-0.11.0-with-dependencies.jar – port:5555
Step 5:
Use the eclipse and create a Java project and create a java class
with the below code and configure the build path
Sample
code:
package com.java;
import
io.selendroid.SelendroidCapabilities;
import org.junit.Test;
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 OneTest {
private WebDriver driver = null;
@Test
public void shouldSearchWithEbay() throws InterruptedException {
DesiredCapabilities
capa=DesiredCapabilities.android();
capa.setCapability(SelendroidCapabilities.EMULATOR, true);
driver = new RemoteWebDriver(capa);
// And now use this to visit ebay
driver.get("http://m.ebay.com");
// Find the text input element by its id
WebElement element = driver.findElement(By.id("kw"));
// Enter something to search for
element.sendKeys("Nexus 5");
// Now submit the form. WebDriver will find the
form for us from the element
element.submit();
Thread.sleep(5000);
// Check the title of the page
System.out.println("Page title is: " + driver.getTitle());
driver.quit();
}
}
Result:
Object Identification:
In order to inspect and
identify the elements in the webview we can use the below url to spy on the
objects.
Note: Make sure the selendroid server and emulator or device is up
and running on the specified port. Refer here for more information.
We can even test the native android
apps using selenium. Here we need have the application kit or .apk file of the
application which we need to test
By
Automation Mentor
www.automationmentor.in
Automation Mentor
www.automationmentor.in
We provide hands-on training on automation tools and frameworks
Interesting blog and I really like your work and must appreciate you work for the packaging machine keep posting,
ReplyDeletecannabis packaging machine
Existing without the answers to the difficulties you’ve sorted out through this guide is a critical case, as well as the kind which could have badly affected my entire career if I had not discovered your website.
ReplyDeletefull Stack developer Training in Bangalore
I wish to show thanks to you just for bailing me out of this particular trouble.As a result of checking through the net and meeting techniques that were not productive, I thought my life was done
ReplyDeletefull Stack developer Training in Bangalore
It is amazing and wonderful to visit your site.Thanks for sharing this information,this is useful to me...
ReplyDeleteClick here:
python training in chennai
Click here:
python training in tambaram
Its really an Excellent post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog. Thanks for sharing....
ReplyDeleteBlueprism training in velachery
Blueprism training in marathahalli
AWS Training in chennai
Your very own commitment to getting the message throughout came to be rather powerful and have consistently enabled employees just like me to arrive at their desired goals.
ReplyDeleteData Science with Python training in chenni
Data Science training in chennai
Data science training in velachery
Data science training in tambaram
Data Science training in anna nagar
Data Science training in chennai
Data science training in Bangalore
A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article. I am learning a lot from you.
ReplyDeletejava training in jayanagar | java training in electronic city
java training in chennai | java training in USA
Some us know all relating to the compelling medium you present powerful steps on this blog and therefore strongly encourage contribution from other ones on this subject while our own child is truly discovering a great deal. Have fun with the remaining portion of the year.
ReplyDeleteangularjs Training in bangalore
angularjs Training in bangalore
angularjs Training in btm
angularjs Training in electronic-city
angularjs online Training
All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates.
ReplyDeletepython training in pune | python training institute in chennai | python training in Bangalore
Thanks for the great blog! keep posting.
ReplyDeleteselenium training in tambaram
selenium training in adyar
iOS Training in Chennai
French Classes in Chennai
Big Data Training in Chennai
java certification training in chennai
best java training
java j2ee training
I'm glad that I came across your post! Keep blogging. Regards.
ReplyDeleteTally Course in Chennai | Tally Classes in Chennai | Tally Training in Chennai | Tally Course | Learn Tally | Tally Institute in Chennai | Learn Tally ERP 9 | Tally Training | Tally Training Institute in Chennai
Appreciating the persistence you put into your blog and detailed information you provide
ReplyDeleteMicrosoft Azure online training
Selenium online training
Java online training
Java Script online training
Share Point online training
I never stop myself to say something about your post such a very interesting and helpful.thanks!!!
ReplyDeleteandroid training in chennai
android online training in chennai
android training in bangalore
android training in hyderabad
android Training in coimbatore
android training
android online training
This post is so interactive and informative.keep update more information...
ReplyDeleteBenefits of PHP for Online Businesses
Advantages of PHP for Online Businesses
This post is so interactive and informative.keep update more information...
ReplyDeleteAndroid Training in Tambaram
Android Training in Chennai
This comment has been removed by the author.
ReplyDelete