[selenium-users] [WebDriver] Submitting a form with HtmlUnitDriver() fails

342 views
Skip to first unread message

Thomas Sundberg

unread,
May 3, 2010, 4:26:17 AM5/3/10
to Selenium Users
Hi!

I'm trying to implement continuous integration with WebDriver. The
code below works:

WebDriver driver = new FirefoxDriver();
driver.get(url);

WebElement form = driver.findElement(By.id("revocationIds"));

form.submit();

Changing to

WebDriver driver = new HtmlUnitDriver();
driver.get(url);

WebElement form = driver.findElement(By.id("revocationIds"));

form.submit();

fails with the excpetion:

org.openqa.selenium.WebDriverException: Cannot locate element used to
submit form
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1',
java.version: '1.6.0_20'
Driver info: driver.version: htmlunit
at org.openqa.selenium.htmlunit.HtmlUnitWebElement.submitForm(HtmlUnitWebElement.java:178)
at org.openqa.selenium.htmlunit.HtmlUnitWebElement.submit(HtmlUnitWebElement.java:135)
at org.openqa.selenium.htmlunit.HtmlUnitWebElement.submit(HtmlUnitWebElement.java:152)

The rest of the stacktrace is ommited to prevent the innocent.

I'm using Maven to build, the latest Selenium 2 avilable is 2.0a2.

I have this dependency specified:

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.0a2</version>
</dependency>

I this a know issue? Is it something that is fixed in a later version?
I have seen that 2.0a4 seems to be available, but I can't reach it
using Maven.
Please contact me offlist if you need more details.

/Thomas

--
Thomas Sundberg
M. Sc. in Computer Science

Mobile: +46 70 767 33 15
Blog: http://thomassundberg.wordpress.com/

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

Mark Collin

unread,
May 3, 2010, 7:44:17 AM5/3/10
to seleniu...@googlegroups.com
org.openqa.selenium.WebDriverException: Cannot locate element used to submit
form

Means it cannot find the submit button for the form you are trying to
submit. You can specify the exact button and use the .click() command
instead so something like:

driver.findElement(By.id("<idOfSubmitButton>")).click();

Bear in mind that HTMLUnit is not using the same JavaScript rendering engine
as FireFox so the way it constructs the DOM may be different which is
probably what is causing you issues.

Regards

Mark
--
This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.

If you have received this email in error please notify postm...@ardescosolutions.com

Thomas Sundberg

unread,
May 3, 2010, 8:10:34 AM5/3/10
to seleniu...@googlegroups.com
On Mon, May 3, 2010 at 13:44, Mark Collin <ma...@ardescosolutions.com> wrote:
> > org.openqa.selenium.WebDriverException: Cannot locate element used to submit
> > form
>
> Means it cannot find the submit button for the form you are trying to
> submit.  You can specify the exact button and use the .click() command
> instead so something like:
>
> driver.findElement(By.id("<idOfSubmitButton>")).click();

Didn't work either. I had tried it earlier, but didn't include it in
my original post.

> Bear in mind that HTMLUnit is not using the same JavaScript rendering engine
> as FireFox so the way it constructs the DOM may be different which is
> probably what is causing you issues.

Could this be an issue even if my web page isn't using any Javascript?

/Thomas

Thomas Sundberg

unread,
May 7, 2010, 4:42:31 AM5/7/10
to seleniu...@googlegroups.com
Hi!

The error below was due to a faulty html.

The part that failed was:

<input id="searchButton"
type="submit"
disabled="false"
tabindex="3"
value="Sök"/>

A version that work is:

<input id="searchButton"
type="submit"
tabindex="3"
value="Sök"/>


The failing html worked ok visual driver, i.e. Firefox and Internet
Explorer. The HtmlUnitDriver was a bit more picky and failed when, a
faulty(?), property disabled was set as above.

Is it a bug or a feature that HtmlUnitDriver is stricter then the
visual drivers?
I'm not sure.

/Thomas

Ahmed Ashour

unread,
May 7, 2010, 7:08:43 AM5/7/10
to Selenium Users
Hi Thomas,

> Is it a bug or a feature that HtmlUnitDriveris stricter then the visual drivers?

