Environment setup for android mobile testing through Emulators in Windows 7
Install
Android Emulator on Windows 7 machine and execute sample script:
Download “SDK ADT bundle for
windows” from following site:http://developer.android.com/sdk/index.html. Then
store this to our C drive.
Ø Starting “Android SDK Manager” and it’s going to install the
packages.
Ø Now we have to select particular version or layer where we are going
to test(Select all check boxes in that version and “install “x” packages as
shows in following screen
Ø Once it is completed then from tools menu select “Manage
AVDs…”. Now we are getting “Android
Virtual Device Manager” window
Ø From above window select “New” Button
Ø Now we will get “Create New Android Virtual Device(AVD)”
window. So create new “AVD” by entering
all fields and click on “OK” button
Ø Now you saw the one virtual AVD which created by you under “AVD
Name”(Android Virtual Device Manager)
Ø Then select “Launch” button.
Finally we are setup “Emulator”.
It looks like in the following figure
Ø It will few minutes to load.
Once it loaded perfectly then unlock it by dragging lock key in emulator
Ø Now minimize all windows and close the Emulator.
Most important part is:
Ø We have to install “apk” file to this Emulator.
Ø Download “android-server-2.32.0.apk” from location
“http://code.google.com/p/selenium/downloads/list”.
Ø Copy the above downloaded file into folder “C:\Program
Files\Android\android-sdk\Platform-tools”
Ø Now run the “Command Prompt” and execute “cd C:\Program
Files\Android\android-sdk\platform-tools”
Ø Then execute the command “adb install android-server-2.32.0.apk”
Ø We also need to ser up Port forwarding, run the command “adb forward
tcp:8080 tcp:8080”
Ø Now click on the WebDriver app on the Emulator and this will make
the android server available at http://localhost:8080/wd/hub
Ø Open this URL in firefox will show up a black page on success
Ø Confirm the following settings on your emulator:
Ø Settings ->Applications->Development Options->Check “USB
debugging”, “Stay Awake” and “Allow mocklocations”.
Ø Now launch Emulator, now you are able to see “WebDriver” installed. When you launch the “WebDriver”
Run the following code from eclipse and
observe the Emulator. The corresponding operations performed.
import junit.framework.TestCase;
import org.openqa.selenium.By;
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 your testing url
driver.get("your testing url");
// Find the text input element by its name
WebElement element = driver.findElement(By.name("searchkeywords"));
// Enter something to search for
element.sendKeys("mobiles");
// 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();
}
}
import org.openqa.selenium.By;
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 your testing url
driver.get("your testing url");
// Find the text input element by its name
WebElement element = driver.findElement(By.name("searchkeywords"));
// Enter something to search for
element.sendKeys("mobiles");
// 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();
}
}
Comments
Post a Comment