Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them, it only takes a minute:

I'm doing a project where I need to grab the system date and insert it a txtbox.

I tried following but doesn't seem to work for me, I'm new to C# as well as Selenium, so I might be doing something silly.

query = driver.FindElement(By.Name("txtbox"));
DateTime y = DateTime.Today;
query.SendKeys("y");
share|improve this question

1 Answer 1

up vote 1 down vote accepted

How did your code not work? Did it send "y" instead of the date?

var query = driver.FindElement(By.Name("txtbox"));
DateTime y = DateTime.Today;
query.SendKeys(y.ToString()); // you shouldn't send string "y", but the y.ToString()
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.