-1

When we don't have a wait on the screen

<div id="divWait" style="cursor: wait; position: absolute; left: 0%; top: 0%; background: transparent; padding: 3px; width: 100%; height: 100%; display: none;">

But when the waiting part is ongoing the display part is gone so it becomes:

<div id="divWait" style="cursor: wait; position: absolute; left: 0%; top: 0%; background: transparent; padding: 3px; width: 100%; height: 100%;">

the snippet i added:

WebDriverWait w =new WebDriverWait(driver,10);
w.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("div//[@id='divWait']").getAttr‌ibute("disabled")));

but it didnt work

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Steve
  • 11
  • 2
  • Wait for Attribute change or wait to get attribute remove as “display” get removed – Muzzamil Jan 18 '20 at 14:13
  • i know, code for it? – Steve Jan 18 '20 at 14:42
  • Then what is the question? – Muzzamil Jan 18 '20 at 14:50
  • What does "it didn't work" mean? It didn't accomplish the intended task or it threw an error or ? Update your question with the info, e.g. full error message or a good description of what is or isn't happening. If the XPath you posted is what you are actually using, that's probably the error because it's not the correct syntax. You don't need an XPath here when you have an ID. What are you actually trying to do? Wait for the wait to appear on the screen or disappear or ??? Please edit your question and add more details. – JeffC Jan 18 '20 at 15:02

2 Answers2

0

We can wait for till display attribute is not present

WebDriverWait wait = new WebDriverWait(driver,60);

wait.until(new ExpectedCondition<Boolean>() {   
boolean isAttributeNotPresent= false;
    public Boolean apply(WebDriver driver) 
{
        WebElement button = driver.findElement(By.id("divWait"));

if(button.isDisplayed()
{

try{
        button.getAttribute("display");
} 
catch(Exception e)
 {
isAttributeNotPresent= true;
return isAttributeNotPresent;
}}
}});

Note: Ignore syntax error as I am typing from Mobile keypad

Muzzamil
  • 2,823
  • 2
  • 11
  • 23
0

Seems you were close. To wait for the property display: none to be removed from the style attribute instead of ExpectedConditions as invisibilityOfElementLocated() you have to induce WebDriverWait for visibilityOfElementLocated() and you can use either of the following Locator Strategies:

  • cssSelector:

    WebElement element = new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div#divWait")));
    
  • xpath:

    WebElement element = new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='divWait']")));
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352