wttech/bobcat

How to refactor @Loadable Webelement in Bobcat 2.0

DeChrish opened this issue · 4 comments

Environment

Bobcat version:
1.5

Bobcat modules used:

  • bb-core
    , JUnit-->

Browser + version:

Expected Behavior

1.5 supports @Loadable

Actual Behavior

Breaking Changes in 2.0

Steps to reproduce

Loading icon <div> is added/ removed from the DOM based on user action.
Example: Once user enters userid and password and submits, loading indicator <div> will be attached to the DOM till the user get authenticated. Once it is completed the loading indicator <div> will be removed from the DOM.

@Loadable is heavy used to address this issue in the existing test suite.
We need to find out how to solve this problem while migrating to 2.0

Hi @DeChrish!

@Loadable executed the provided condition before interacting with a given element. You can achieve the same manually with BobcatWait.

In the example you have provided, that would be something like this:

@Inject
private BobcatWait wait;
//...
submitTheForm();
wait.until(ExpectedConditions.invisibilityOfElementLocated(<your div locator>));

If the above acts weird (e.g. due to the fact that the loader is blinking), you might want to tweak it as follows (check if the loader appears, then check if it's gone):

  public void waitUntilLoadingIsDone() {
    try {
      wait.ignoring(StaleElementReferenceException.class) // this should take care of the loader disappearing during condition evaluation 
          .until(visibilityOf(<loader element>));
    } catch (TimeoutException e) {
       // ignoring the exception here
    }
    wait.until(invisibilityOf(<loader element>));
  }

@mkrzyzanowski Thanks for the updates, we are in middle of migration- i will test this code snippet and close this issue.

@mkrzyzanowski Thanks. it is working