自動化測試中用到的一些功能類
1、WebDriver處理一些彈窗
import java.util.Set; public class AlertOperate { |
2、一些數據類型轉換
public class Chanage { //int to String public static String IntToString(int i){ String s = Integer.toString(i); return s; } //String to int public static int StringToInt(String s){ int i = Integer.parseInt(s); return i; } } |
3、和數據庫交互
import java.sql.DriverManager; import com.mysql.jdbc.Connection; class ConnMySQL { public void connection() throws Exception{ while(rs1.next()){ |
4、創建EXCEL
// 生成Excel的類 import jxl.Workbook; public class CreateExcel{ class Create_Excel{ // 將定義好的單元格添加到工作表中 /* // 寫入數據并關閉文件 }catch(Exception e){ |
5、讀取EXCEL
// 讀取Excel的類 import jxl.Cell; /* |
6、更新EXCEL
import java.io.File; public class UpdateExcel{ |
7、WebDriver判斷元素是否存在
import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; /* |
8、java下載圖片
import java.io.File; import org.apache.http.HttpEntity; import com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException; public class Movision_verifyImage { } if (entity != null && entity.isStreaming()) { // 將取得的文件文件流寫入目標文件 while ((j = is.read(b)) != -1) { |
9、java遠程登錄linux并執行命令
import java.io.BufferedReader; import ch.ethz.ssh2.Connection;
FileWriter fw = new FileWriter("F:\\vmstat.txt"); // OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("data2.txt")); } |
10、java將控制臺打印寫入日志文件
import java.io.File; public class ToLog { @SuppressWarnings("deprecation") |
寫分享這么多吧~各位,晚安!
posted on 2013-09-10 11:17 順其自然EVO 閱讀(447) 評論(0) 編輯 收藏 所屬分類: selenium and watir webdrivers 自動化測試學習