Selenium 与 BrowserMob.com
我正在使用 Selenium 来在 Web 服务器上创建负载平衡测试。该网站有一个用户名/密码,为了使用它,我有一个包含用户名密码组合的 csv 文件。
问题是我使用 Javascript 中的随机函数从 csv 文件中选择一行并填充登录功能或注册详细信息。
var csv = browserMob.getCSV("pickStickEmails.csv");
var row = csv.random();
var Email = row.get("email");
var Password = row.get("password");
selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxEmail", Email);
selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxEmailConfirm", Email);
selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxPassword", Password);
selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxPasswordConfirm", Password);
如果在计划运行期间选择同一记录两次,这显然会在注册时带来问题。显然,在登录情况下,如果在注册时未选择记录,然后在需要现有帐户的测试中选择记录,则测试会因该记录不存在而失败。
我的问题是,是否有可能以某种方式让 browserMob 一次迭代一个记录?显然,当 browserMob 开始负载测试时,它会增加到一次有 10 个用户使用该网站,每个用户都运行我假设的脚本?
我确实使用 C# 中的 Selenium-RC 和 NUnit 编写了测试,并将 csv 文件读入列表中,然后迭代列表。显然,这会依次运行每个用户,并且不会模拟多个用户同时访问该网站。
对此的任何建议将不胜感激。
谢谢,
乔恩
I am working with Selenium in order to create load balancing tests on a web server. The website has a username/password and in order to work with this I have a csv file filled with username password combinations.
The issue is I am using the random function in Javascript to select a row from the csv file and populate the login functionality or registration details.
var csv = browserMob.getCSV("pickStickEmails.csv");
var row = csv.random();
var Email = row.get("email");
var Password = row.get("password");
selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxEmail", Email);
selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxEmailConfirm", Email);
selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxPassword", Password);
selenium.type("ctl00_StandardMainBodyPlaceHolder_ctl00_TextBoxPasswordConfirm", Password);
This obviously brings up issues when registering if the same record is selected twice during a scheduled run. Obviously with the login situation if a record isn't selected when registering and is then selected on a test that requires an existing account the test fails due to it not existing.
My question is, is it possible to somehow get browserMob to iterate through the records one at a time? Obviously when browserMob begins a load test it ramps up to lets say 10 users using the website at one time each running the script I assume?
I did write the test using Selenium-RC in C# with NUnit and read the csv file into a List and then iterated through the list. Obviously this runs each user after another and doesn't simulate multiple users being on the site at one time.
Any advice on this would be greatly appreciated.
Thanks,
Jon
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要强制执行唯一参数化,您需要调用 browserMob.getUserNum() ,因为这将获取正在处理您的测试的节点的用户编号。您可以在他们的帮助中看到这一点。我已将您的代码更新为我认为应该的样子。应该意味着我还没有测试过:)
To enforce unique parameterization you need to call
browserMob.getUserNum()
as that will get the user number for that node that is processing your test. You can see this in their help. I have updated your code to how I think it should look. Should means I have not tested it :)我认为这可能是在负载测试期间为每个用户获取唯一记录的一种方法:
它基本上创建一个数字数组,充当 csv 文件的行号。然后它只使用 CsvTable 上的 get() 函数,而不是随机使用从您的建议中选择的唯一编号。
感谢您的指导!
I think this could possibly be a way to get a unique record for each user during a load test:
It basically creates an array of numbers which act as row numbers for the csv file. Then it just uses the get() function on the CsvTable instead of random using the unique number selected from your suggestion.
Thank's for the guidance!