[英]C# .net Selenium, how to insert a date and time using sendKeys()
我正在做一个项目,需要获取系统日期并将其插入txtbox。
我尝试了以下操作,但似乎对我没有用,我对C#和Selenium还是陌生的,所以我做的事情可能很愚蠢。
query = driver.FindElement(By.Name("txtbox"));
DateTime y = DateTime.Today;
query.SendKeys("y");
您的代码如何工作? 它发送的是“ 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.