Hi, thanks for you replies.
I do know that submit() can be invoked on the form. Or if a form has a
default submit then "enter" would submit the underlying form.
Like on a web page, if I have multiple forms and each submits to
different URLs, then "enter" on individual elements (like input) would
submit the element's parent form.
However, I was wondering how WebDriver deals with such
WebElement.submit() calls.
Does it introspect on the element it is called and then calls the
parentForm.submit()?
Why I ask is that, on some browsers button.submit() works perfectly
for the example URL I posted.
e.g. With IE9, Win7, Se 2.0.1.0 the same script with button.submit()
works.
on FF3.6, FF5, Max OSX, Se 2.0 it doesn't.
regards
~angshu
On Jul 20, 2:29 am, Luke Inman-Semerau <
luke.seme...@gmail.com> wrote:
> It also submits the form on any form element (input, textarea, select) -
>
> driver.findElement(By.cssSelector("input#username")).submit();
>
>
>
>
>
>
>
> On Tue, Jul 19, 2011 at 1:37 PM, Jeff <
predato...@gmail.com> wrote:
> > submit() is for forms, click() is for buttons.
>
> > driver.findElement(By.tagName("form")).submit();
>
> > On Tue, Jul 19, 2011 at 6:22 AM, angshu <
angshuonl...@gmail.com> wrote:
>
> >> Hi, I want to know how Webdriver deals with a button's click/submit
> >> events. When should we call element's submit or click?
>
> >> e.g. consider the following test
> >> *****************************************
> >> org.openqa.selenium.WebDriver driver = new
> >> org.openqa.selenium.firefox.FirefoxDriver();
> >> driver.get("
http://net.tutsplus.com/demos/contactform/");
> >> driver.findElement(By.id("name")).sendKeys("test");
> >> driver.findElement(By.id("email")).sendKeys("
t...@gmail.com");
> >> driver.findElement(By.id("phone")).sendKeys("098765432");
> >> driver.findElement(By.id("submit_btn")).submit();
>
> >> junit.framework.Assert.assertTrue(browser.findElement(By.id("checkmark")).isDisplayed());
> >> *****************************************
> >> If I would change, the element.submit() to click() in the 6th line
> >> above, the test passes. Calling submit() doesnt seem to work.
> >> What does webdriver do in the background?
> >> Does it call element's form.submit() method? What would be the effect
> >> if I enter on an <input> to trigger the default form submit action?
>
> >> --
> >> 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.
>
> > --
> > Jeff Vincent
> >
predato...@gmail.com
> > I ♥ DropBox <
http://db.tt/9O6LfBX> !!