[英]C# .net Selenium, how to insert a date and time using sendKeys()
I'm doing a project where I need to grab the system date and insert it a txtbox. 我正在做一个项目,需要获取系统日期并将其插入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. 我尝试了以下操作,但似乎对我没有用,我对C#和Selenium还是陌生的,所以我做的事情可能很愚蠢。
query = driver.FindElement(By.Name("txtbox"));
DateTime y = DateTime.Today;
query.SendKeys("y");
How did your code not work? 您的代码如何工作? Did it send "y" instead of the date?
它发送的是“ y”而不是日期吗?
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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.