Hi,

No there is currently no way to convert IElement to HtmlElement, but this
functionality would be important. I've opened up feature request 2677075 to
implement this in the next version.
https://sourceforge.net/tracker2/?func=detail&aid=2677075&group_id=61302&atid=497985

Cheers!
Jevon

On Sat, Mar 7, 2009 at 8:47 AM, <dcr...@ups.com> wrote:

> Is there any way to convert IElement  to HtmlElement (Htmlunit)?
>
> I am trying to implement a method that allows me to work in the same way as
> clickByXPath(), and getting hung up on the whole conversion to actually
> select value from the HtmlSelect object:
>
>   public void selectElementByXPath(String xpath, String selectValue) {
>        boolean selected = false;
>        if (xpath.contains("select")) {
>                for (IElement e : getElementsByXPath(xpath)) {
>                        try {
>                                HtmlSelect s = (HtmlSelect) e;
>                                if (s.hasAttribute(selectValue)) {
>                                        s.setSelectedAttribute(selectValue,
> true);
>                                        selected = true;
>                                }
>                        } catch (Exception exp) {
>                                //do nothing, try othe
>                        }
>                }
>                if (!selected)
>                {
>                        throw new RuntimeException("selectElementByXPath -
> Could not find select Object \"" + xpath
>                                        + "\" with option " + selectValue);
>                }
>
>        }
>        else
>                //throw exception since this is not a select object
>        {
>                throw new RuntimeException("Element with xpath \"" + xpath
>                                + "\" is not a select object");
>        }
>
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco,
> CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the
> Enterprise
> -Strategies to boost innovation and cut costs with open source
> participation
> -Receive a $600 discount off the registration fee with the source code:
> SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> JWebUnit-users mailing list
> JWebUnit-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jwebunit-users
>
>
------------------------------------------------------------------------------
_______________________________________________
JWebUnit-users mailing list
JWebUnit-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jwebunit-users

Reply via email to