我有两种形式:
<form action="" method="post" name="form1" id="form1" target="_self">
///
</form>
<style>
form#form2 {
display: none;
}
</style>
<form action="" method="get" name="form2" id="form2" target="_blank">
////
</form>
我有以下代码:
WebDriver driver = new HtmlUnitDriver();
List<WebElement> forms = driver.findElements(By.cssSelector("form"));
for (WebElement form : forms) {
if (!form.isDisplayed()) break;
System.out.print(form.ToString() + "\n");
}
在控制台中,我看到:
<form action="" method="post" name="form1" id="form1" target="_self">
<form action="" method="get" name="form2" id="form2" target="_blank">
如何检查表单是否不可见?
问题的解决方案。
WebDriver driver = new HtmlUnitDriver(**true**);