/** * Create an instance of {@link Action } * */ public Action createAction() { return new Action(); }
@Override public String doRender(Object o) { if (!(o instanceof Action)) return null; Action action = (Action) o; Webelement self = action.getWebelement(); StringBuilder builder = new StringBuilder(); builder.append(self.getType() + " " + self.getName()); builder.append(" -> " + action.getName()); String arg = action.getArg().size() > 0 ? " " + action.getArg().toString() : ""; builder.append(arg); return builder.toString(); }
/** * Create action with specified name for webelement self. * * @param self - instance of class that support DescribedElement * @param name - name of returned Action * @return created Action instance */ protected Action getAction(DescribedElement self, String name) { Action action = factory.createAction(); action.setName(name); action.setWebelement((Webelement) element(self)); return action; }
@Override public Object get(DescribedElement self, String url) { Action action = getAction(self, "get"); action.getArg().add(url); return action; }
@Override public Object sendKeys(DescribedElement self, CharSequence... keysToSend) { Action action = getAction(self, "send keys"); StringBuilder builder = new StringBuilder(); for (CharSequence key : keysToSend) { builder.append(key); } action.getArg().add(builder.toString()); return action; }
@Override public Object dragAndDropOn(DescribedElement self, DescribedElement element) { Action action = getAction(self, "drag and drop by"); action.getArg().add(element); return action; }