I currently am working with a java/selenium project (written by another dev) where we loop through and excel sheet for the elements and their attributes and perform an action based on the condition (click, mousehover, etc). There is one button element that when clicked, it gets disabled, shows a different text while executing, then stays disabled but once data is loaded to a webpage, the button Text goes back to the original while staying disabled. See below for the snapshot of before click, after click and waiting for data to load, and after data is loaded along with the xpath of the element:
Before:
After data is loaded and process complete:
I have code below that works for performing the necessary actions based on the webElementType, since this is a button. What I would like is to be able to wait until this button says "Apply Filter" and still has the disabled attribute to it. How can I do that using java and selenium? See below code where click(element) is called where I am looking to wait for this specific scenario:
public void performAction() throws Throwable {
List<Locator> allLocators = this.eachWebElement.getAllPossibleLocators();
String webElementType = this.eachWebElement.getElementType();
String logText = "";
try {
WebElement element = getSuitableWebElement(allLocators);
List<WebElement> allElements = getSuitableWebElements(allLocators);
if (webElementType.equalsIgnoreCase("textBox")) {
logText = "to enter " + this.eachWebElement.getInputValue() + " in "
+ this.eachWebElement.getElementName() + " ";
// System.out.println("TEXT BOX - Execute Step : " + this.eachWebElement.getElementName());
enterText(element, this.eachWebElement.getInputValue().trim());
// ExtentCustom.eachTest.log(Status.PASS, MarkupHelper.createLabel(logText, ExtentColor.GREEN));
ExtentCustom.eachTest.pass(MarkupHelper.createLabel(logText, ExtentColor.GREEN));
} else if ("radiobuttoncheckboxbuttonlink".contains(webElementType.toLowerCase())) {
logText = "to click on " + this.eachWebElement.getElementName() + " ";
// click(getSuitableWebElement(allLocators));
click(element);
// ExtentCustom.eachTest.log(Status.PASS, MarkupHelper.createLabel(logText, ExtentColor.GREEN));
ExtentCustom.eachTest.pass(MarkupHelper.createLabel(logText, ExtentColor.GREEN));
} else if (webElementType.equalsIgnoreCase("movemouse")) {
logText = " mouse is moved to " + this.eachWebElement.getElementName();
// moveMouse(getSuitableWebElement(allLocators));
// System.out.println(" mouse is moved to ");
moveMouse(element);
// ExtentCustom.eachTest.log(Status.PASS, MarkupHelper.createLabel(logText, ExtentColor.GREEN));
ExtentCustom.eachTest.pass(MarkupHelper.createLabel(logText, ExtentColor.GREEN));
} else if (webElementType.equalsIgnoreCase("fileupload")) {
logText = " file is uploaded to " + this.eachWebElement.getElementName();
// moveMouse(getSuitableWebElement(allLocators));
// System.out.println(" fileupload code " + this.eachWebElement.getInputValue());
// System.out.println(allLocators);
uploadFile(element, this.eachWebElement.getInputValue());
// ExtentCustom.eachTest.log(Status.PASS, MarkupHelper.createLabel(logText, ExtentColor.GREEN));
ExtentCustom.eachTest.pass(MarkupHelper.createLabel(logText, ExtentColor.GREEN));
} else {
boolean selectedStatus = selectFromDropdown(allElements, this.eachWebElement.getInputValue().trim());
Assert.assertTrue(selectedStatus, this.eachWebElement.getInputValue().trim() + " not able to select, might be element value to select is wrong");
logText = "value " + eachWebElement.getInputValue().trim() + " got selected from the dropdown : "
+ this.eachWebElement.getElementName();
// ExtentCustom.eachTest.log(Status.PASS, MarkupHelper.createLabel(logText, ExtentColor.GREEN));
ExtentCustom.eachTest.pass(MarkupHelper.createLabel(logText, ExtentColor.GREEN));
}
} catch (Throwable t) {
throw t;
} finally {
// ExtentCustom.logResult(reportStatusLogger, logText);
}
}