作为我测试的一部分,系统应该查明用于打开网站的设备是移动设备还是普通桌面.
我一直收到错误:
"InvalidSelectorError:无法找到带有xpath表达式的元素//*[contains(@class,is-mobile ..."
萤火虫的财产:
<body class="login-page is-desktop">
Run Code Online (Sandbox Code Playgroud)
我的测试:
public class isMobile {
public static boolean isMobile = false;
public static boolean checkIfMobile(WebDriver driver) throws Exception {
List<WebElement> list = driver.findElements(By
.xpath("//body[contains(@class, 'is-mobile'"));
if (list == null) {
return false;
} else {
return true;
}
}
}
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我正确的XPath应该如何?