如何在 Mac OS 上设置 Appium 以从 Android 和 iOS 设备上的 JAVA 类运行自动化测试
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24813589/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to setup Appium on Mac OS to run automated tests from JAVA classes on Android and iOS devices
提问by Igor Vishnevskiy
Problem I was facing with Appium that I decided myself below. I could not find a way to install required components for Appium without using SUDO. After installing it all with SUDO, then trying to run Appium, I was getting error that Appium and NODE should have been installed without SUDO. Trying to search online for solution took me quite a while since there are almost no tutorials exist online for Appium to run on MAC while developing tests using JAVA. Below is the step by step instruction on how to set up Appium on Mac OS and run a first test from within a Java Class. Just copy and paste commands into Terminal on your Mac and you will set it up. I wish there were more clear step by step tutorials online for Appium. Tutorials written by developers of Appium are so vague, I don't even want to recommend to look for answers on their website.
我在使用 Appium 时遇到的问题是我在下面决定的。如果不使用 SUDO,我找不到为 Appium 安装所需组件的方法。使用 SUDO 安装所有内容后,然后尝试运行 Appium,我收到错误消息,应该在没有 SUDO 的情况下安装 Appium 和 NODE。尝试在线搜索解决方案花了我很长时间,因为在使用 JAVA 开发测试时,几乎没有在线教程可以让 Appium 在 MAC 上运行。下面是有关如何在 Mac OS 上设置 Appium 并从 Java 类中运行第一个测试的分步说明。只需将命令复制并粘贴到 Mac 上的终端中即可进行设置。我希望有更清晰的 Appium 在线分步教程。Appium 的开发者写的教程太含糊了,我什至不想推荐在他们的网站上寻找答案。
采纳答案by Igor Vishnevskiy
Answered by Igor VishnevskiyI have been looking for the answer everywhere on the internet and could not find anything. It took me some time to make this work. I hope this quick guide will help the next engineer to save some time on setting up Appium to run automation on Android devices. Appium will not run if NODE or Appium itself is installed using SUDO and MAC won't let you install neither without using SUDO. There is a workaround though. My steps make it possible to install and setup Appium the right way without need to use SUDO for installation. Everything is tested and it works. Below are the steps. Enjoy!
由 Igor Vishnevskiy 回答我一直在互联网上到处寻找答案,但一无所获。我花了一些时间来完成这项工作。我希望这个快速指南能够帮助下一位工程师节省一些时间来设置 Appium 以在 Android 设备上运行自动化。如果使用 SUDO 安装 NODE 或 Appium 本身,Appium 将不会运行,而 MAC 不会让您在不使用 SUDO 的情况下安装它们。不过有一个解决方法。我的步骤使以正确的方式安装和设置 Appium 成为可能,而无需使用 SUDO 进行安装。一切都经过测试并且可以正常工作。下面是步骤。享受!
There could be one problem while setting up Appium using bellow steps. If you face some errors while creating or saving data into certain directories, that is caused by the luck of write permissions set to those directories. What you will need to do is to set CHMOD to 777 to the directories where components of Appium are trying to write while installing and then rerun all steps again.
使用以下步骤设置 Appium 时可能会出现一个问题。如果您在创建或将数据保存到某些目录时遇到一些错误,那是由于对这些目录设置了写权限的运气造成的。您需要做的是将 CHMOD 设置为 777 到 Appium 组件在安装时尝试写入的目录,然后再次重新运行所有步骤。
Step 1:Install JAVA 6. You will need JAVA 6 with Appium. JAVA 6 for Mac OS has to be downloaded from Apple's support page: http://support.apple.com/kb/DL1572
第 1 步:安装 JAVA 6。您将需要带有 Appium 的 JAVA 6。JAVA 6 for Mac OS 必须从 Apple 的支持页面下载:http: //support.apple.com/kb/DL1572
Step 2:In your bash add the following path using following format:
第 2 步:在您的 bash 中,使用以下格式添加以下路径:
export PATH=$HOME/local/bin:$PATH
Step 3:Setup Maven (Download and set Bash profile PATH for Maven):
第 3 步:设置 Maven(下载并设置 Maven 的 Bash 配置文件路径):
http://maven.apache.org/download.cgi
------>This is what your Bash Profile should look like:
------>你的 Bash Profile 应该是这样的:
export PATH="/Users/your_username/Desktop/adt-bundle-mac-x86_64-20140702/sdk/platform-tools":$PATH
export PATH="/Users/your_username/Desktop/adt-bundle-mac-x86_64-20140702/sdk/tools":$PATH
export PATH=$HOME/local/bin:$PATH
export ANDROID_HOME=/Users/your_username/Desktop/adt-bundle-mac-x86_64-20140321/sdk
export PATH="/Users/your_username/Desktop/apache-maven-3.2.2/bin":$PATH
export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)
Obviously to run tests on Android device, you will need to download Android SDK and add it to your Bash Profile as well. To run tests on iOS devices, you will only need to install XCode, no need to add that to your Bash profile. But Android SDK has to be added.
显然,要在 Android 设备上运行测试,您还需要下载 Android SDK 并将其添加到您的 Bash 配置文件中。要在 iOS 设备上运行测试,您只需要安装 XCode,无需将其添加到您的 Bash 配置文件中。但是必须添加Android SDK。
Step 4:Copy and paste following sequence of commands into your Terminal window and press ENTER. Copy and pasting it all together will work. It will take some time to install NODE, so be patient.
第 4 步:将以下命令序列复制并粘贴到终端窗口中,然后按 ENTER。将它们全部复制并粘贴在一起即可。安装NODE需要一些时间,请耐心等待。
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install
Step 5:After installation from Step 4 is complete, run following command in your Terminal window:
第 5 步:从第 4 步安装完成后,在终端窗口中运行以下命令:
curl https://www.npmjs.com/install.sh | sh
Step 6:Then in your Terminal window execute following command:
第 6 步:然后在您的终端窗口中执行以下命令:
npm install -g grunt-cli
Step 7:Then in your Terminal window execute following command:
第 7 步:然后在您的终端窗口中执行以下命令:
npm install -g appium
Step 8:Then in your Terminal window execute following command:
第 8 步:然后在您的终端窗口中执行以下命令:
npm install wd
Step 9:Then in your Terminal window execute following command to start the Appium server:
第 9 步:然后在您的终端窗口中执行以下命令以启动 Appium 服务器:
appium &
(step 9 will start the server).
(第 9 步将启动服务器)。
Step 10:From the separate terminal Window
cd to root directory of your JAVA project in your workspace.
(example: cd /Users/ivishnevskiy/Documents/workspace/ApiumJUnit
)
第 10 步:从单独的终端窗口 cd 到您工作区中 JAVA 项目的根目录。(例如:cd /Users/ivishnevskiy/Documents/workspace/ApiumJUnit
)
Step 11:Attach your Android device to USB and to your MAC computer.
第 11 步:将您的 Android 设备连接到 USB 和您的 MAC 计算机。
Step 12:In the same Terminal window from Step 10, run following command to launch the Appium test:
第 12 步:在与第 10 步相同的终端窗口中,运行以下命令以启动 Appium 测试:
mvn -Dtest=test.java.com.saucelabs.appium.AndroidContactsTest test
where test.java.com.saucelabs.appium is a package name and AndroidContactsTest is a class name.
其中 test.java.com.saucelabs.appium 是包名,AndroidContactsTest 是类名。
If you still need help setting it up. Let me know. I can help. My LinkedIn: http://www.linkedin.com/pub/igor-vishnevskiy/86/51a/b65/
如果您仍然需要帮助进行设置。让我知道。我可以搭把手。我的领英:http: //www.linkedin.com/pub/igor-vishnevskiy/86/51a/b65/
AFTER SETTING APPIUM UP ON YOUR DEVICE, FOLLOW MY NEXT TUTORIAL TO CREATE IN ECLIPSE AND RUN YOUR FIRST TEST ON THE ACTUAL iOS DEVICE (NOT EMULATOR): How to create in Eclipse and run your Appium test on the iOS device (not emulator) where app is installed prior to the execution of the test script?
在您的设备上设置 Appium 后,按照我的下一个教程在 ECLIPSE中创建并在实际 iOS 设备(不是模拟器)上运行您的第一次测试: 如何在 Eclipse 中创建并在 iOS 设备(不是模拟器)上运行您的 Appium 测试,其中在执行测试脚本之前安装了应用程序?
回答by M_ Fa
Sorry its a little messy take it from my notes ;
对不起,它有点乱,从我的笔记中取出;
consider you have a system enviroment its located in .bash_profile you have to add jre jdk files there
考虑到您有一个系统环境,它位于 .bash_profile 中,您必须在那里添加 jre jdk 文件
also android sdk if you want to run appium for android and ios from mac
如果您想从 mac 为 android 和 ios 运行 appium,也可以使用 android sdk
there is a ui automator you have to install it
有一个 ui automator 你必须安装它
there is a setup dr in appium you can check to see if you install appium correctly
在 appium 中有一个 setup dr 你可以检查你是否正确安装了 appium
its the steps i take to run appium on ios for [android device and ios device] ; i note every step some step might be un necessary i wish it help you
这是我为 [android 设备和 ios 设备] 在 ios 上运行 appium 所采取的步骤;我注意到每一步都有一些步骤可能是不必要的我希望它对你有帮助
go to terminal :
去终端:
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install
sudo ln -s /path_to_maven_folder/bin/mvn /usr/bin/mvm
npm ln -s /Users/[your username]/Desktop/Appium/Tools/apache-maven-3.2.5/bin/mvn /usr/bin/mvn
$ mvn –version
download android bundle for iOS then run command
下载适用于 iOS 的 android 包然后运行命令
tools/android update sdk --no-ui
curl https://www.npmjs.org/install.sh | sh
npm install -g grunt-cli
npm install -g appium
npm install wd
==================================== Open and edit .bash_profile file
==================================== 打开并编辑 .bash_profile 文件
open -e .bash_profile If you don't have .bash_profile file in your computer path, then create one. Enter below command to create a new file. Once created follow Step-2.
open -e .bash_profile 如果您的计算机路径中没有 .bash_profile 文件,则创建一个。输入以下命令以创建新文件。创建完成后,请按照第 2 步操作。
touch .bash_profile Step-3
触摸 .bash_profile Step-3
add and save and again run in terminal
添加并保存并再次在终端中运行
export ANDROID_HOME=/Applications/Appium/Tools/android-sdk-macosx/ export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools step 4 set java home export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
export ANDROID_HOME=/Applications/Appium/Tools/android-sdk-macosx/ export PATH=${PATH}:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools 第四步设置java home export JAVA_HOME=/System/Library/Frameworks/ JavaVM.framework/Versions/CurrentJDK/Home
and add it to bash profile
并将其添加到 bash 配置文件中
install Eclipse :
install test ng in eclipse
add selenium library
add maven
New java project
udid >>find udi in xcode
install app in simulator
defaults write
com.apple.Finder AppleShowAllFiles TRUE
go to finder \
安装 Eclipse:在 Eclipse 中安装 test ng
添加 selenium 库添加 maven 新的 java 项目 udid >>在 xcode 中找到 udi 在模拟器默认安装应用程序写 com.apple.Finder AppleShowAllFiles TRUE 转到 finder \
enable ui automator in XCODE Device
setting >>developer
在 XCODE 设备
设置中启用 ui automator >>developer
install brew ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
安装 brew ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
install idevice brew install ideviceinstaller
安装 idevice brew 安装 ideviceinstaller
add maven jar files
添加 Maven jar 文件
update java to 1.8 install java then run this in terminal
将 java 更新到 1.8 install java 然后在终端中运行它
export JAVA_HOME="/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home”
preference eclipse java select search add newest version
偏好 Eclipse Java 选择搜索添加最新版本
回答by Reaz Patwary
Steps that need to follow:
需要遵循的步骤:
- install xcode
- install xcode command line tool
- install Appium GUI *.dmg file Appium
- Install homebrew (assuming you have ruby installed on your mac, if not install ruby first)
- Install Java (it should come with mac OS)
- Install node and Maven using brew command from terminal
- Install Appium server using node
- npm install –g appium
- appium &
- Authorize your iOS simulator and device to access by Appium by typing the command from terminal: sudo authorize_ios
- 安装 xcode
- 安装 xcode 命令行工具
- 安装 Appium GUI *.dmg 文件 Appium
- 安装自制软件(假设你的 mac 上安装了 ruby,如果没有先安装 ruby)
- 安装 Java(它应该与 mac OS 一起提供)
- 从终端使用 brew 命令安装节点和 Maven
- 使用 node 安装 Appium 服务器
- npm install -g appium
- 应用程序
- 通过从终端输入命令来授权你的 iOS 模拟器和设备通过 Appium 访问:sudo authorize_ios
:)
:)
I have made a video about how to configure appium on a Mac computer which can be viewedhere.
我制作了一个关于如何在 Mac 计算机上配置 appium 的视频,可以在这里查看。
And slides can be viewed here.
可以在此处查看幻灯片。
回答by Emjey
Follow these steps.
按着这些次序。
Pre-requisites to download.1. Appium 2. Android SDK 3. Java JDK 4. Android .apk file 5. Xcode and command line tools
下载的先决条件。1. Appium 2. Android SDK 3. Java JDK 4. Android .apk 文件 5. Xcode 和命令行工具
Process:
过程:
- Install Xcode with command line tools and appium.
- Download all the Android SDK necessary tools, that includes mandatorily platform-tools and build-tools
- Download and install Java JDK
- 使用命令行工具和 appium 安装 Xcode。
- 下载所有 Android SDK 必要的工具,包括强制平台工具和构建工具
- 下载并安装 Java JDK
Setting $Path and Configuring
设置 $Path 和配置
- Open bash_profile with the command
open .bash_profile
Copy the contents to your .bash_profile
export ANDROID_HOME=/Users/username/Library/Android/sdk . (copy it from the sdk manager in android studio) export PATH=$ANDROID_HOME/platform-tools:$PATH export PATH=$ANDROID_HOME/tools:$PATH export JAVA_HOME=$(/usr/libexec/java_home)export PATH="/usr/local/opt/openssl/bin:$PATH"
- 使用命令打开 bash_profile
open .bash_profile
将内容复制到您的 .bash_profile
export ANDROID_HOME=/Users/username/Library/Android/sdk . (copy it from the sdk manager in android studio) export PATH=$ANDROID_HOME/platform-tools:$PATH export PATH=$ANDROID_HOME/tools:$PATH export JAVA_HOME=$(/usr/libexec/java_home)export PATH="/usr/local/opt/openssl/bin:$PATH"
Copy the above, and save the .bash_profile
复制上面的,保存 .bash_profile
- Go to Appium, and click on Android symbol. Select and choose the .apk(place the apk in the project folder)
- Tick on the Device name and choose the applicable Android version in the capabilities.
- In the Advance settings under Android, choose the sdk path(Copy from the android sdk manager)
Click on the settings symbol, and add value to the
environment variables
ANDROID_HOME /Users/username/Library/Android/sdk (Copy the path from sdk manager)
Connect the device or launch the emulator, and click on
Launch
in appium, then click onInspector
, this should create a session and launch the app in your mobile and grab the current screenshot.
- 转到 Appium,然后单击Android 符号。选择并选择.apk(将apk放在项目文件夹中)
- 勾选设备名称并在功能中选择适用的 Android 版本。
- 在Android下的高级设置中,选择sdk路径(从android sdk管理器中复制)
单击设置符号,然后将值添加到
environment variables
ANDROID_HOME /Users/username/Library/Android/sdk (Copy the path from sdk manager)
连接设备或启动模拟器,然后
Launch
在 appium 中单击,然后单击Inspector
,这将创建一个会话并在您的手机中启动应用程序并获取当前屏幕截图。
回答by Raj Subrameyer
I used this post to help me set up Appium on my Mac. I also used other sources to do my installation completely. Here are step by step instructions to upgrade to appium 1.7.x
seamlessly on your Mac OS X.
我使用这篇文章来帮助我在 Mac 上设置 Appium。我还使用其他来源来完成我的安装。以下是1.7.x
在 Mac OS X 上无缝升级到 appium 的分步说明。
Please make a note of the following details BEFORE you start the upgrade process
在开始升级过程之前,请记下以下详细信息
- If Appium is not installed on your system previously, please use ONLY the commands related to "Install" below
- If you face any problem of deleting folder/directories using command line, please go to Finder and delete it
- Once you upgrade to new OS on your Mac machine, App Store and iTunes may open late and work slow for the first time
- 如果您的系统之前没有安装 Appium,请仅使用下面与“安装”相关的命令
- 如果您在使用命令行删除文件夹/目录时遇到任何问题,请转到 Finder 并删除它
- 在 Mac 机器上升级到新操作系统后,App Store 和 iTunes 可能会延迟打开并且第一次运行缓慢
Step by Step Instructions
分步说明
Need to install OS 10.12.x or higher version.
Need to install Xcode 9.x. Sign in with your developer account (
https://developer.apple.com/download/more/
) and download it OR Download it free from the Mac App store
需要安装 OS 10.12.x 或更高版本。
需要安装 Xcode 9.x。使用您的开发者帐户 (
https://developer.apple.com/download/more/
)登录并下载或从 Mac App Store 免费下载
Note - If you face problems while installing the new version of Xcode then please uninstall the old versions.
注意 - 如果您在安装新版本的 Xcode 时遇到问题,请卸载旧版本。
- Need to install the Command line tools for Xcode 9.x.
- 需要为 Xcode 9.x 安装命令行工具。
Launch Terminal and enter the below command
启动终端并输入以下命令
xcode-select --install
- Uninstall HomeBrew
- 卸载 HomeBrew
Uninstall Command:
卸载命令:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
- Install HomeBrew
- 安装 HomeBrew
Install Command:
安装命令:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Uninstall all instances of Node
go to
/usr/local/lib
and delete anynode
andnode_modules
go to
/usr/local/include
and delete anynode
andnode_modules
directory if you installed withbrew
installnode
, then runbrew uninstall node
in your terminalcheck your Home directory for any local or lib or include folders, and delete any
node
ornode_modules
from there. (To reach home directory open Terminal and entercd
)go to
/usr/local/bin
and delete any node executable
Install Node
卸载所有 Node 实例
转到
/usr/local/lib
并删除任何node
和node_modules
如果使用install 安装,则转到
/usr/local/include
并删除任何node
和node_modules
目录,然后在终端中运行brew
node
brew uninstall node
检查您的主目录是否有任何本地或 lib 或包含文件夹,并从那里删除任何
node
或node_modules
。(要到达主目录打开终端并输入cd
)转到
/usr/local/bin
并删除任何节点可执行文件
安装节点
Command:
命令:
brew install node
- Install ideviceinstaller:
- 安装 ideviceinstaller:
Command:
命令:
brew install ideviceinstaller
- Uninstall Appium from terminal
- 从终端卸载 Appium
Command:
命令:
npm uninstall -g appium
npm cache clean --force
- Install Appium
- 安装 Appium
Command:
命令:
npm install -g [email protected]** (Or we can just do npm install -g appium)
- Need to Install supporting tools for Appium 1.7.2
- 需要为 Appium 1.7.2 安装支持工具
Command:
命令:
brew install carthage
npm install -g ios-deploy
npm install -g deviceconsole
- For downloading simulators go to
Xcode --> Preferences --> Components
, and download necessary simulators.
- 要下载模拟器,请访问
Xcode --> Preferences --> Components
,并下载必要的模拟器。
回答by Shiv Shankar Balaji
Here is the step by step installation of appium on mac via terminal. After where you can run your java class file with the appium server start from script.
下面是通过终端在 mac 上逐步安装 appium。之后,您可以使用 appium 服务器从脚本开始运行您的 java 类文件。
Installation of Appium in MAC
在MAC中安装Appium
Step 1 : Install java JDK:
第 1 步:安装 Java JDK:
-- > Download Link here : http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
--> 下载链接在这里:http: //www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Step 2 : Install Android Studio:
第 2 步:安装 Android Studio:
--> Download Link here: https://developer.android.com/studio/index.html
--> 在这里下载链接:https: //developer.android.com/studio/index.html
Scroll till last and find the software as below:
滚动到最后找到软件如下:
android-studio-ide-173.4819257-mac.dmg
android-studio-ide-173.4819257-mac.dmg
Step 3 : Install Home brew
第 3 步:安装 Home brew
--> In Terminal install brew:
--> 在终端安装 brew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Step 4 : Install Node.js
第 4 步:安装 Node.js
--> install node.js:
--> 安装 node.js:
download installer: https://nodejs.org/en/download/and run
下载安装程序:https: //nodejs.org/en/download/并运行
Step 5 : Install npm
第 5 步:安装 npm
--> In Terminal install npm:
--> 在终端安装 npm:
brew update
brew install node
npm install -g npm
Step 6 : To setup Environment
第 6 步:设置环境
To open bash_profile in terminal, type the following command:
要在终端中打开 bash_profile,请键入以下命令:
open -e .bash_profile
If bash profile not available, create a bash_profile by following command
如果 bash 配置文件不可用,请通过以下命令创建一个 bash_profile
Start up Terminal
启动终端
Type "cd ~/" to go to your home folder
输入“cd ~/”转到您的主文件夹
Type "touch .bash_profile
" to create your new file.
键入“ touch .bash_profile
”以创建新文件。
To Edit .bash_profile where you can just type "open -e .bash_profile
" to open it in TextEdit.
要编辑 .bash_profile,您只需键入“ open -e .bash_profile
”即可在 TextEdit 中打开它。
paste following:
粘贴以下内容:
export ANDROID_HOME=/Users/user/Library/Android/sdk
export PATH=$ANDROID_HOME/platform-tools:$PATH
export PATH=$ANDROID_HOME/tools:$PATH
export JAVA_HOME=$(/Library/Java/JavaVirtualMachines/jdk1.8.0_141.jdk)
export PATH=${JAVA_HOME}/Contents/Home/bin:$PATH
export PATH=/usr/local/bin:/usr/local/sbin:~/bin:$PATH
export PATH=$PATH:/opt/bin:$PATH
save (Ctrl+S) and exit
保存 (Ctrl+S) 并退出
NOTE : As default Android studio and Java takes the above path, if you have changed the path then do change it here with correct version
注意:作为默认的 Android Studio 和 Java 采用上述路径,如果您更改了路径,请在此处使用正确的版本进行更改
Step 7. Install Appium In Terminal install Appium command line:
步骤 7. 安装 Appium 在终端安装 Appium 命令行:
npm install -g [email protected]
npm install wd
Step 8. Install Carthage
步骤 8. 安装 Carthage
Now type the following command to get into WebDriverAgent and Install carthage:
现在输入以下命令进入 WebDriverAgent 并安装 carthage:
cd /usr/local/lib/node_modules/appium/node_modules/appium-xcuitest-driver/WebDriverAgent
brew install carthage
npm i -g webpack
Step 9. Run Appium in command line
步骤 9. 在命令行中运行 Appium
From above steps do 'cd' to get out of all subfolders and then type 'appium'
从上面的步骤做'cd'退出所有子文件夹,然后输入'appium'
cd
appium
If everything works correct you should get the following line
如果一切正常,你应该得到以下行
[Appium] Welcome to Appium v1.6.0-beta1
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
Now you have to run java class file from the script where have to start the appium server from script, here are the steps to follow
现在您必须从脚本运行 java 类文件,其中必须从脚本启动 appium 服务器,以下是要遵循的步骤
public AppiumDriver<WebElement> setUp() throws Exception {
builder = new AppiumServiceBuilder();
//builder.usingAnyFreePort();
//builder.withIPAddress("0.0.0.0");
//builder.usingPort(4723);
builder.withCapabilities(cap);
builder.withArgument(GeneralServerFlag.SESSION_OVERRIDE);
builder.withArgument(GeneralServerFlag.LOG_LEVEL,"error");
builder.withAppiumJS(newFile("/usr/local/lib/node_modules/appium/build/lib/main.js"));
builder.usingDriverExecutable(new File("/usr/local/bin/node"));
service = AppiumDriverLocalService.buildService(builder);
service.start();
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("app", "/Users/user/Documents/yourapp.app");
capabilities.setCapability("noReset", "false");
capabilities.setCapability(MobileCapabilityType.VERSION, "12.0");
capabilities.setCapability(MobileCapabilityType.PLATFORM, "iOS");
capabilities.setCapability(MobileCapabilityType.UDID,"abcddjkfg...");
capabilities.setCapability("bundleId", "com...");
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, "XCUITest");
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "user's iPhone");
driver = new IOSDriver<>(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
return driver;
}
In terminal get the path
在终端获取路径
echo $PATH
Copy the path and note down
复制路径并记下
Now open your Run configuration (Eclipse)
Select the class file you are going to run
Click on Environment Tab
Click New
Give the variable name as 'PATH'
Now paste the copied path in value and save it
现在打开你的运行配置(Eclipse)
选择你要运行的类文件
单击环境选项卡
点击新建
将变量名称指定为“PATH”
现在将复制的路径粘贴到 value 中并保存
Here is the image link for reference
这是图片链接供参考
Now you ran the script and you could see the appium server start in editor console and app will get launch in the device and your script will run
现在你运行了脚本,你可以看到 appium 服务器在编辑器控制台中启动,应用程序将在设备中启动,你的脚本将运行
NOTE : For real device iOS automation, you can use appium desktop GUI and some stuff are additionally yet to install for real device iOS automation do the following link for configuration
注意:对于真实设备的 iOS 自动化,您可以使用 appium 桌面 GUI 并且一些东西还没有为真实设备的 iOS 自动化安装,请执行以下链接进行配置
https://techsouljours.blogspot.com/2018/08/install-appium-on-mac.html
https://techsouljours.blogspot.com/2018/08/install-appium-on-mac.html
Post author and executed by https://www.linkedin.com/in/shiv-shankar-siddarth/