【Mac + Appium + Java1.8(一)】之Android自动化环境安装配置以及IDEA配置(附录扩展Selenium+Java自动化)

 

配置环境:

  • MacOS:10.13.6
  • java:1.8
  • IntelliJ IDEA:2018.3
  • Android SDK:25
  • Appium:1.9.1
  • Appium-desktop:1.7.1
  • java-client:6.1.0(最新且不是Bate版本)
  • junit:4.12
  • Android:6.0.0

 

一、安装测试环境

1、安装java

因为java电脑当初自带的,不做描述,所以请参考下面地址安装。

参考地址:《Mac配置java运行环境的步骤

2、安装 IntelliJ IDEA

IDEA官网地址:https://www.jetbrains.com/idea/

下载完之后打开IDEA

 

一直点击下一步即可,到了破解界面:

破解网址:《IntelliJ IDEA 2018 破解过程[详细步骤](Mac OS & Windows)

 

破解步骤:

①下载破解包

地址:http://idea.lanyus.com/下载JetbrainsCrack-x.x-release-enc.jar

②打开IDEA,拷贝进去(红色)

③在该目录Contents->bin下,修改idea.vmoptions文件(也就是上图中蓝色框的文件),用编辑器打开,在文件最底部添加如下一行信息,可直接复制:

-javaagent:JetbrainsCrack-x.x-release-enc.jar

④添加完成后重新打开IntelliJ IDEA应用程序并进入主界面,在弹出的激活对话框中选择Activation Code,若没有弹出激活框,可在Help下点击Register如下图:

然后在弹出的激活窗口上选择Activation Code并输入以下注册码:

K71U8DBPNE-eyJsaWNlbnNlSWQiOiJLNzFVOERCUE5FIiwibGljZW5zZWVOYW1lIjoibGFuIHl1IiwiYXNzaWduZWVOYW1lIjoiIiwiYXNzaWduZWVFbWFpbCI6IiIsImxpY2Vuc2VSZXN0cmljdGlvbiI6IkZvciBlZHVjYXRpb25hbCB1c2Ugb25seSIsImNoZWNrQ29uY3VycmVudFVzZSI6ZmFsc2UsInByb2R1Y3RzIjpbeyJjb2RlIjoiSUkiLCJwYWlkVXBUbyI6IjIwMTktMDUtMDQifSx7ImNvZGUiOiJSUzAiLCJwYWlkVXBUbyI6IjIwMTktMDUtMDQifSx7ImNvZGUiOiJXUyIsInBhaWRVcFRvIjoiMjAxOS0wNS0wNCJ9LH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Hk3bQVvbfdAwxcDy4xBjs3L4raPLU3yenSzr/OEur1+jfOxnQSmEcMXKXgrAQ9U55gwjcOFKrgOxEdek/Sk1VfOjvS+nuM4eyEruFMfaZHzoQiuw4IqgGc45ohFH0UUyjYcuFxxDSU9lMCv8qdHKm+wnPRb0l9l5vXsCBDuhAGYD6ss+Ga+aDY6f/qXZuUCEUOH3QUNbbCUlviSz6+GiRnt1kA9N2Qachl+2yBfaqUqr8h7Z2gsx5LcIf5kYNsqJ0GavXTVyWh7PYiKX4bs354ZQLUwwa/cG++2+wNWP+HtBhVxMRNTdVhSm38AknZlD+PTAsWGu9GyLmhti2EnVwGybSD2Dxmhxk3IPCkhKAK+pl0eWYGZWG3tJ9mZ7SowcXLWDFAk0lRJnKGFMTggrWjV8GYpw5bq23VmIqqDLgkNzuoog==

进入界面后,创建项目:

点击”Create New Project”选项创建新的Java项目。选择项目类型为Java,然后,继续”Next”。

 

创建项目文件夹:

点击完成进入到IDEA里面,编写hello world:

package javaBase;

public class HelloWorld {
    public static void main(String[] args){
        System.out.println("hello World");
    }
}

 运行结果,点击工具栏 Run 按钮(或在代码文件中右键选择”Run ‘HelloWorld.main()’“)运行, 将会在控制台看到“hello word” 的输出:

3、安装Android SDK、Appium、Appium-desktop

统一参考:《【Mac + Appium学习(一)】之安装Appium环境前提准备》安装及配置。

4、安装Maven

Java开发必备工具!

1)Maven 安装 Java-client

首先,启动IntelliJ IDEA,创建Maven项目,然后在maven配置文件中添加Java-client配置。

打开Intellij IDE,选择左侧的Maven,不选择任何Maven模板,选择Next ,如下图:

 

 之后会出现如下界面,界面信息为 .xml配置文件信息

①官网提供的文档:https://github.com/appium/java-client

里面可以查看Maven版本,注意Bate版本不要。

②或者查看官网的实例:https://github.com/appium-boneyard/sample-code/blob/master/sample-code/examples/java/junit/pom.xml

 

在配置文件中添加Junit、appium-java:

    <dependencies>
        <!-- Junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>

        <!-- appium-java -->
        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>6.1.0</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

但是添加版本的时候报红色,点击前面红色灯泡Update一下就好了:

 

最后,在src/java/下面创建一个类:

 

二、附录

感谢:

YF_Li123:《利用IDEA的Maven创建第一个java程序(helloworld)

:《环境安装之Selenium

 

 至此,本节内容完毕,Appium+Java环境搭建完毕,下面就可以编写自动化脚本了!

=============================================================

下面简单介绍下selenium的配置,上面几乎所有步骤都一致,唯一不同的就是在配置文件中添加selenium-java:

    <dependencies>
        <!-- selenium-java -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.0.1</version>
        </dependency>
    </dependencies>

然后也是在src/java下面新建一个类:

//package javaBase;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Itest {
    public static void main(String[] args) {

        WebDriver driver = new ChromeDriver();
        driver.get("http://www.itest.info");

        String title = driver.getTitle();
        System.out.printf(title);

        driver.close();
    }
}

然后直接Run就可以了!

 

posted @ 2019-12-28 11:41  Owen_ET  阅读(1220)  评论(0编辑  收藏  举报