標籤:圖片 font span browser tps .com 通過 log config
1.主要介紹介紹Java+Selenium+POM的自動化測試架構的搭建,第一個首先實現代碼和帳號URL等資訊的分離。第二點支援跨瀏覽器,通過讀取設定檔的方式實現。
1)將帳號URL等資訊添加在properties檔案中然後讀取
2)編寫瀏覽器類通過去取設定檔實現瀏覽器的切換
3)測試瀏覽器類
項目結構:
1.建立一個檔案夾將properties檔案放在檔案夾中內容如下:
# browser switcher
#browserName = Firefox
browserName = Chrome
#browserName = IE
# test server switcher
URL=https://portal.rrx360.com
#URL=https://taobao.com
2.寫一個解析properties檔案類的方法去讀取檔案擷取需要的資訊
package com.rrx.framework;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
public class PropertiesEngine {
public static String getProperties(String name) throws IOException {
Properties properties=new Properties();
properties.load(new FileInputStream(".\\TestConfig\\config.properties") );
String zhi=properties.getProperty(name);
return zhi;
}
}
java+Selenium+TestNg搭建自動化測試架構(1)實現代碼和資料的分離