启动网页始终还是 WEB 端的网页,H5 的配置也没有生效
代码如下
public class runtest {
WebDriver driver;
@BeforeClass
public void beforeClass(){
System.setProperty("webdriver.chrome.driver", "resources/chromedriver.exe");
Map<String, String> mobileEmulation = new HashMap<String, String>();
//设置设备,例如:Google Nexus 7/Apple iPhone 6
//mobileEmulation.put("deviceName", "Google Nexus 7");
mobileEmulation.put("deviceName", "Apple iPhone 6 Plus"); //这里是要使用的模拟器名称,就是浏览器中模拟器中的顶部型号
Map<String, Object> chromeOptions = new HashMap<String, Object>();
chromeOptions.put("mobileEmulation", mobileEmulation);
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
try {
System.out.println("开始启动driver~~~");
driver = new ChromeDriver(capabilities);
System.out.println("启动driver成功~~~");
} catch (Exception e) {
System.out.println("启动driver失败~~~");
System.out.println(e.getMessage());
}
}
@Test
public void run(){
driver.get("http://www.wenshushu.cn/");
System.out.println("使用浏览器,进入到了页面");
}
大佬们,该如何修改呢?