本篇内容主要讲解“Appium如何安装配置环境”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“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如何安装配置环境”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。