代码如下:
类 MainTest.java:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriver.Window;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.selenium.CommonUtils;
public class MainTest{
private static final Logger logger = LoggerFactory.getLogger(MainTest.class);
public static void main(String[] args){
CommonUtils.killSelenium();
WebDriver driver = initChrome(); // 打开浏览器
logger.info( "###################################### 测试开始 ######################################" );
driver.get( CommonUtils.Test_SysUrl);// 访问指定网址
test_01(driver);
logger.info("###################################### 测试结束 ######################################" );
CommonUtils.killSelenium();
// logger.info("- - - - - - - - - - - - - - - - - - 已结束所有进程 - - - - - - - - - - - - - - - - - -");
}
/**
* 创建一个接口并审核
* @param driver
*/
public static void test_01(WebDriver driver){
if(! new Login().doIt( driver , CommonUtils.uid, CommonUtils.uname) ){
CommonUtils.killSelenium();
}
}
/**
* 打开浏览器,但是还未输入网址
* @return
*/
public static WebDriver initChrome(){
System.setProperty("webdriver.chrome.driver",CommonUtils.chromePath246);// 设置驱动类型和位置
ChromeOptions options = new ChromeOption