Selenium Apply 按钮在组合框上不起作用?
Selenium Apply button not working on combo box?
我的应用按钮有问题。我有组合框过滤器,一切都很好,它在 squares.But 之间切换,当它应该应用时,不知何故它只是继续,就像它没有选择任何东西并且测试成功完成,但没有我需要的过滤。
有人可以检查我的代码并解决检查器错误。也许我遗漏了什么?
我的Java代码:
if (type.equals("")) {
elementList = driver.findElements(By.xpath("//div[@id='" + id + "_menu']//a[@class='FIText']"));
if (elementList.size() > 0) {
if (driver.findElements(By.xpath("//div[@id='" + id + "_menu']//div[@class='CFApplyButtonContainer']//button[@class='tab-button']//span[@class='label'][text()='Apply']/..")).size() > 0) {
type = "multi_checkbox_with_apply";
}else {
type = "multi_checkbox_without_apply";
}
}
}
检查器错误:
<div class="CFApplyButtonConatiner" style="height: 21px;">
<button class="tab-button tab-widget disabled" type="button" style="max-width: 56px" disabled="">
<span class="icon"></span>
<span class="label">Cancel</span>
</button>
<button class="tab-button tab-widget focus disabled" type="button" style="max-width: 56px" disabled="">
<span class="icon"></span>
<span class="label">Apply</span>
</button>
有人可以检查一下吗?
我不知道为什么它不起作用?也许有人知道如何测试它。
BR,
玛丽亚
明确一点,此解决方案将查找显示的元素并点击它!!
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("div.CFApplyButtonConatiner"))));
List<WebElement> elementsList = driver.findElements(By.cssSelector("div.CFApplyButtonConatiner > button");
for(WebElement ele: elementsList) {
if(ele.isDisplayed()) {
ele.click();
}
}
我已经使用了像 Ranijth 的建议:
if (type.equals("")) {
elementList = driver.findElements(By.xpath("//div[@id='" + id + "_menu']//a[@class='FIText']"));
if (elementList.size() > 0) {
//if (driver.findElements(By.xpath("//div[@id='" + id + "_menu']//div[@class='CFApplyButtonContainer']//button[@class='tab-button']//span[@class='label'][text()='Apply']/..")).size() > 0) {
if (driver.findElements(By.cssSelector("div.CFApplyButtonConatiner > button"))!=null) {
//if (driver.findElements(By.cssSelector("div.CFApplyButtonConatiner > button")).size() > 0) {
type = "multi_checkbox_with_apply";
}
else {
type = "multi_checkbox_without_apply";
}
}
}
现在它工作正常,但现在我需要测试它以检查输出。如果有人有更好的解决方案,请告诉我。
我的应用按钮有问题。我有组合框过滤器,一切都很好,它在 squares.But 之间切换,当它应该应用时,不知何故它只是继续,就像它没有选择任何东西并且测试成功完成,但没有我需要的过滤。
有人可以检查我的代码并解决检查器错误。也许我遗漏了什么?
我的Java代码:
if (type.equals("")) {
elementList = driver.findElements(By.xpath("//div[@id='" + id + "_menu']//a[@class='FIText']"));
if (elementList.size() > 0) {
if (driver.findElements(By.xpath("//div[@id='" + id + "_menu']//div[@class='CFApplyButtonContainer']//button[@class='tab-button']//span[@class='label'][text()='Apply']/..")).size() > 0) {
type = "multi_checkbox_with_apply";
}else {
type = "multi_checkbox_without_apply";
}
}
}
检查器错误:
<div class="CFApplyButtonConatiner" style="height: 21px;">
<button class="tab-button tab-widget disabled" type="button" style="max-width: 56px" disabled="">
<span class="icon"></span>
<span class="label">Cancel</span>
</button>
<button class="tab-button tab-widget focus disabled" type="button" style="max-width: 56px" disabled="">
<span class="icon"></span>
<span class="label">Apply</span>
</button>
有人可以检查一下吗? 我不知道为什么它不起作用?也许有人知道如何测试它。
BR, 玛丽亚
明确一点,此解决方案将查找显示的元素并点击它!!
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("div.CFApplyButtonConatiner"))));
List<WebElement> elementsList = driver.findElements(By.cssSelector("div.CFApplyButtonConatiner > button");
for(WebElement ele: elementsList) {
if(ele.isDisplayed()) {
ele.click();
}
}
我已经使用了像 Ranijth 的建议:
if (type.equals("")) {
elementList = driver.findElements(By.xpath("//div[@id='" + id + "_menu']//a[@class='FIText']"));
if (elementList.size() > 0) {
//if (driver.findElements(By.xpath("//div[@id='" + id + "_menu']//div[@class='CFApplyButtonContainer']//button[@class='tab-button']//span[@class='label'][text()='Apply']/..")).size() > 0) {
if (driver.findElements(By.cssSelector("div.CFApplyButtonConatiner > button"))!=null) {
//if (driver.findElements(By.cssSelector("div.CFApplyButtonConatiner > button")).size() > 0) {
type = "multi_checkbox_with_apply";
}
else {
type = "multi_checkbox_without_apply";
}
}
}
现在它工作正常,但现在我需要测试它以检查输出。如果有人有更好的解决方案,请告诉我。