Why run three row if the csv store tow data row?
Its your CVS file, its got extra line or CR at the end, use notepad to delete all empty space and line after the last character of 2nd line. Also remember to delete and reload the file in Data Driven
Is there a way to query a csv file in Karate?
There's no need. Karate can transform a CSV file into a JSON array in one line:
* def data = read('data.csv')
After that just use JsonPath or a "filter" operation to "query" for data (search the docs for more examples):
* def found = data.find(x => x['TC-ID'] === 'TC-1')
* def results = data.filter(x => x.FNAME.startsWith('A'))
Karate Skip test cases read from CSV in a Scenario Outline
Let's say you have three rows and you just want to run one. You can read the csv and then filter it using JsonPath filters. The following code will run only testcase "tc02".
Sample Code:
Feature: CSV Filter
Background:
* def data = read('testdata.csv')
* def data = get data[?(@.testcase=='tc02')]
Scenario Outline: <testcase>,<desc>
* def look = "<testcase>,<desc>"
* print look
Examples:
| data |
# testdata.csv
# testcase,desc
# tc01,desc01
# tc02,desc02
# tc03,desc03
Input from CSV file to a text field in Web C# without using UIMap/Recorded code
Add in a data source to your test method.
add in the csv file to your solution. Right click folder /solution, add existing item, select the file, change the properties of the file 'Copy to Output Directory' to 'copy always'
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\\data.csv", "data#csv", DataAccessMethod.Sequential), DeploymentItem("data.csv"), TestMethod]
[TestMethod]
public void openBrw()
{
BrowserWindow browser = BrowserWindow.Launch("www.google.com");
UITestControl UISearch = new UITestControl(browser);
UISearch.TechnologyName = "Web";
UISearch.SearchProperties.Add("ControlType", "Edit");
UISearch.SearchProperties.Add("Id", "lst-ib");
//search by column1
Keyboard.SendKeys(UISearch, TestContext.DataRow["column1"].ToString());
}
Related Topics
How Enumerate All Classes with Custom Class Attribute
Dynamically Access Table in Ef Core 2.0
C#: How to Make It Harder for Hacker/Cracker to Get Around or Bypass the Licensing Check
Restsharp JSON Parameter Posting
C#:What If a Static Method Is Called from Multiple Threads
C#: Waiting for All Threads to Complete
Why Cannot C# Generics Derive from One of the Generic Type Parameters Like They Can in C++ Templates
Calling Async Methods from a Wcf Service
Why Is Cross Thread Operation Exception Not Thrown While Running Exe in Bin\Debug
Does .Net Provide an Easy Way Convert Bytes to Kb, Mb, Gb, etc.
Generate and Sign Certificate Request Using Pure .Net Framework
Service Hangs Up at Waitforexit After Calling Batch File
How to Check If a String Exists in Another String
How to Write Some Data to Excel File(.Xlsx)