简体   繁体   English

如何在selenium web驱动程序和c#中使用sendkeys,以便生成唯一的名称和帐号

[英]How to use sendkeys in selenium web driver and c# so it generates unique name and account numbers

I am New to automation with no background in programming. 我是自动化新手,没有编程背景。 I am creating a test case to run in selenium where account number and account name needs to be unique each time. 我正在创建一个在selenium中运行的测试用例,其中每次帐号和帐户名称都必须是唯一的。 This is what i have. 这就是我所拥有的。

 string ClientName = "Automation" + new Random();
 driver.FindElement(By.XPath("XXXX")).SendKeys(ClientName);

Found my own answer. 找到了我自己的答案。 Installed Faker-cs-PCL from NuGet Package Manager. 从NuGet Package Manager安装Faker-cs-PCL。

 var ClientName = driver.FindElement(By.XPath("XXXXXXX"));
 var name = Faker.Name.FullName();
 ClientName.SendKeys(name);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM