To verify the fields filled in an application using Selenium, you can follow these steps:
- Launch the browser and navigate to the application's URL.
- Fill in the input fields with the desired data.
- Click the "Submit" or "Save" button to submit the form.
- Verify that the data is saved correctly by navigating to the edit form page.
- Retrieve the data from the input fields on the edit form page.
- Compare the retrieved data with the original data that was entered in step 2.
Here is a sample code (Selenium with Java) to get you started:
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class FormTest {
public static void main(String[] args) {
// Set up WebDriver and navigate to the application
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
WebDriver driver = new ChromeDriver();
driver.get("http://your-application-url.com");
// Fill out and save the form
WebElement nameField = driver.findElement(By.id("name"));
nameField.sendKeys("John Doe");
WebElement emailField = driver.findElement(By.id("email"));
emailField.sendKeys("[email protected]");
WebElement saveButton = driver.findElement(By.id("save-button"));
saveButton.click();
// Edit the form and verify the updated information
WebElement editButton = driver.findElement(By.id("edit-button"));
editButton.click();
WebElement newNameField = driver.findElement(By.id("name"));
newNameField.clear();
newNameField.sendKeys("Jane Doe");
WebElement newEmailField = driver.findElement(By.id("email"));
newEmailField.clear();
newEmailField.sendKeys("[email protected]");
saveButton.click();
String updatedName = driver.findElement(By.id("name")).getAttribute("value");
String updatedEmail = driver.findElement(By.id("email")).getAttribute("value");
if (updatedName.equals("Jane Doe") && updatedEmail.equals("[email protected]")) {
System.out.println("Form updated successfully.");
} else {
System.out.println("Form update failed.");
}
driver.quit();
}
}
You will need to replace the /path/to/chromedriver
with the actual path to the ChromeDriver file on your machine, and update the element selectors (e.g. By.id("name")
, By.id("email")
, etc.) to match those in your application.