我需要选中/取消选中图片上标有蓝色的复选框。问题是我必须检查复选框是否来自带有窗帘标签的列表。 我的脚本必须做这样的事情:
@Test public void test_calls_backend_functionY_and_returns_formatted_reply() { ... }
答案 0 :(得分:1)
尝试以下代码:
IWebElement element = driver.findElement(By.xpath("//span[contains(text(),'Articles Expenses')]/../../ul[1]/li/div/div/span/input")); /*select first element/checkbox from the first menu i.e., Articles Expenses */
if (element.Selected) /* if checkbox is already selected */
{
element.Click(); /* uncheck the checkbox if already selected */
}