1、WebDriver处理一些弹窗
import java.util.Set; import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.NoAlertPresentException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.ie.InternetExplorerDriver; 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 java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import com.mysql.jdbc.Connection; class ConnMySQL { public void connection() throws Exception{ while(rs1.next()){ |
4、创建EXCEL
// 生成Excel的类 import java.io.File; import jxl.Workbook; public class CreateExcel{ class Create_Excel{ // 将定义好的单元格添加到工作表中 /* // 写入数据并关闭文件 }catch(Exception e){ |
5、读取EXCEL
// 读取Excel的类 import java.io.File; import jxl.Cell; /* |
6、更新EXCEL
import java.io.File; import jxl.Workbook; import jxl.write.Label; import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; public class UpdateExcel{ |
7、WebDriver判断元素是否存在
import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; /* |
8、java下载图片
import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Date; import java.util.List; 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 java.io.FileWriter; import java.io.InputStream; import java.io.InputStreamReader; 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; import java.io.FileWriter; import java.io.IOException; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class ToLog { @SuppressWarnings("deprecation") |
1、WebDriver处理一些弹窗
import java.util.Set; import org.openqa.selenium.Alert; import org.openqa.selenium.By; import org.openqa.selenium.NoAlertPresentException; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.ie.InternetExplorerDriver; 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 java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import com.mysql.jdbc.Connection; class ConnMySQL { public void connection() throws Exception{ while(rs1.next()){ |
4、创建EXCEL
// 生成Excel的类 import java.io.File; import jxl.Workbook; public class CreateExcel{ class Create_Excel{ // 将定义好的单元格添加到工作表中 /* // 写入数据并关闭文件 }catch(Exception e){ |
5、读取EXCEL
// 读取Excel的类 import java.io.File; import jxl.Cell; /* |
6、更新EXCEL
import java.io.File; import jxl.Workbook; import jxl.write.Label; import jxl.write.WritableSheet; import jxl.write.WritableWorkbook; public class UpdateExcel{ |
7、WebDriver判断元素是否存在
import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; /* |
8、java下载图片
import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; import java.util.Date; import java.util.List; 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 java.io.FileWriter; import java.io.InputStream; import java.io.InputStreamReader; 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; import java.io.FileWriter; import java.io.IOException; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class ToLog { @SuppressWarnings("deprecation") |
最新内容请见作者的GitHub页:http://qaseven.github.io/