A Project with an output type of class library cannot be started directly

Hi

A Project with an output type of class library  cannot be started directly

I am writing a script in c# for Hybrid framework. I have written the script for reading the excel sheet in which the keyword and test data is present. the build solution got succeeded but on running the code I am getting error message “A project with an output type of class library cannot be started directly. I am attaching the screenshots of my code and the excel sheet.

Code for Keyword Functions

using OpenQA.Selenium;

using OpenQA.Selenium.IE;

using OpenQA.Selenium.Support.UI;

namespace Framework.PageObjects

{

public class KeywordFunctions

{

private IWebDriver driver;

public KeywordFunctions(IWebDriver driver)

{

this.driver = driver;

}

public void OpenBrowser()

{

driver = new InternetExplorerDriver();

}

public void EnterURL(string url)

{

driver.Url = url;

}

public void EnterUserName(string userName)

{

driver.FindElement(By.Id(“uname”)).SendKeys(userName);

}

public void EnterPassword(string Password)

{

driver.FindElement(By.Id(“pwd”)).SendKeys(Password);

}

public void ClickLogIn()

{

driver.FindElement(By.Name(“s1”)).Click();

}

public void QuitDriver()

{

driver.Quit();

}

}

}

Code for Reading Excel

using System;

using excel = Microsoft.Office.Interop.Excel;

namespace Framework.PageObjects

{

class ExcelUtils

{

excel.Application x1Appl;

excel.Workbook x1WorkBook;

excel._Worksheet x1WorkSheet;

excel.Range x1Range;

public excel.Range ReadExcel(String filePath)

{

//Creates excel application

x1Appl = new excel.Application();

//Creates excel workbook object for specified file

x1WorkBook = x1Appl.Workbooks.Open(filePath);

//Creates excel work sheet object for sheet 1

x1WorkSheet = x1WorkBook.Sheets[1];

//Gets used range of excel file(here range is 3)

x1Range = x1WorkSheet.UsedRange;

return x1Range;

}

public void CloseExcelFiles()

{

x1WorkBook.Close();

x1Appl.Quit();

}

}

}

Code For Framework

using NUnit.Framework;

using OpenQA.Selenium;

using OpenQA.Selenium.IE;

using Framework.PageObjects;

using System;

using excel = Microsoft.Office.Interop.Excel;

 

namespace Framework.TestCases

{

class HybridTestFramework

{

public IWebDriver driver;

[Test]

public void LoginTest_Hybrid()

{

ExcelUtils excelFile = new ExcelUtils();

excel.Range testCaseRange = excelFile.ReadExcel(@”C:\Users\hargovind.senapati\Documents\Visual Studio 2015\Projects\Driver Verification\Framework Excel.xlsx”);

int xlRowCnt = 0;

String TestCaseId = null;

String Username;

String Password;

String URL;

driver = new InternetExplorerDriver();

KeywordFunctions keyword = new KeywordFunctions(driver);

for (xlRowCnt = 2; xlRowCnt <= testCaseRange.Rows.Count; xlRowCnt++)

{

TestCaseId = (string)(testCaseRange.Cells[xlRowCnt, 3] as excel.Range).Value2;

URL = (string)(testCaseRange.Cells[xlRowCnt, 4] as excel.Range).Value2;

Username = (string)(testCaseRange.Cells[xlRowCnt, 4] as excel.Range).Value2;

Password = (string)(testCaseRange.Cells[xlRowCnt, 4] as excel.Range).Value2;

 

 

if (TestCaseId.Equals(“OpenBrowser”))

{

//This will execute if the excel cell value is ‘OpenBrowser’

//Action Keyword is called here to perform action

//keyword.OpenBrowser();

}

else if (TestCaseId.Equals(“EnterURL”))

{

keyword.EnterURL(URL);

}

else if (TestCaseId.Equals(“EnterUserName”))

{

keyword.EnterUserName(Username);

}

else if (TestCaseId.Equals(“EnterPassword”))

{

keyword.EnterPassword(Password);

}

else if (TestCaseId.Equals(“ClickLogIn”))

{

keyword.ClickLogIn();

}

else if (TestCaseId.Equals(“QuitDriver”))

{

keyword.QuitDriver();

}

}

excelFile.CloseExcelFiles();

}

}

}

 

Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.