I using the following form to fill values from a C# Desktop application . I able to fill first Name, Last Name, and email address but I am getting an element not found exception for the drop down and the text area.
My Code :
Find Element by Id is not working for any element but I was not sure what else to use for the dropdown as placeholder is not present for it. But The placeholder attribute is present for text area still I am getting the exception.
Web Form Example
These sample HTML forms show how easy it can be to build forms with FormSmarts form creator.
formsmarts.com
My Code :
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");
driver.FindElement(By.CssSelector("input[placeholder='Your email address']")).SendKeys("johndoe@example.com");
SelectElement selectElement = new SelectElement(driver.FindElement(By.Id("u_k0J_338367")));
selectElement.SelectByValue("Website Feedback");
driver.FindElement(By.CssSelector("input[placeholder='Your comment']")).SendKeys("Everything Rocks!!!");
Find Element by Id is not working for any element but I was not sure what else to use for the dropdown as placeholder is not present for it. But The placeholder attribute is present for text area still I am getting the exception.