About Selendroid :
Selendroid is an open source automation framework which drives of UI of android native, hybrid and mobile web application.
It supports both emulator and real device. It uses Json Wire Protocol to run webdriver test scripts on device.
It can be integrated with selenium grid for parallel execution on multiple nodes.
No need any modification in application and not need source code to automate application.
Prerequisites:
1.JDK should be installed and java home path setup in your machine.
2.Android SDK should be installed on your machine and android path should be setup in your machine
5.Eclipse.
6.Create new Emulator or attached real devices with you machine.
Run Server:
Open command prompt and go to downloaded Selendroid jar file and run below command
1
java -jar selendroid-standalone-0.9.0-with-dependencies.jar -aut resigned-selendroid-test-app-0.9.0.apk
Where selendroid-standalone-0.9.0-with-dependencies.jar is downloaded selendroid jar file and resigned-selendroid-test-app-0.9.0.apk application apk file name.
Check server status
Step to create test script:
1.Create a java project in eclipse.
2.Add selenium and selendroid jar file in eclipse environments:
3.Create package “com.test“ and add java file “SelendroidTest.java” with below code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package com.test;
import io.selendroid.SelendroidCapabilities;
import io.selendroid.SelendroidConfiguration;
import io.selendroid.SelendroidDriver;
import io.selendroid.SelendroidLauncher;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.testng.Assert;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
public class SelendroidTest {
private WebDriver driver ;
@BeforeSuite
public void setUp() throws Exception
{
SelendroidConfiguration config = new SelendroidConfiguration();
config.addSupportedApp("selendroid-test-app-0.9.0.apk");
SelendroidLauncher selendroidServer = new SelendroidLauncher(config);
selendroidServer.lauchSelendroid();
SelendroidCapabilities caps = new SelendroidCapabilities("io.selendroid.testapp:0.9.0");
driver = new SelendroidDriver(caps);
}
@Test
public void selendroidTest() throws Exception
{
WebElement inputField = driver.findElement(By.id("my_text_field"));
Assert.assertEquals("true", inputField.getAttribute("enabled"));
inputField.sendKeys("Selendroid");
Assert.assertEquals("Selendroid", inputField.getText());
//click EN butoon
WebElement button = driver.findElement(By.id("buttonTest"));
button.click();
//click accept button
button = driver.findElement(By.id("button2"));
button.click();
Thread.sleep(5000);
//click on registration button
button = driver.findElement(By.id("startUserRegistration"));
button.click();
Thread.sleep(10000);
// fill registration form data
WebElement element = driver.findElement(By.id("label_username"));
String text = element.getText();
System.out.println(text);
element = driver.findElement(By.id("inputUsername"));
element.sendKeys("bob");
element = driver.findElement(By.id("inputEmail"));
element.sendKeys("test@gmail.com");
element = driver.findElement(By.id("inputPassword"));
element.clear();
element.sendKeys("test1233");
element = driver.findElement(By.id("inputName"));
element.clear();
element.sendKeys("My Name ");
element = driver.findElement(By.id("input_preferedProgrammingLanguage"));
element.click();
element = driver.findElement(By.id("text1"));
element.click();
element = driver.findElement(By.id("input_adds"));
element.click();
element = driver.findElement(By.id("btnRegisterUser"));
element.click();
element = driver.findElement(By.id("buttonRegisterUser"));
element.click();
}
@AfterSuite
public void tearDown(){
driver.quit();
}
}
Post a Comment
Post a Comment