简体   繁体   English

Web测试:如何从数据源过滤匹配的数据?

[英]Web test: how to filter matching data from a data source?

Noob question on web testing: In step 1 of my web test, I load a Foo record, which has a value of Score equal to 200. 关于Web测试的Noob问题:在Web测试的第1步中,我加载了Foo记录,该记录的Score值等于200。

In a datasource MyDataSource.csv I have data like so: 在数据源MyDataSource.csv我有如下数据:

Group No Value    Description
1        100      Not so good
2        175      OK
3        250      Pretty good
4        300      Excellent

Based on the value of the Score field, I want to set a context variable {{groupNo}} for use in following steps, which is the group with the highest value that is less than or equal to score. 基于“ Score字段的值,我想设置一个上下文变量{{groupNo}}以用于后续步骤,该变量是具有小于或等于score的最大值的组。 So in our example, the groupNo would be 2. 因此,在我们的示例中, groupNo为2。

How do I do that? 我怎么做?

Solved my own question. 解决了我自己的问题。 I created an ExtractionRule , and read the source data into a static collection. 我创建了ExtractionRule ,并将源数据读取到静态集合中。 In the Extract() method, I looked up the appropriate value from that collection and wrote the appropriate value to a context parameter. Extract()方法中,我从该集合中查找了适当的值,并将适当的值写入了上下文参数。

That's my workaround, though I'm open to accepting a different answer if anyone has a better solution. 这是我的解决方法,但是如果有人有更好的解决方案,我愿意接受其他答案。

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

相关问题 来自Web API的Lightswitch数据作为数据源 - Lightswitch data from Web API as data source 如何通过不同于数据源的文本过滤ASPxGridView - How to filter ASPxGridView by text that is different from data source 从另一个过滤 Combobox 绑定源数据 - Filter Combobox binding source data from another 如何在单元测试项目中从不同文件夹访问数据源? - How can I access data source from different folders in my unit test project? 如何使用C#测试SSAS中与数据源的连接 - How to test connection to a data source in SSAS using C# 如何从源代码中抓取变量数据? - How to scrape a variable data from a source code? 如何使用Repository和Web API选择不同的数据源实例? - How to select a different data source instance using a Repository and Web API? 当新测试项目的测试被引入解决方案时,MSTest单元测试适配器无法连接到数据源 - MSTest Unit Test Adapter Failing to Connect to Data Source When Tests From New Test Project Are Introduced to Solution 如何使用LIKE和%%运算符查询和过滤Web表单中的数据? - How to query and filter my data in web form by using LIKE and %% operators? 如何从数据源添加要动态添加到Excel文件中的数据 - How to add data from a data source to be added in an Excel file dynamically
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM