背景为了方便后续编写自动化ui接口便捷,进行的相应的调研。
开源地址GitHub:
https://github.com/selenide/selenide
文章地址:
https://selenide.org/documentation.html
1.建立maven工程,导入pom.xml文件.更新依赖
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2.编写代码:
package com.xm.UItestCase;
import com.codeborne.selenide.Configuration;
import org.openqa.selenium.By;
import org.testng.annotations.*;
import java.util.logging.Logger;
import static com.codeborne.selenide.Selenide.*;
public class UITest_open_exp {
private static Logger logger = Logger.getLogger("MyLogger");
@DataProvider(name = "testData")
public static Object[][] vars1() {
return new Object[][]{
{"chrome"},
{"chrome"},
{"chrome"},
};
}
@Test(dataProvider = "testData")
public void test(String vars1) {
System.setProperty("webdriver.chrome.driver", "/Users/XXXXX/Downloads/chromedriver");
// Configuration.browser="chrome";
Configuration.browser = vars1;
Configuration.baseUrl = "https://baidu.com";
System.out.println(System.getProperty("webdriver.chrome.driver"));
System.out.println("test--do--" + vars1);
open("/");
// $(By.id("userName")).setValue("100000");
// $(By.id("password")).setValue("100000");
logger.info("执行完成");
}
}
3.检查结果,具体api使用还需要继续研究。