selenide官方api: https://selenide.org/documentation.html
启动浏览器
1 package StartDriver; 2 import static com.codeborne.selenide.Selenide.* ; 3 import org.testng.annotations.Test; 4 public class TestStartDriver { 5 @Test 6 public void testFirefox(){ 7 //selenide默认使用Firefox浏览器 8 open("https://www.baidu.com/"); 9 } 10 @Test void testChrome(){ 11 //指定Driver 的存放目录 12 System.setProperty("webdriver.chrome.driver","c:/driver/chromedriver.exe"); 13 //指定需要启动的浏览器类型 14 System.setProperty("selenide.browser", "Chrome"); 15 //System.setProperty("selenide.browser", "Ie"); 16 //打开测试地址 17 Selenide.open("https://www.baidu.com/"); 18 } 19 }
八大元素定位,其中id、name、xpath 能完成95%的元素定位
原文:https://www.cnblogs.com/annawong/p/11171797.html