HtmlUnit should follow real browsers along the way.

Please submit a minimal test case to HtmlUnit bug tracker.

Thanks,
Ahmed

On May 7, 11:42 am, Thomas Sundberg <thomas.k.sundb...@gmail.com>
wrote:
> Hi!
>
> The error below was due to a faulty html.
>
> The part that failed was:
>
>     <input id="searchButton"
>            type="submit"
>            disabled="false"
>            tabindex="3"
>            value="Sök"/>
>
> A version that work is:
>
>     <input id="searchButton"
>            type="submit"
>            tabindex="3"
>            value="Sök"/>
>
> The failing html worked ok visual driver, i.e. Firefox and Internet
> Explorer. TheHtmlUnitDriverwas a bit more picky and failed when, a
> faulty(?), property disabled was set as above.
>
> I'm not sure.
>
> /Thomas
>
> On Mon, May 3, 2010 at 14:10, Thomas Sundberg
>
>
>
> <thomas.k.sundb...@gmail.com> wrote:
> > On Mon, May 3, 2010 at 13:44, Mark Collin <m...@ardescosolutions.com> wrote:
> >> > org.openqa.selenium.WebDriverException: Cannot locate element used to submit
> >> >form
>
> >> Means it cannot find the submit button for theformyou are trying to
> >> submit.  You can specify the exact button and use the .click() command
> >> instead so something like:
>
> >> driver.findElement(By.id("<idOfSubmitButton>")).click();
>
> > Didn't work either. I had tried it earlier, but didn't include it in
> > my original post.
>
> >> Bear in mind that HTMLUnit is not using the same JavaScript rendering engine
> >> as FireFox so the way it constructs the DOM may be different which is
> >> probably what is causing you issues.
>
> > Could this be an issue even if my web page isn't using any Javascript?
>
> > /Thomas
>
> >> Regards
>
> >> Mark
>
> >> -----Original Message-----
> >> From: seleniu...@googlegroups.com
> >> [mailto:seleniu...@googlegroups.com] On Behalf Of Thomas Sundberg
> >> Sent: 03 May 2010 09:26
> >> To: Selenium Users
> >> Subject: [selenium-users] [WebDriver]Submittingaformwith
> >>HtmlUnitDriver()fails
>
> >> Hi!
>
> >> I'm trying to implement continuous integration with WebDriver. The
> >> code below works:
>
> >>        WebDriver driver = new FirefoxDriver();
> >>        driver.get(url);
>
> >>        WebElementform= driver.findElement(By.id("revocationIds"));
>
> >>        form.submit();
>
> >> Changing to
>
> >>        WebDriver driver = newHtmlUnitDriver();
> >>        driver.get(url);
>
> >>        WebElementform= driver.findElement(By.id("revocationIds"));
>
> >>        form.submit();
>
> >>failswith the excpetion:
> >> If you have received this email in error please notify postmas...@ardescosolutions.com
>
> >> --
> >> You received this message because you are subscribed to the Google Groups "Selenium Users" group.
> >> To post to this group, send email to seleniu...@googlegroups.com.
> >> To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
> >> For more options, visit this group athttp://groups.google.com/group/selenium-users?hl=en.
>
> > --
> > Thomas Sundberg
> > M. Sc. in Computer Science
>
> > Mobile: +46 70 767 33 15
> > Blog:http://thomassundberg.wordpress.com/
>
> --
> Thomas Sundberg
> M. Sc. in Computer Science
>
> Mobile: +46 70 767 33 15
> Blog:http://thomassundberg.wordpress.com/
>
> --
> You received this message because you are subscribed to the Google Groups "Selenium Users" group.
> To post to this group, send email to seleniu...@googlegroups.com.
> To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/selenium-users?hl=en.

Ahmed Ashour

unread,
May 7, 2010, 7:27:08 AM5/7/10
to seleniu...@googlegroups.com
Hi Again,

Actually, disabled='false' button is disabled, so you can't manually click on it in real browsers.

I believe click() should be not allowed in drivers other than HtmlUnit.

Yours,
Ahmed
----
Blog: http://asashour.blogspot.com

