I am trying to fill a website form using C# Desktop Application, I am using the flowing form as an example –
https://formsmarts.com/html-form-example
I have written the following code –
private void button1_Click(object sender, EventArgs e)
{
// Initialize Chrome WebDriver
IWebDriver driver = new ChromeDriver();
// Navigate to the form URL
driver.Navigate().GoToUrl("https://formsmarts.com/html-form-example");
// Find input fields by their IDs and fill them with desired values
driver.FindElement(By.Id("u_HbM_4607")).SendKeys("John");
driver.FindElement(By.Id("u_HbM_338354")).SendKeys("Doe");
driver.FindElement(By.Id("u_HbM_4608")).SendKeys("[email protected]");
driver.FindElement(By.Id("u_HbM_338367")).SendKeys("Website Feedback");
driver.FindElement(By.Id("u_HbM_4609")).SendKeys("Everything Rocks!!!");
// Submit the form
//driver.FindElement(By.Id("u_CU_221828")).Click();
// Close the browser
//driver.Quit();
}
I am getting the following exception –
An unhandled exception of type 'OpenQA.Selenium.NoSuchElementException' occurred in WebDriver.dll
no such element: Unable to locate element: {"method":"css selector","selector":"#u_CU_221823"}
at
driver.FindElement(By.Id("u_HbM_4607")).SendKeys("John");
From here, Redirect to page, pre-filling form fields
I got to know that we can also send URL parameters to fill the fields, from the following answer
Are you just testing with an aspx page, or is the online approval form an aspx page?
You can try adding URL parameters to a GET request instead of POST.
http://www.amazon.co.uk/exec/obidos/search-handle-form?field-keywords=Harry+Potter
but how do I create this URL?
I researched and found the format from here – https://helpx.adobe.com/in/sign/adv-user/web-form/url-parameters.html
But how do I find the parameter names of this URL- https://formsmarts.com/html-form-example