MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / Submit

Method Submit

dotnet/src/webdriver/WebElement.cs:611–632  ·  view source on GitHub ↗

Submits this element to the web server. If this current element is a form, or an element within a form, then this will be submitted to the web server. If this causes the current page to change, then this method will attempt to block until the new page is loaded. Thrown when the target element is no longer vali

()

Source from the content-addressed store, hash-verified

609 /// is loaded.</remarks>
610 /// <exception cref="StaleElementReferenceException">Thrown when the target element is no longer valid in the document DOM.</exception>
611 public virtual void Submit()
612 {
613 string? elementType = this.GetAttribute("type");
614 if (elementType != null && elementType == "submit")
615 {
616 this.Click();
617 }
618 else
619 {
620 string script = "/* submitForm */var form = arguments[0];\n" +
621 "while (form.nodeName != \"FORM\" && form.parentNode) {\n" +
622 " form = form.parentNode;\n" +
623 "}\n" +
624 "if (!form) { throw Error('Unable to find containing form element'); }\n" +
625 "if (!form.ownerDocument) { throw Error('Unable to find owning document'); }\n" +
626 "var e = form.ownerDocument.createEvent('Event');\n" +
627 "e.initEvent('submit', true, true);\n" +
628 "if (form.dispatchEvent(e)) { HTMLFormElement.prototype.submit.call(form) }\n";
629
630 this.driver.ExecuteScript(script, this);
631 }
632 }
633
634 /// <summary>
635 /// Returns a string that represents the current <see cref="WebElement"/>.

Callers

nothing calls this directly

Calls 3

GetAttributeMethod · 0.95
ClickMethod · 0.95
ExecuteScriptMethod · 0.45

Tested by

no test coverage detected