title: Cannot cast WebElement to org.openqa.selenium.internal.Locatable
body: <p>I am trying to automate resize a column from a table, by using Actions class this is my code:</p>
  
  <pre><code>public boolean resizeColumn(String columnToResize, String toColumn) {
      try {
          WebElement column = findElement(columnResize, columnToResize);
          WebElement moveToPosition = findElement(columnByName, toColumn);
          waitUntilClickable(column);
          //click on resize
          getSupport().clickAndHold(column);
          ..
          ...
  </code></pre>
  
  <p>In PageSupport class:</p>
  
  <pre><code>public void clickAndHold(WebElement onElement) {
      Actions actions = new Actions(driver);
      actions.clickAndHold(onElement);
  }
  </code></pre>
  
  <p>In Actions class:</p>
  
  <pre><code> public Actions clickAndHold(WebElement onElement) {
      action.addAction(new ClickAndHoldAction(mouse, (Locatable) onElement));
      return this;
    }
  </code></pre>
  
  <p>But I get the following error: </p>
  
  <blockquote>
    <p>java.lang.ClassCastException: eu.ohim.tmdsview.selenium.util.WebElementProxy cannot be cast to org.openqa.selenium.internal.Locatable</p>
  </blockquote>
  
  <p>Apparently it does not like the cast to Locatable, any ideas? Thanks in advance!</p>
  
  <p><strong>UPDATE- WebElementProxy class</strong></p>
  
  <pre><code>package eu.ohim.tmdsview.selenium.util;
  
  import java.util.List;
  
  import org.openqa.selenium.By;
  import org.openqa.selenium.Dimension;
  import org.openqa.selenium.Point;
  import org.openqa.selenium.WebDriver;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.internal.WrapsElement;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  
  import eu.ohim.tmdsview.test.TestEnv;
  
  /**
   * &lt;class&gt;WebElementProxy&lt;/class&gt;. Defines all the interaction manners that the framework 
   * may perform with the application. 
   * @implements WebElement, WrapsElement
   *
   */
  public class WebElementProxy implements WebElement, WrapsElement {
  
  private final Logger logger = LoggerFactory.getLogger(getClass());
  
  private By locator;
  
  private WebDriver searchContext;
  
  private WebElement element;
  
  /**
   * WebElementProxy. Overloaded constructor.
   * @param searchContext. Webdriver search content
   * @param locator. By element
   */
  public WebElementProxy(WebDriver searchContext, By locator) {
      this.locator = locator;
      this.searchContext = searchContext;
  }
  
  /**
   * WebElementProxy. Overloaded constructor.
   * @param searchContext. Webdriver search content
   * @param element. Webelement object
   */
  public WebElementProxy(WebDriver searchContext, WebElement element) {
      this.element = element;
      this.searchContext = searchContext;
  }   
  
  /**
   * &lt;method&gt;getElement&lt;/method&gt; method: recovers to the framework the WebElement selected to use it 
   * @return the WebElement selected
   */
  private WebElement getElement() {
      //If the element is not null, the framework returns it
      if(element != null) {
          return element;
      } else {
          //If the elements has not found, the framework prints the problematic locator 
          logger.trace("findElement() [{}]", locator);
          return searchContext.findElement(locator);
      }
  }
  
  /**
   * &lt;method&gt;click&lt;/method&gt; method: search the element and does click on it
   */
  public void click() {
      infoWithScrenshot("click() [{}]", locator);
      getElement().click();
  }
  
  /**
   * &lt;method&gt;submit&lt;/method&gt; method: search the element and submits it
   */
  public void submit() {
      infoWithScrenshot("submit() [{}]", locator);
      getElement().submit();
  }
  
  /**
   * &lt;method&gt;sendKeys&lt;/method&gt; method: search the element and writes the text passed as a parameter
   * @param CharSequence... keysToSend. Text to writes on the application
   */
  public void sendKeys(CharSequence... keysToSend) {
      infoWithScrenshot("sendKeys() [{}] to element [{}]", keysToSend, locator);
      getElement().sendKeys(keysToSend);
  }
  
  /**
   * &lt;method&gt;clear&lt;/method&gt; method: search the element and clears it
   */
  public void clear() {
      infoWithScrenshot("clear() [{}]", locator);
      getElement().clear();
  }
  
  /**
   * &lt;method&gt;getTagName&lt;/method&gt; method: search the element and catch the name of it
   * @return the name of the tag as a string
   */
  public String getTagName() {
      logger.info("getTagName() [{}]", locator);
      return getElement().getTagName();
  }
  
  /**
   * &lt;method&gt;getAttribute&lt;/method&gt; method: search the element and catch the attribute of it
   * @return the text inside the attribute element
   */
  public String getAttribute(String name) {
      logger.info("getAttribute() [{}] from [{}]", name, locator);
      return getElement().getAttribute(name);
  }
  
  /**
   * &lt;method&gt;isSelected&lt;/method&gt; method: search the element and selects it
   * @return a boolean value to know if is selected or not an element
   */
  public boolean isSelected() {
      logger.info("isSelected() [{}]", locator);
      return getElement().isSelected();
  }
  
  /**
   * &lt;method&gt;isEnabled&lt;/method&gt; method: search the element and checks if is enabled it or not
   * @return a boolean value to know if is enabled or not an element
   */
  public boolean isEnabled() {
      logger.info("isEnabled() [{}]", locator);
      return getElement().isEnabled();
  }
  
  /**
   * &lt;method&gt;isEnabled&lt;/method&gt; method: search the element and recovers the inside it
   * @return a string value with the text inside the element
   */
  public String getText() {
      logger.info("getText() [{}]", locator);
      return getElement().getText();
  }
  
  /**
   * &lt;method&gt;findElements&lt;/method&gt; method: search elements in the web code and returns them
   * @param by. By
   * @return The list of elements that have found, to use it
   */
  public List&lt;WebElement&gt; findElements(By by) {
      logger.trace("findElements() [{}] on element [{}]", by, locator);       
      return getElement().findElements(by);
  }
  
  /**
   * &lt;method&gt;findElement&lt;/method&gt; method: search an element in the web code and returns it
   * @param by. By
   * @return The element found to use it
   */
  public WebElement findElement(By by) {
      logger.trace("findElement() [{}] on element [{}]", by, locator);        
      return getElement().findElement(by);
  }
  
  /**
   * &lt;method&gt;isDisplayed&lt;/method&gt; method: search an element in the web code and check if is displayed
   * currently on the "ghost" window browser
   * @return Boolean value to know if the element is displayed currently or not 
   */
  public boolean isDisplayed() {
      logger.trace("isDisplayed() [{}]", locator);
      return getElement().isDisplayed();
  }
  
  /**
   * &lt;method&gt;getLocation&lt;/method&gt; method: search an element in the web code and gets his location
   * @return the Point where the element is
   */
  public Point getLocation() {
      logger.info("getLocation() [{}]", locator);     
      return getElement().getLocation();
  }
  
  /**
   * &lt;method&gt;getSize&lt;/method&gt; method: search an element in the web code and gets his size
   * @return the element Size of the element
   */
  public Dimension getSize() {
      logger.info("getSize() [{}]", locator);     
      return getElement().getSize();
  }
  
  /**
   * &lt;method&gt;getCssValue&lt;/method&gt; method: search an element in the web code and gets his Css value
   * @return a string with the property name
   */
  public String getCssValue(String propertyName) {
      logger.info("getCssValue() [{}] on element [{}]", propertyName, locator);           
      return getElement().getCssValue(propertyName);
  }
  
  /**
   * &lt;method&gt;getLocator&lt;/method&gt; method: search an element in the web code and gets his localization
   * @return the element localization
   */
  public By getLocator() {
      return locator;
  }
  
  /**
   * &lt;method&gt;toString&lt;/method&gt; method: makes as a string properly formated the WebElementProxy 
   * @return String properly formated
   */
  @Override
  public String toString() {
      return ConstantsFramework.WEB_ELEMENT_PROXY_LOCATOR + locator + ConstantsFramework.ELEMENT + element + ConstantsFramework.CLOSE_BRACKET;
  }
  
  /**
   * &lt;method&gt;getWrappedElement&lt;/method&gt; method: to obtain the wrappered element 
   * @return the WebElement to wrapper
   */
  @Override
  public WebElement getWrappedElement() {
      return getElement();
  }
  
  /**
   * &lt;method&gt;infoWithScrenshot&lt;/method&gt; method: adds information to the screenshot taken
   * @param msg. String with a comment
   * @param Object... args. The screenshot
   */
  private void infoWithScrenshot(String msg, Object... args) {
      if(TestEnv.instance().isAutomaticScreenshot()) {
          String imgPath = ScreenshotUtil.takeScreenshot();
          //If the image path exists
          if(imgPath != null) {
              msg += " [&lt;a class=\"screenshot\" href=\"" + imgPath + "\" target=\"_blank\"&gt;before&lt;/a&gt;]";
          }
      }
      logger.info(msg, args);     
  }   
  
  }
  </code></pre>
  
  <p><strong>UPDATE</strong>
  This is what I am trying to resize, click on: style="cursor: col-resize;</p>
  
  <pre><code>&lt;thead&gt;
  &lt;th id="grid_ipvalue" class="ui-state-default ui-th-column ui-th-ltr" title="Indication of the product" role="columnheader" style="width: 568px;"&gt;
  &lt;th id="grid_ApplicantName" class="ui-state-default ui-th-column ui-th-ltr" title="Owner name" role="columnheader" style="width: 426px;" aria-selected="true"&gt;
  &lt;span class="ui-jqgrid-resize ui-jqgrid-resize-ltr" style="cursor: col-resize;"/&gt;
  &lt;div id="jqgh_grid_ApplicantName" class="ui-jqgrid-sortable"&gt;
  &lt;/th&gt;
  &lt;th id="grid_did" class="ui-state-default ui-th-column ui-th-ltr" title="Design number" role="columnheader" style="width: 311px;"&gt;
  </code></pre>
  
  <p>Here you can see the <a href="http://i.stack.imgur.com/z8yRE.png" rel="nofollow">table</a></p>