如何设置Appium在Mac OS上运行的Java类在Android和iOS设备的自动化测试 [英] How to setup Appium on Mac OS to run automated tests from JAVA classes on Android and iOS devices

查看:255
本文介绍了如何设置Appium在Mac OS上运行的Java类在Android和iOS设备的自动化测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是面临着Appium,我决定自己下面。我无法找到一个方法来安装所需组件Appium不使用sudo。使用sudo安装了一切,然后试图运行Appium后,我得到了Appium和节点应该已经没有sudo安装错误。试图在网上搜索解决方案,花了相当长一段时间,因为几乎没有在线教程存在Appium的MAC,而使用JAVA开发测试运行。下面是关于如何建立Appium在Mac OS和运行在Java类第一个测试的一步一步的指示。只需复制和粘贴命令到终端在Mac上,你会对其进行设置。我希望那里Appium是一步教程更清晰的步骤在线。教程写的Appium开发商是如此模糊,我甚至不想推荐给寻找他们的网站上的答案。

解决方案

由Igor Vishnevskiy回答  我一直在寻找的答案无处不在互联网上,但没有找到任何东西。我花了一些时间来完成这项工作。我希望这个快速指南将有助于在未来的工程师,以节省一些时间设置Appium在Android设备上运行的自动化。如果将节点或Appium本身使用sudo和MAC不会让你既没有安装使用sudo安装Appium将无法运行。有一个解决办法,但。我的步骤,使其能够安装和设置Appium以正确的方式,而不需要使用sudo进行安装。一切都进行测试和它的作品。下面是步骤。尽情享受吧!

有可能是一个问题,而设立Appium使用波纹管的步骤。如果您在创建或保存数据到某个目录中面临的一些错误,这是通过设置对这些目录的写权限的运气所致。你将需要做的是设置文件模式为777到Appium的组件正试图安装时写的目录,然后再重新运行的所有步骤。

第1步: 安装Java 6,您将需要JAVA 6 Appium。 Java 6中的Mac OS必须从苹果的支持页面下载: http://support.apple.com/kb/DL1572

第二步: 在您的bash中使用以下格式添加以下路径:

 导出PATH = $ HOME / local / bin目录:$ PATH
 

第三步: 安装Maven的(下载并设置Bash的配置文件路径Maven的):

  http://maven.apache.org/download.cgi
 

------> 这是你的Bash配置文件应该是什么样子:

 导出路径=/用户/ your_username /桌面/ ADT-束-MAC-x86_64-20140702 / SDK /平台工具:$ PATH
出口PATH =/用户/ your_username /桌面/ ADT-束-MAC-x86_64-20140702 / SDK /工具:$ PATH
出口PATH = $ HOME / local / bin目录:$ PATH
出口ANDROID_HOME = /用户/ your_username /桌面/ ADT-束-MAC-x86_64-20140321 / SDK
出口PATH =/用户/ your_username /桌面/阿帕奇Maven的-3.2.2 / bin中:$ PATH
出口JAVA_HOME = $(在/ usr / libexec中/ JAVA_HOME -v 1.6)
 

显然运行在Android设备的测试,你将需要下载的Andr​​oid SDK,并将其添加到您的Bash配置文件也是如此。运行在iOS设备上测试,你只需要安装X code,没有必要添加到您的Bash配置文件。但是Android SDK提供了无以复加。

第四步: 复制和粘贴命令的如下顺序进入终端窗口,preSS ENTER键。复制和粘贴在一起会工作。这将需要一些时间来安装节点上,所以要耐心等待。

 回声出口PATH = $ HOME / local / bin目录:$ PATH'>>在〜/ .bashrc
。在〜/ .bashrc
MKDIR〜/本地
MKDIR〜/节点最新安装
CD〜/节点最新安装
卷曲http://nodejs.org/dist/node-latest.tar.gz |焦油XZ --strip组件= 1
的./configure  -  preFIX =〜/地方
使安装
 

第五步: 之后从第4步安装完成后,运行以下命令在终端窗口:

 卷曲https://www.npmjs.com/install.sh | SH
 

第6步: 然后在你的终端窗口中执行以下命令:

  NPM安装-g咕噜-CLI
 

第7步: 然后在你的终端窗口中执行以下命令:

  NPM安装-g appium
 

第8步: 然后在你的终端窗口中执行以下命令:

  NPM安装WD
 

第9步: 然后在你的终端窗口中执行以下命令来启动Appium服务器:

  appium和放大器;
 

(第9步将启动服务器)。

第10步: 从单独的终端窗口 cd到根在工作区Java项目的目录。 (例如: CD /用户/ ivishnevskiy /文件/工作区/ ApiumJUnit

第11步: 附上你的Andr​​oid设备的USB和Mac计算机。

第12步: 在从第10步相同的终端窗口中运行以下命令来启动Appium测试:

  MVN -Dtest = test.java.com.saucelabs.appium.AndroidContactsTest测试
 

在这里test.java.com.saucelabs.appium是包名 和 AndroidContactsTest是一个类名。

如果您仍然需要帮助设置它。让我知道。我可以搭把手。我的LinkedIn: http://www.linkedin.com/pub/igor-vishnevskiy/ 86 / 51A / B65 /

  
    
      
        

在设定APPIUM在您的设备,按照我的下一篇教程在Eclipse中创建并运行你的第一个测试实际的iOS设备(未仿真器):         如何在Eclipse中创建并运行iOS设备上的Appium测试(不仿真器),其中应用程序安装之前测试脚本的执行?

      
    
  

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.

解决方案

Answered by Igor Vishnevskiy I 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!

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.

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

Step 2: In your bash add the following path using following format:

export PATH=$HOME/local/bin:$PATH

Step 3: Setup Maven (Download and set Bash profile PATH for Maven):

http://maven.apache.org/download.cgi

------> This is what your Bash Profile should look like:

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.

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.

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:

curl https://www.npmjs.com/install.sh | sh

Step 6: Then in your Terminal window execute following command:

npm install -g grunt-cli

Step 7: Then in your Terminal window execute following command:

npm install -g appium

Step 8: Then in your Terminal window execute following command:

npm install wd

Step 9: Then in your Terminal window execute following command to start the Appium server:

appium &

(step 9 will start the server).

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)

Step 11: Attach your Android device to USB and to your MAC computer.

Step 12: In the same Terminal window from Step 10, run following command to launch the Appium test:

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.

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/

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在Mac OS上运行的Java类在Android和iOS设备的自动化测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