Dictionary string error - SystemCollectionsGenericDictionary2SystemStringSystemString | Selenium C# Forum
S
Shreekanth Posted on 17/01/2019

Getting Warning message in Dictionary Line..

public class LoginTest :BaseTest
{
static string testCaseName = "ReportsTest";
static ExcelReaderFile xls = new ExcelReaderFile(ConfigurationManager.AppSettings["xlsPath"]);

[Test, TestCaseSource("getData")]
public void runReport(Dictionary<string, string> data)       ---> In this line!

 

Test Name: runReport(System.Collections.Generic.Dictionary`2[System.String,System.String])

Any help would be appreciated!!

 

Screenshot attached


G
gunjan Replied on 17/01/2019

You are getting the warning as you might have set the 'Runmode' column's value to 'N' in the excel because of which it skips the testcase with a warning.

Kindly check the Runmode column value in the excel.


S
Shreekanth Replied on 17/01/2019

I tried it with RUN MODE "Y". I don't have any "N".

Though, the test is passed - this message warns me.

I also attached my Data Excel File..

Please check..

 

 


S
Shreekanth Replied on 17/01/2019

Data Excel attached as well

I have only 3  Columns and 4 rows of Data

Do I need to change the code?


G
gunjan Replied on 18/01/2019

Excel is correct. Can you show me the code that you are trying to execute.


S
Shreekanth Replied on 18/01/2019

attached my logintest.cs


G
gunjan Replied on 18/01/2019

Please check this condition:

if (!DataUtil.DataUtil.isTestRunnable(testCaseName, xls) || data["Runmode"].Equals("N"))
{
test.Log(Status.Skip, "Skipping the test as runmode is No");
Assert.Ignore("Skipping the test as runmode is No");
}

 

Try this :

if (!(DataUtil.DataUtil.isTestRunnable(testCaseName, xls) || data["Runmode"].Equals("N")))
{
test.Log(Status.Skip, "Skipping the test as runmode is No");
Assert.Ignore("Skipping the test as runmode is No");
}


S
Shreekanth Replied on 18/01/2019

I tried new code and still same error.

The problem is in this line:

public void runReport(Dictionary<string, string> data)

Above line is looking to pass parameters in DATAUTIL.cs in below code:

object[][] data = new object[rows][];
int dataRow = 0;
Dictionary<string, string> table = null;

for (int rNum = dataStartRowNum; rNum < dataStartRowNum + rows; rNum++)
{
data[rNum - dataStartRowNum] = new object[1];
table = new Dictionary<string, string>();
for (int cNum = 0; cNum < cols; cNum++)
{
string key = xls.getCellData(sheetName, cNum, colStartRowNum);
string value = xls.getCellData(sheetName, cNum, rNum);
table.Add(key, value);
}
data[dataRow][0] = table;
dataRow++;

 


G
gunjan Replied on 18/01/2019

This code is correct. Can you send me the entire code so that I can try executing it.


S
Shreekanth Replied on 18/01/2019

I cannot upload here! its failing to upload my ZIP File.

Please share your email id. I will drop you an email.


G
gunjan Replied on 18/01/2019

seleniumtraining10@gmail.com


G
gunjan Replied on 18/01/2019

Did you try this :

if (!(DataUtil.DataUtil.isTestRunnable(testCaseName, xls) || data["Runmode"].Equals("N")))
{
test.Log(Status.Skip, "Skipping the test as runmode is No");
Assert.Ignore("Skipping the test as runmode is No");
}


S
Shreekanth Replied on 18/01/2019

Yes Gunjan..I tried it and it is showing same warning message.


S
Shreekanth Replied on 18/01/2019

I sent you my code to above email id.

 

 

 

 

 

 

 

 

 


G
gunjan Replied on 18/01/2019

The code is running fine at my end. I can't see any warning message.

Please check once again.


S
Shreekanth Replied on 19/01/2019

Code is working fine my end also..

If you expand Testingframework project(in Test Explorer) --> runReport (you will see this message)

I have attached screenshot.

Do you see this message?

 


G
gunjan Replied on 19/01/2019

Yes .. this is the name of the test method which will be listed every time for each test.


S
Shreekanth Replied on 21/01/2019

ok got it. please close the ticket