- Selenium WebDriver 3 Practical Guide
- Unmesh Gundecha Satya Avasarala
- 220字
- 2021-08-13 16:08:11
The submit() method
The submit() action can be taken on a Form or on an element, which is inside a Form element. This is used to submit a form of a web page to the server hosting the web application. The API syntax for the submit() method is as follows:
void submit()
The preceding method doesn't take any input parameters and doesn't return anything. But a NoSuchElementException is thrown when this method is executed on a WebElement that is not present within the form.
Now, let's see a code example to submit the form on a Search page:
@Test
public void elementSubmitExample() {
WebElement searchBox = driver.findElement(By.name("q"));
searchBox.sendKeys(Keys.chord(Keys.SHIFT,"phones"));
searchBox.submit();
}
In the preceding code, toward the end is where the Search form is submitted to the application servers using the submit() method. Now, try to execute the submit() method on an element, let's say the About link, which is not a part of any form. We should see NoSuchElementException is thrown. So, when you use the submit() method on a WebElement, make sure it is part of the Form element.
- Modern JavaScript Web Development Cookbook
- 面向物聯(lián)網(wǎng)的CC2530與傳感器應(yīng)用開(kāi)發(fā)
- 數(shù)字烏托邦
- Spring Boot 2.0 Projects
- HCNA網(wǎng)絡(luò)技術(shù)
- 局域網(wǎng)組建、管理與維護(hù)項(xiàng)目教程(Windows Server 2003)
- 雷達(dá)饋線技術(shù)
- 中國(guó)互聯(lián)網(wǎng)發(fā)展報(bào)告2018
- 網(wǎng)管工具使用與技巧大全
- Master Apache JMeter:From Load Testing to DevOps
- 物聯(lián)網(wǎng)工程導(dǎo)論(第3版)
- 設(shè)備監(jiān)控技術(shù)詳解
- 局域網(wǎng)組成實(shí)踐
- 沖擊:5G如何改變世界
- 物聯(lián)網(wǎng)技術(shù)與實(shí)踐