Uploaded image for project: 'ZATS'
  1. ZATS
  2. ZATS-20

Unable to query for empty desktop

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 1.2.0
    • 1.1.0
    • Mimic
    • None

      I am trying to validate that popup window closes correctly
      The window closes by:

      @ContextParam(ContextType.VIEW)
      private Component self;

      self.detach();

      Then in my ZATS test I close the window by:
      desktop.query("button[label='Close']").click();

      and then I query for this window and expect it to be null:
      assertNull(desktop.query("#win"));

      But instead I get this exception:
      org.zkoss.zats.ZatsException
      at org.zkoss.zats.mimic.impl.Searcher.findAll(Searcher.java:107)
      at org.zkoss.zats.mimic.impl.Searcher.find(Searcher.java:118)
      at org.zkoss.zats.mimic.impl.DefaultDesktopAgent.query(DefaultDesktopAgent.java:90)
      <some calls in my code>
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80)
      at org.testng.internal.Invoker.invokeMethod(Invoker.java:702)
      at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:894)
      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1219)
      at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
      at org.testng.TestRunner.privateRun(TestRunner.java:768)
      at org.testng.TestRunner.run(TestRunner.java:617)
      at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
      at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
      at org.testng.SuiteRunner.run(SuiteRunner.java:240)
      at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
      at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87)
      at org.testng.TestNG.runSuitesSequentially(TestNG.java:1185)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:1110)
      at org.testng.TestNG.run(TestNG.java:1022)
      at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:109)
      at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
      at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)
      Caused by: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.zkoss.zats.mimic.impl.Searcher.findAll(Searcher.java:74)
      ... 29 more
      Caused by: java.lang.NullPointerException
      at org.zkoss.zk.ui.select.impl.ComponentIterator.buildRootCtx(ComponentIterator.java:210)
      at org.zkoss.zk.ui.select.impl.ComponentIterator.seekNext(ComponentIterator.java:192)
      at org.zkoss.zk.ui.select.impl.ComponentIterator.loadNext(ComponentIterator.java:187)
      at org.zkoss.zk.ui.select.impl.ComponentIterator.hasNext(ComponentIterator.java:146)
      at org.zkoss.zk.ui.select.Selectors.toList(Selectors.java:341)
      at org.zkoss.zk.ui.select.Selectors.find(Selectors.java:86)
      ... 34 more

      This happens because the code in ComponentIterator does not expect that there may be no root components at all e.g. that that desktop is empty:

      package org.zkoss.zk.ui.select.impl;

      public class ComponentIterator implements Iterator<Component> {

      private ComponentMatchCtx buildRootCtx() {
      Component rt = _root == null ? _page.getFirstRoot() : _root;

      Component rt2 = rt.getFellowIfAny(seq.getId());

      Please have a look and fix

            paowang paowang
            m17 m17
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: