Java Selenium应用按钮在组合框上不起作用?
我对应用按钮有问题。我有组合框过滤器,一切都很好,它是在方块之间切换。但当它假设要应用时,不知何故它只是继续,就像它没有被选中一样,测试成功完成,但我不需要过滤 有人可以检查我的代码和部分与督察错误。也许我错过了什么 我的Java代码:Java Selenium应用按钮在组合框上不起作用?,java,selenium,selenium-webdriver,selenium-ide,Java,Selenium,Selenium Webdriver,Selenium Ide,我对应用按钮有问题。我有组合框过滤器,一切都很好,它是在方块之间切换。但当它假设要应用时,不知何故它只是继续,就像它没有被选中一样,测试成功完成,但我不需要过滤 有人可以检查我的代码和部分与督察错误。也许我错过了什么 我的Java代码: if (type.equals("")) { elementList = driver.findElements(By.xpath("//div[@id='" + id + "_menu']//a[@class='FIText']")); if (e
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>
取消
申请
有人能检查一下这个吗?
我不知道为什么它不起作用?也许有人知道如何测试它
比尔,
Marija为了清楚起见,此解决方案将查找显示的元素并单击它
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();
}
}
WebDriverWait wait=newwebdriverwait(驱动程序,10);
WebElement element=wait.until(ExpectedConditions.elementtobelickable(By.cssSelector(“div.cfapplybuttonocationner”));
List element列表=driver.findElements(By.cssSelector(“div.cfapplybuttoncontinner>按钮”);
for(WebElement元素:元素列表){
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";
}
}
}
现在它工作正常,但现在我需要测试它以检查输出。如果有更好的解决方案,请告诉我。如果您认为它有帮助,请竖起大拇指!!