From: Ahmed Ashour <asas...@yahoo.com>
To: Selenium Users <seleniu...@googlegroups.com>
Sent: Fri, May 7, 2010 2:08:43 PM
Subject: [selenium-users] Re: [WebDriver] Submitting a form with HtmlUnitDriver() fails
> >> selenium-users+unsub...@googlegroups.com.

> >> For more options, visit this group at
> >>http://groups.google.com/group/selenium-users?hl=en.
>
> >> --
> >> This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.
>
> >> If you have received this email in error please notify postmas...@ardescosolutions.com
>
> >> --
> >> You received this message because you are subscribed to the Google Groups "Selenium Users" group.
> >> To post to this group, send email to seleniu...@googlegroups.com.
> >> To unsubscribe from this group, send email to selenium-users+unsub...@googlegroups.com.

> >> For more options, visit this group athttp://groups.google.com/group/selenium-users?hl=en.
>
> > --
> > Thomas Sundberg
> > M. Sc. in Computer Science
>
> > Mobile: +46 70 767 33 15
> > Blog:http://thomassundberg.wordpress.com/
>
> --
> Thomas Sundberg
> M. Sc. in Computer Science
>
> Mobile: +46 70 767 33 15
> Blog:http://thomassundberg.wordpress.com/
>
> --
> You received this message because you are subscribed to the Google Groups "Selenium Users" group.
> To post to this group, send email to seleniu...@googlegroups.com.
> To unsubscribe from this group, send email to selenium-users+unsub...@googlegroups.com.

> For more options, visit this group athttp://groups.google.com/group/selenium-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-users+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.

Daniel Wagner-Hall

unread,
May 9, 2010, 11:36:09 AM5/9/10
to Selenium Users
For reference, I've created a bug for this related behaviour:
https://code.google.com/p/selenium/issues/detail?id=514 - fixes to
come

On May 7, 12:27 pm, Ahmed Ashour <asash...@yahoo.com> wrote:
> Hi Again,
>
> Actually, disabled='false' button is disabled, so you can't manually click on it in real browsers.
>
> I believe click() should be not allowed in drivers other than HtmlUnit.
>
> Yours,
> Ahmed
> ----
> Blog:http://asashour.blogspot.com
>
> ________________________________
> From: Ahmed Ashour <asash...@yahoo.com>
> > >> selenium-user...@googlegroups.com.
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/selenium-users?hl=en.
>
> > >> --
> > >> This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.
>
> > >> If you have received this email in error please notify postmas...@ardescosolutions.com
>
> > >> --
> > >> You received this message because you are subscribed to the Google Groups "Selenium Users" group.
> > >> To post to this group, send email to seleniu...@googlegroups.com.
> > >> To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
> > >> For more options, visit this group athttp://groups.google.com/group/selenium-users?hl=en.
>
> > > --
> > > Thomas Sundberg
> > > M. Sc. in Computer Science
>
> > > Mobile: +46 70 767 33 15
> > > Blog:http://thomassundberg.wordpress.com/
>
> > --
> > Thomas Sundberg
> > M. Sc. in Computer Science
>
> > Mobile: +46 70 767 33 15
> > Blog:http://thomassundberg.wordpress.com/
>
> > --
> > You received this message because you are subscribed to the Google Groups "Selenium Users" group.
> > To post to this group, send email to seleniu...@googlegroups.com.
> > To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/selenium-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "Selenium Users" group.
> To post to this group, send email to seleniu...@googlegroups.com.
> To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/selenium-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "Selenium Users" group.
> To post to this group, send email to seleniu...@googlegroups.com.
> To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/selenium-users?hl=en.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.

Thomas Sundberg

unread,
May 9, 2010, 11:50:43 AM5/9/10
to seleniu...@googlegroups.com
Hi!


On Sun, May 9, 2010 at 17:36, Daniel Wagner-Hall <dawa...@gmail.com> wrote:
> For reference, I've created a bug for this related behaviour:
> https://code.google.com/p/selenium/issues/detail?id=514 - fixes to
> come


I just added a comment to the bug you created and added a maven
project showing the incorrect behaviour.

And I claim that the example I attached should be submitted even tho
the disabled property is is set initially.

/Thomas
Reply all
Reply to author
Forward
0 new messages