共计 2940 个字符,预计需要花费 8 分钟才能阅读完成。
本篇内容主要讲解“Appium 如何安装配置环境”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让丸趣 TV 小编来带大家学习“Appium 如何安装配置环境”吧!
安装 Android SDK,AndroidSDK_installer_r24.4.1-windows.exe
用 Admistrator 运行 SDK Manager.exe,
Tools 下选择 SDK Tools, SDK Platform-tools,SDK Build-tools 安装
Android 7.11 (API 25) 下选择 SDK Platform 安装
Android 5.1.1 (API 22) 下选择 SDK Platform,ARM EABI v7a System Image 和 Intel x86 Atom System Image 安装
这个可以自己选择安装。
用 Administrator 运行 AVD Manager.exe
在 Device Definitions 下选择 Nexus 4 然后点 Create Device,输入名字,屏幕大小,分辨率,内存大小。
在 Device Definitions 下选择刚才新建的 Device,然后点击 Create AVD 创建虚拟设备,CPU/ABI 选择 ARM(armeabi-v7a), Skin 选 No Skin
在 Android Virtual Devices 下 选择金健的虚拟设备,点 Start,启动设备
添加环境变量 ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk
安装 nodejs
nodejs 下安装 appium
npm install -g appium
npm install -g appium-doctor
运行 appium-doctor, 检查环境
info AppiumDoctor Appium Doctor v.1.4.2
info AppiumDoctor ### Diagnostic starting ###
info AppiumDoctor ? The Node.js binary was found at: C:\Program Files\nodejs\node.exe
info AppiumDoctor ? Node version is 6.10.2
info AppiumDoctor ? ANDROID_HOME is set to: C:\Program Files (x86)\Android\android-sdk
info AppiumDoctor ? JAVA_HOME is set to: C:\Program Files\Java\jdk1.8.0_51
info AppiumDoctor ? adb exists at: C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe
info AppiumDoctor ? android exists at: C:\Program Files (x86)\Android\android-sdk\tools\android.bat
info AppiumDoctor ? emulator exists at: C:\Program Files (x86)\Android\android-sdk\tools\emulator.exe
info AppiumDoctor ? Bin directory of %JAVA_HOME% is set
info AppiumDoctor ### Diagnostic completed, no fix needed. ###
info AppiumDoctor
info AppiumDoctor Everything looks good, bye!
info AppiumDoctor
运行 appium,启动 appium hub server
C:\Program Files\nodejs appium
[Appium] Welcome to Appium v1.6.4
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
Maven dependency
dependency
groupId io.appium /groupId
artifactId java-client /artifactId
version 4.1.2 /version
/dependency
Java
import java.net.URL;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
public class AndroidDriverTest {
public static void main(String[] args) throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME,
capabilities.setCapability(platformName , Android
capabilities.setCapability(deviceName , Android Emulator
capabilities.setCapability(platformVersion , 5.1.1
capabilities.setCapability(appPackage , com.android.calculator2
capabilities.setCapability(appActivity , .Calculator
AndroidDriver MobileElement driver =
new AndroidDriver MobileElement (new URL( http://127.0.0.1:4723/wd/hub), capabilities);
driver.findElementByAndroidUIAutomator(text(\ 1\) ).click();
driver.findElementByAndroidUIAutomator(text(\ +\) ).click();
driver.findElementByAndroidUIAutomator(text(\ 2\) ).click();
driver.findElementByAndroidUIAutomator(text(\ =\) ).click();
System.out.println(driver.currentActivity());
driver.quit();
}
}
到此,相信大家对“Appium 如何安装配置环境”有了更深的了解,不妨来实际操作一番吧!这里是丸趣 TV 网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!