1. 程式人生 > >【坑】自動化測試之Excel表格

【坑】自動化測試之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