private static GalenPageAction waitActionFrom(String[] args) {
    if (args.length < 2) {
      throw new SyntaxException("the timeout is not specified");
    }

    GalenPageActionWait wait = new GalenPageActionWait();
    wait.setTimeout(parseTimeout(args[1]));

    if (args.length > 2) {
      parseUntilConditions(wait, args);
    }
    return wait;
  }
  private static void parseUntilConditions(GalenPageActionWait wait, String[] args) {
    if (args[2].equals("until")) {
      if (args.length > 3) {
        List<GalenPageActionWait.Until> untilElements = new LinkedList<GalenPageActionWait.Until>();

        UntilType currentType = null;

        for (int i = 3; i < args.length; i++) {
          UntilType type = UntilType.parseNonStrict(args[i]);

          if (type != null) {
            currentType = type;
          } else {
            if (currentType == null) {
              throw new SyntaxException(
                  "You have to specify one of the following checks: visible, hidden, exist, gone");
            }

            untilElements.add(new GalenPageActionWait.Until(currentType, Locator.parse(args[i])));
          }
        }

        wait.setUntilElements(untilElements);
      } else throw new SyntaxException("You have to provide locators");
    } else throw new SyntaxException(String.format("Expected \"until\" but got \"%s\"", args[2]));
  }