I have to check what was the currant location which my test is going to execute. Actually i was thinking that is inside the bin folder but i was wrong.
string value = AppDomain.CurrentDomain.BaseDirectory;
From this you can get the actual location where your test project is building right now.
in my case it is on
E:\\Users\\<user>\\documents\\visual studio 2012\\Projects\\TestWithSelenium3\\TestResults\\cja_ES-NB-110 2017-01-18 22_43_22\\Out
Then based on the above location i have to give the relative path. My Gecko driver was inside the
TestWithSelenium3
folder so i have to move back 3 time as below.@"..\..\..\TestWithSelenium3"
Then it works,
FInal test method will looks like :
[TestMethod]
public void CodedUITestMethod1()
{
var path = Application.CommonAppDataPath;
string value = AppDomain.CurrentDomain.BaseDirectory;
FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(@"..\..\..\TestWithSelenium3", "geckodriver.exe");
IWebDriver driver = new FirefoxDriver(service);
driver.Navigate().GoToUrl("http://www.google.com");
Thread.Sleep(4444);
}
No comments:
Post a Comment