pom template

<?xml version="1.0" encoding="UTF-8"?>
<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>com.alexchen.template</groupId>
    <artifactId>simple-app</artifactId>
    <version>1.0.0-SNAPSHOT</version>

    <distributionManagement>
        <repository>
            <id>nexus.releases</id>
            <name>fxorder</name>
            <url>http://your-nexus:8081/nexus/content/repositories/releases/</url>
        </repository>

        <snapshotRepository>
            <id>nexus.snapshots</id>
            <name>simple-app</name>
            <url>http://your-nexus:8081/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

    <scm>
        <connection>scm:git:ssh://your-git-path:port/apps/simple-app.git</connection>
        <developerConnection>scm:git:ssh://your-git-path:port/apps/simple-app.git</developerConnection>
        <url>https://your-git-path:port/repos/simple-app/browse</url>
        <tag>HEAD</tag>
    </scm>

    <dependencies>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.1.2</version>
        </dependency>

        <dependency>
            <groupId>com.mchange</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.5.1</version>
        </dependency>
        <dependency>
            <groupId>oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0.4</version>
        </dependency>
        <!--<dependency>-->
            <!--<groupId>com.hynnet</groupId>-->
            <!--<artifactId>oracle-driver-ojdbc6</artifactId>-->
            <!--<version>12.1.0.1</version>-->
        <!--</dependency>-->

        <!-- rest -->
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jaxrs</artifactId>
            <version>3.0.9.Final</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
            <version>9.2.9.v20150224</version>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-webapp</artifactId>
            <version>9.2.9.v20150224</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-client</artifactId>
            <version>3.0.9.Final</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-jackson2-provider</artifactId>
            <version>3.0.9.Final</version>
            <exclusions>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-annotations</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- rest -->

        
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.4</version>
        </dependency>
        <dependency>
            <groupId>com.typesafe</groupId>
            <artifactId>config</artifactId>
            <version>1.2.1</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>18.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.inject</groupId>
            <artifactId>guice</artifactId>
            <version>4.0-beta5</version>
        </dependency>
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.20</version>
        </dependency>


        <!-- test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <artifactId>hamcrest-core</artifactId>
                    <groupId>org.hamcrest</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>1.10.19</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <artifactId>hamcrest-core</artifactId>
                    <groupId>org.hamcrest</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.4.182</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.sparkjava</groupId>
            <artifactId>spark-core</artifactId>
            <version>2.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.mina</groupId>
            <artifactId>mina-core</artifactId>
            <version>2.0.9</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>build-details.properties</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>build-details.properties</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-toolchains-plugin</artifactId>
                <version>1.1</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>toolchain</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <toolchains>
                        <jdk>
                            <version>1.8</version>
                        </jdk>
                    </toolchains>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <!-- When running analyze-only fail if there are problems, and output XML to fix the problems -->
                    <ignoreNonCompile>true</ignoreNonCompile>
                    <outputXML>true</outputXML>
                    <failBuild>true</failBuild>
                    <failOnWarning>false</failOnWarning>
                </configuration>
                <executions>
                    <!-- always analyze after compilation -->
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>analyze</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <filters>
                        <filter>${project.basedir}/src/main/assembly/filter.properties</filter>
                    </filters>
                    <descriptors>
                        <descriptor>${project.basedir}/src/main/assembly/assembly.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>dist-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!-- Used to automatically create release versions of our builds. -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <autoVersionSubmodules>false</autoVersionSubmodules>
                    <localCheckout>true</localCheckout>
                    <pushChanges>true</pushChanges>
                    <arguments>-DskipTests</arguments>
                    <releaseProfiles>releaseInProgress</releaseProfiles>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>
 
### POM模型概念 Page Object Model (POM) 是一种设计模式,用于创建对象存储库来管理Web页面上的UI元素。通过这种方式,可以提高代码的可重用性和易维护性。在Selenium测试自动化中,POM有助于分离测试逻辑和页面交互细节。 #### 创建HomePage类作为示例 为了展示如何利用Python中的`Selenium WebDriver`实现POM,在下面的例子中定义了一个名为`HomePage`的类[^2]: ```python from selenium.webdriver.common.by import By class HomePage: login_link_locator = (By.LINK_TEXT, '登录') def __init__(self, driver): self.driver = driver def click_login_link(self): # 解包操作是因为login_link_locator是一个元组 self.driver.find_element(*self.login_link_locator).click() ``` 此段代码展示了如何封装特定网页组件的行为到独立的方法里,比如点击登录链接的动作被抽象成了`click_login_link()`方法。这不仅提高了代码清晰度还增强了模块化程度。 #### 继承机制优化POM结构 除了单独为每个页面编写对应的Page Object外,还可以考虑引入继承关系进一步简化公共部分的设计[^3]。例如,可以通过构建一个通用的基础页面模板(`Template_Page`),让其他具体页面从中派生而来,从而共享一些共有的属性或行为而不必重复声明它们。 ```python class TemplatePage: """A base template that other pages can inherit from.""" def __init__(self, driver): self.driver = driver # 所有非登录页都可以从这里派生 class AnotherPage(TemplatePage): pass ``` 这种做法特别适用于那些具有相似布局或者导航栏等特征的应用程序界面。 #### 测试框架集成建议 当采用`selenium4+pytest+allure+pom`组合来进行自动化测试开发时,需要注意配置编码设置以支持中文字符显示正常[^5]。如果遇到终端输出乱码的情况,则可以在项目的根目录下添加`pytest.ini`文件,并加入相应指令解决这一问题。 综上所述,POM提供了一种优雅的方式来组织基于浏览器端的功能测试脚本,使得整个过程更加直观高效的同时也便于后期维护更新工作。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值