Currently working with selenium Java code and incorporating JavaScript execution using the executeScript method, as seen below:
WebElement menu = driver.findElement(By.cssSelector(string1));
((JavascriptExecutor) driver).executeScript("arguments[0].click();", menu);
I am aiming to determine if an element is clickable. If the button is disabled, the click event will not fire, so I require a flag. The issue lies in the fact that a click event in JS returns undefined.
Thus, I need to implement a flag within my executeScript like so:
Object flag_to_stop = ((JavascriptExecutor) driver).executeScript("<<something here if returns true string else returns false string>>, menu);
while (Object.toString.equals(<<true string>>))
This way, I can run a while loop and break out of it if flag_to_stop is false;
Open to any suggestions folks!
Please note, this question pertains more to JavaScript, with all the provided Java code for reference.