【坑】自动化测试之Excel表格

参考一位大神的博客项目架构,把元素和数据都参数化,但是总是被excel表格坑

1.无法下拉

动作列通过下拉列表来控制,点击下拉列表无反应

解决方案:不知道是不是中间动了什么,因为Excel版本的问题,一直在调整,所以重新设置一遍

先设为任何值,之后再引入来源设为序列,下拉列表重新赋值

 2.运行代码最后一行报空指针

解决方案:有时候表格会有隐藏数据,所以直接断点查看了总行数,发现有11行,多了一条数据,所以直接删除即可

3.找不到文件 2.xlsx

然而我项目中并没有这个文件

所以,推测是数据问题,断点查看,神坑,

输入框有个空格,获取不到值,取的是序号的值,去掉成功了

4.版本问题

不管是一开始的驱动版本,还是现在的Excel版本,都调了好久,因为是自己调,所以花费了很长时间,所以把目前完整的pom文件记录下来

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3          xmlns="http://maven.apache.org/POM/4.0.0"
  4          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5     <modelVersion>4.0.0</modelVersion>
  6 
  7     <groupId>com.meiyunji.gogoMall</groupId>
  8     <artifactId>gogoMall</artifactId>
  9     <version>1.0-SNAPSHOT</version>
 10     <properties>
 11         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 12         <allure.version>1.4.23</allure.version>
 13         <aspectj.version>1.8.5</aspectj.version>
 14     </properties>
 15     <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java   web应用程序测试工具-->
 16     <dependencies>
 17         <dependency>
 18             <groupId>org.seleniumhq.selenium</groupId>
 19             <artifactId>selenium-java</artifactId>
 20             <version>LATEST</version>
 21         </dependency>
 22         <!-- https://mvnrepository.com/artifact/org.testng/testng    开源自动化测试框架-->
 23         <dependency>
 24             <groupId>org.testng</groupId>
 25             <artifactId>testng</artifactId>
 26             <version>6.9.5</version>
 27         </dependency>
 28         <!-- https://mvnrepository.com/artifact/log4j/log4j  日志-->
 29         <dependency>
 30             <groupId>log4j</groupId>
 31             <artifactId>log4j</artifactId>
 32             <version>1.2.16</version>
 33             <scope>provided</scope>
 34         </dependency>
 35         <!-- https://mvnrepository.com/artifact/net.sourceforge.jexcelapi/jxl  用java操作excel文件-->
 36         <dependency>
 37             <groupId>net.sourceforge.jexcelapi</groupId>
 38             <artifactId>jxl</artifactId>
 39             <version>2.6.12</version>
 40         </dependency>
 41         <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
 42         <dependency>
 43             <groupId>com.google.code.gson</groupId>
 44             <artifactId>gson</artifactId>
 45             <version>2.8.2</version>
 46         </dependency>
 47         <!-- https://mvnrepository.com/artifact/javax.mail/mail  发送邮件-->
 48         <dependency>
 49             <groupId>javax.mail</groupId>
 50             <artifactId>mail</artifactId>
 51             <version>1.5.0-b01</version>
 52         </dependency>
 53         <dependency>
 54             <groupId>com.codeborne</groupId>
 55             <artifactId>phantomjsdriver</artifactId>
 56             <version>1.2.1</version>
 57         </dependency>
 58         <dependency>
 59             <groupId>commons-configuration</groupId>
 60             <artifactId>commons-configuration</artifactId>
 61             <version>1.9</version>
 62         </dependency>
 63         <!--解析java源代码-->
 64         <dependency>
 65             <groupId>com.thoughtworks.qdox</groupId>
 66             <artifactId>qdox</artifactId>
 67             <version>1.12.1</version>
 68             <scope>compile</scope>
 69         </dependency>
 70         <dependency>
 71             <groupId>org.seleniumhq.selenium</groupId>
 72             <artifactId>selenium-remote-driver</artifactId>
 73             <version>LATEST</version>
 74         </dependency>
 75         <dependency>
 76             <groupId>commons-io</groupId>
 77             <artifactId>commons-io</artifactId>
 78             <version>2.5</version>
 79         </dependency>
 80         <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
 81         <dependency>
 82             <groupId>org.apache.poi</groupId>
 83             <artifactId>poi-ooxml</artifactId>
 84             <version>3.10-FINAL</version>
 85         </dependency>
 86         <!-- https://mvnrepository.com/artifact/org.apache.poi/ooxml-schemas -->
 87         <dependency>
 88             <groupId>org.apache.poi</groupId>
 89             <artifactId>ooxml-schemas</artifactId>
 90             <version>1.3</version>
 91         </dependency>
 92     </dependencies>
 93     <!--构建项目需要的信息-->
 94     <build>
 95         <!--使用的插件列表-->
 96         <plugins>
 97             <plugin>
 98                 <!--指定项目源码的jdk版本-->
 99                 <groupId>org.apache.maven.plugins</groupId>
100                 <version>3.1</version>
101                 <artifactId>maven-compiler-plugin</artifactId>
102                 <configuration>
103                     <source>1.8</source>
104                     <target>1.8</target>
105                 </configuration>
106             </plugin>
107         </plugins>
108     </build>
109 
110 </project>
View Code

猜你喜欢

转载自www.cnblogs.com/icy88/p/10211118.html