It would be great if somebody helps me in solving below issue that I am facing during automation execution:
I am trying to bring in test case looping based on number of lines in the excel. I am using Data-driven capability in visual studio to achieve this. This works perfectly in Visual studio environment when i execute in "Test Explorer". But, when I build this project’s DLL and copy to the working folder of the automation tool (Where it picks for execution), below error is triggered:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
Please see the below code snippet:
[DataSource("System.Data.Odbc", "Dsn=Excel Files;Driver={Microsoft Excel Driver (*.xlsx)};dbq=J:\\Automation_Working_Directory\\Automation_Files_Demo\\Test_Report_01Base.xlsx;defaultdir=.;driverid=790;maxbuffersize=2048;pagetimeout=5;readonly=true", "SrsReportRunController_Dialog$", DataAccessMethod.Sequential)]
[TestMethod]
public void Test_Report_01()
{
#region Fetch data from Excel file
string fromDate = TestContext.DataRow["From date"].ToString();
string startDate = TestContext.DataRow["Report period start date"].ToString();
string toDate = TestContext.DataRow["To date"].ToString();
#endregion Fetch data from Excel file
Application.Control.TextBox().SetValue(fromDate);}
When i am trying to use the "fromDate" value to enter in the application, I am getting NullReferenceExecption.
Thanks in Advance.