private Component(String name) {
   final String id =
       name.substring(0, 1).toLowerCase()
           + WordUtils.capitalize(name).replace(" ", "").substring(1);
   GrapheneContext context = GrapheneContext.getContextFor(Default.class);
   final WebDriver browser = context.getWebDriver();
   this.select =
       GrapheneProxy.getProxyForHandler(
           GrapheneContextualHandler.forFuture(
               context,
               new GrapheneProxy.FutureTarget() {
                 @Override
                 public Object getTarget() {
                   return new Select(
                       browser.findElement(By.cssSelector("select[id$=" + id + "Select]")));
                 }
               }),
           Select.class);
   this.output =
       WebElementUtils.findElementLazily(
           By.cssSelector("span[id$=" + id + "ValueOutput]"), browser);
   this.input =
       WebElementUtils.findElementLazily(
           ByJQuery.selector("input:text[id$=" + id + "ValueInput]"), browser);
   this.link =
       WebElementUtils.findElementLazily(
           ByJQuery.selector("input:submit[id$=" + id + "ValueButton]"), browser);
   this.executeOption = name;
 }
Example #2
0
 public static WebElement unwrap(WebElement element) {
   Preconditions.checkNotNull(element, "The element cannot be null.");
   WebElement result = element;
   while (GrapheneProxy.isProxyInstance(result)) {
     result = ((GrapheneProxyInstance) result).unwrap();
   }
   return result;
 }
Example #3
0
 private static <T> T requestTimeWaiting(T target, Interceptor interceptor) {
   GrapheneProxyInstance proxy;
   if (GrapheneProxy.isProxyInstance(target)) {
     proxy = (GrapheneProxyInstance) ((GrapheneProxyInstance) target).copy();
   } else {
     throw new IllegalStateException("Can't create a new proxy.");
   }
   proxy.registerInterceptor(interceptor);
   return (T) proxy;
 }