这里有人可以帮助我设置集成Appium
工具进行自动化测试的环境。我停留在uiautomatorviewer
。
我已经设置了Android Studio并安装了JDK。
答案 0 :(得分:1)
设置环境变量:
Android SDK路径:C:\ Users \ user_name \ AppData \ Local \ Android \ Sdk
在环境变量中设置ANDROID_HOME:并从上方设置SDK的路径
在Android SDK文件夹中,需要将三个特定的文件夹添加到Path变量中。这些文件夹是–
C:\ Users \ user_name \ AppData \ Local \ Android \ Sdk \ platform-tools C:\ Users \用户名\ AppData \ Local \ Android \ Sdk \ tools C:\ Users \用户名\ AppData \ Local \ Android \ Sdk \ tools \ bin
%ANDROID_HOME%\ platform-tools ANDROID_HOME%\ tools %ANDROID_HOME%\ tools \ bin
设置PATH变量:
您应该已经添加了这3个文件夹的所有位置–;%ANDROID_HOME%\ platform-tools;%ANDROID_HOME%\ tools;%ANDROID_HOME%\ tools \ bin
要验证是否正确设置了所有Android环境变量,请打开命令提示符并运行以下命令:sdkmanager – -list (请注意,两个连字符之间不能有空格。)
您也可以运行以下命令:uiautomatorviewer在命令提示符下。这将打开UI Automator Viewer窗口。
在环境变量中设置JAVA_HOME:
C:\ Program Files \ Java \ jdk1.8.0_131
将此变量添加到PATH变量中,如下所示:
;%JAVA_HOME%\ bin;
要完成自动化设置,请遵循以下说明:
使用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 studio