如何为Android和ios的appium自动化运行单一代码结构?

时间:2018-06-12 06:33:19

标签: android ios appium

我正在研究Android和IOS的Appium测试自动化项目,我已经定义了一些配置和runTests.xml文件。 我关心的是使用android和IOS的单一代码结构。

现在,我所做的配置,仅适用于Android,它不适用于iOS平台。

请检查pom.xml文件:

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>MW_TestAutomation</groupId>
    <artifactId>MW_TestAutomation</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>MW_TestAutomation</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.version>3.7.0</maven.compiler.version>
        <appium.version>5.0.0-BETA4</appium.version>
        <selenium.version>3.3.1</selenium.version>
        <junit.version>4.12</junit.version>
        <testng.version>6.14.3</testng.version>
        <log4j.version>1.2.17</log4j.version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <suiteXmlFile>runTests.xml</suiteXmlFile>
    </properties>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.testng/testng -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>${testng.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/junit/junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- https://mvnrepository.com/artifact/io.appium/java-client -->
        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>${appium.version}</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>${selenium.version}</version>
        </dependency>

        <!-- https://mvnrepository.com/artifact/log4j/log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>${log4j.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.21.0</version>
                <configuration>
                    <systemPropertyVariables>
                        <platform>${platform}</platform>
                    </systemPropertyVariables>
                    <suiteXmlFiles>
                        <suiteXmlFile>${suiteXmlFile}</suiteXmlFile>
                    </suiteXmlFiles>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.version}</version> <!-- or whatever current version -->
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                </configuration>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources/com/mw/configs</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
</project>

并且mvn命令是 mvn clean test -Dplatform = android -DsuiteXmlFile = runTests.xml

并且runText.xml文件是:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="MW_Test_Automation">

    <!-- Login Page test scenarios -->
    <test name="LoginPageTest">
        <classes>
            <class name="com.mw.tests.LoginPageTest" />
        </classes>
    </test>

    <!-- Dashboard Page test scenarios -->
    <test name="DashboardPageTest">
        <classes>
            <class name="com.mw.tests.DashboardPageTest" />
        </classes>
    </test>

    <!-- Gauge Page test scenarios -->
    <test name="GaugePageTest">
        <classes>
            <class name="com.mw.tests.GaugePageTest" />
        </classes>
    </test>

</suite>

请告诉我如何使用此配置为android和ios执行自动化?

0 个答案:

没有答案