Question send web form values as URL Parameters?

Anonymous

Well-known member
Joined
Sep 29, 2020
Messages
88
Programming Experience
Beginner
I am trying to fill a website form using C#Desktop application.
I am using the following form as an example -

C#:
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");

            var frame = driver.FindElement(By.CssSelector("iframe.fs_embed"));
            driver.SwitchTo().Frame(frame);
            driver.FindElement(By.CssSelector("input[placeholder='Your first name']")).SendKeys("John");
            driver.FindElement(By.CssSelector("input[placeholder='Your last name']")).SendKeys("Doe");
//more code

        }

Is there anyway I can send these values using URL Parameters? I am confused how I can find the parameter name of each field. I have to generate multiple URLs and store them in a file so that the end user can click on them later.
Please guide. Thank you.
 
Last edited:
Is your intent to fill out the UI form, or to be able to submit the form with information as if the user filled out the form and hit the submit button?

Depending on the web UI code/framework, you might be able to pre-fill some of the form fields so that when the page is displayed, then the values will already be present. There is no one size fits all solutionx though. You have to know how that particular form works.

If your objective is to just submit the form with data, then see my response in your other thread about asking the site owner for an API. If they don't have an API, but the form just uses a regular HTTP POST when the form is submitted, you just have to mimic what the browser does: it will either send the values as parameters on the URL, or it will send the values as form data in the body. In either case, the names of the parameters will be defined in the HTML input elements of the form.
 

Latest posts

Back
Top Bottom