这里有人能帮我建立一个集成Appium工具的自动化测试环境吗?我被困在uiautomatorviewer了。
我已经安装了Android并安装了JDK。
发布于 2018-08-03 07:40:49
设置环境变量:
完成自动化设置的遵循以下说明:
使用uiautomatorviewer来捕捉屏幕。
Steps for Appium Setup:
1. Install android studio
2 SDK
2. Appium jar files selenium
3. Appium java client jar
4. Java selenium library
5. Appium server
6. Java
7 install pdanet in both system and mobile device co connectivity
8 gson jar files
**steps**
Open android Studio
Create new project
Create new basic activity
Copy java client jar file and paste in the app/lib folder
select all jar copied files in the lib folder then right click and click on "Add as library".
select build.gradle then rebuild project
commit jUnit and paste following code beneath of it
testCompile 'org.assertj:assertj-core:2.0.0'
testCompile 'org.testng:testng:6.9.10'
sync the code
Right click on Package Name the create a new class
import org.openqa.selenium.By;
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.AfterMethod;
import org.testng.annotations.BeforeMethod;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
public class WaitTest {
RemoteWebDriver driver;
@BeforeMethod
public void setUp() throws MalformedURLException {
// Created object of DesiredCapabilities class.
DesiredCapabilities capabilities = new DesiredCapabilities();
// Set android deviceName desired capability. Set your device name.
capabilities.setCapability("deviceName", "4200174ad22b7200");
// Set BROWSER_NAME desired capability. It's Android in our case here.
capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");
// Set android VERSION desired capability. Set your mobile device's OS version.
capabilities.setCapability(CapabilityType.VERSION, "5.1.1");
// Set android platformName desired capability. It's Android in our case here.
capabilities.setCapability("platformName", "Android");
// Set android appPackage desired capability. It is
// com.android.calculator2 for calculator application.
// Set your application's appPackage if you are using any other app.
capabilities.setCapability("appPackage", "in.dishtv.svctechnician");
// Set android appActivity desired capability. It is
// com.android.calculator2.Calculator for calculator application.
// Set your application's appPackage if you are using any other app.
capabilities.setCapability("appActivity", "in.dishtv.svctechnician.activity.MyActivity");
// Created object of RemoteWebDriver will all set capabilities.
// Set appium server address and port number in URL string.
// It will launch calculator app in android device.
driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
//driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
}
@org.junit.Test
public void LoginTest1() {
try {
setUp();
} catch (MalformedURLException e) {
e.printStackTrace();
}
driver.findElement(By.id("userNameEdittext")).sendKeys("james");
driver.findElement(By.id("passwordEdittext")).sendKeys("bond");
driver.findElement(By.id("submitButton")).click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@AfterMethod
public void End() {
driver.quit();
}
}
Do not import Selenium jar (because of it's too long size) use Gradle link from Below:
**compile group: 'org.seleniumhq.selenium', name: 'selenium-server-standalone', version: '2.53.0'**
Start Appium server
concect device
run tests in the android studiohttps://stackoverflow.com/questions/51667574
复制相似问题