Skip to content
Advertisement

Pause code execution if progress bar is displayed

I use this code to pause code execution:

new WebDriverWait(driver, 30).until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//div[@class='ngx-loading-text center-center' and starts-with(., 'Loading')]")));

Unfortunately the html code is changed this way:

<ngx-spinner _ngcontent-eas-c0="" bdcolor="rgba(255, 255, 255, 0.9)" color="#0070A0" size="medium" type="square-jelly-box" _nghost-eas-c1="">
   <!---->
   <div _ngcontent-eas-c1="" class="overlay" style="background-color: rgba(255, 255, 255, 0.9); position: fixed;">
      <div _ngcontent-eas-c1="" class="la-square-jelly-box la-2x" style="color: rgb(0, 112, 160);">
         <!---->
         <div _ngcontent-eas-c1=""></div>
         <div _ngcontent-eas-c1=""></div>
      </div>
      <div _ngcontent-eas-c1="" class="loading-text"><span _ngcontent-eas-c0="" class="spinner">Please Wait ...</span></div>
   </div>
</ngx-spinner>

I tried to implement this code”

new WebDriverWait(driver, 30).until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//div[@class='spinner' and starts-with(., 'Loading')]")));

But the code execution is not paused. Can you advise how to implement his properly?

Advertisement

Answer

See if this xpath works.

wait.until(ExpectedConditions.invisibilityOfElementLocated(By.xpath("//div[@class='loading-text']/span[@class='spinner']"))

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement