asdasdasdasd

package com.testET.util;


import java.net.URL;


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriver.Navigation;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.safari.SafariDriver;


import com.opera.core.systems.OperaDriver;
/**
 * @author liuxin
 * 
 * Selenium 工具类
 * */
public class ETUtils {

/********/
private static ETUtils model = new ETUtils();

private static WebDriver webDriver;
private static Navigation navigation;

private ETUtils(){}

public static ETUtils getInstance(){

return model;
}


/**
* 浏览器设定
* 实例化Selenium2对象

* @param Int browserString 
* 1,谷歌
* 2,火狐
* 3,IE
* 4,Opera
* 5,Safari
* */
public void setBrowser(int browserInt,String driverPath){
//"C:/Program Files/Chrome WebDriver/chromedriver.exe"
switch(browserInt){
case 1:
System.setProperty("webdriver.chrome.driver",driverPath);
webDriver = new ChromeDriver();
break;
case 2:
System.setProperty("webdriver.firefox.driver",driverPath);
webDriver = new FirefoxDriver();
break;
case 3:
System.setProperty("webdriver.internetExplorer.driver",driverPath);
webDriver = new InternetExplorerDriver();
break;
case 4:
System.setProperty("webdriver.opera.driver",driverPath);
webDriver = new OperaDriver();
break;
case 5:
//对Safari的支持由于技术限制在本版本中未包含
System.setProperty("webdriver.safari.driver",driverPath);
webDriver = new SafariDriver();
break;
}
}

/**
* 地址导航

* @param String url
* */
public void UrlNav(String url){
navigation = webDriver.navigate();
navigation.to(url);
}

/**
* 地址导航

* @param URL url
* */
public void UrlNav(URL url){
navigation = webDriver.navigate();
navigation.to(url);
}

/**
* 事件处理函数

* @param xpath  String   
* @param case事件  int

* 1,按钮事件
* 2,输入事件

* */
public void handleClickEvent(String xpath){

WebElement webEle = webDriver.findElement(By.xpath(xpath));
webEle.click();

}
public void handleInputEvent(String xpath , String inputString){
  
WebElement webEle = webDriver.findElement(By.xpath(xpath));
   webEle.clear();
   webEle.sendKeys(inputString);   
}



}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值