1 Reply Latest reply on Jun 4, 2014 9:53 AM by Juraj Húska

    problems with Graphene guards

    Davide Gesino Newbie

      I'm having had times trying to using the arquillian extensions drone and graphene.

      I use Arquillian 1.1.3 final, drone 1.3.0.Final and graphene 2.0.2.Final, but I rely on Selenium 2.41 (added top selenium BOM before arquillian dependencies), and test against Firefox 27.

      The app I'm testing is highly dynamic, as it has been developed using backbone.js, thus all the HTML components I interact with are guarded by"isPresent", "isVisible".

       

      The point is, on my machine all my tests work fine, but as I move to a faster machine the tests fail randomly, though I have added all the required guards.


      To do so I use an utility function that relies on Graphene guards.

       

        private static void waitForElementToBePresent(By sel,SearchContext ctx) {

                      Graphene.waitGui()

                              .withTimeout(40, TimeUnit.SECONDS)

                              .pollingEvery(2, TimeUnit.SECONDS)

                              .until()

                              .element(ctx,sel)

                              .is().present();

       

              }


        private static void waitForElementToBeVisible(By sel,SearchContext ctx) {

                      Graphene.waitGui()

                              .withTimeout(40, TimeUnit.SECONDS)

                              .pollingEvery(2, TimeUnit.SECONDS)

                              .until()

                              .element(ctx,sel)

                              .is().visible();

       

              }

       

      I don't use Grahpene page injection feature.

      My tests al look like this:

       

       

      @Drone

      WebDriver browser;

       

      public void myTest(){

       

                      browser.get("myUrl");

                      browser.navigate().refresh();

       

                      final WebElement body = browser.findElement(ByJQuery.selector("body"));

                      waitForElementToBePresent(ByJQuery.selector("body"),browser);

       

                    

                      /**

                       * selecting the following jquery expression with all the required guards

                       * $(".ebAccordion:first").find(".ebAccordion").eq(0).find(".ebCheckbox:first")

                       */

                      waitForElementToBePresent(ByJQuery.selector(".ebAccordion:first"),body);

                      WebElement firstLevelAccordion =body.findElement(ByJQuery.selector(".ebAccordion:first"));

       

                      waitForElementToBePresent(ByJQuery.selector(".ebAccordion"),firstLevelAccordion);

                      WebElement secondLevelAccordion = firstLevelAccordion.findElement(ByJQuery.selector(".ebAccordion:first"));

       

                      waitForElementToBePresent(ByJQuery.selector(".ebCheckbox:first"),secondLevelAccordion);

                      WebElement cardCheckBox  = secondLevelAccordion.findElement(ByJQuery.selector(".ebCheckbox:first"));

       

                      cardCheckBox.click();

       

      In every test I navigate to a different page, then I calculate from scratch all the elements I need to interact with, starting from the browser.

       

      Am I using drone+graphene in a wrong way, or there are still issues on Graphene guards?

      THe workaround is to add plenty of sleep after every interaction with a WebElement (click and so on), but I would like to go with a different way if possible.

       

      Thanks a lot