Reputation: 172
My code is(I replace actual URL with ../../../).
[TestInitialize]
public static void Initalize()
{
AppiumOptions desiredcap = new AppiumOptions();
desiredcap.AddAdditionalCapability("app", @".../../../..../");
driver = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), desiredcap);
if (driver == null)
{
Console.WriteLine("App not running");
return;
}
}
I want to make URL dynamic of
desiredcap.AddAdditionalCapability("app", @".../../../..../");
because i want to use this method in different project. Is it possible to write variable url instead of ../../../ and take url value from some other file or from Testcase.
Upvotes: 0
Views: 220
Reputation: 1424
So, you can create base class with Initalize(string capUrl)
method and call it in derived classes as here:
[TestInitialize]
public static void Initalize()
{
base.Initalize("http://SomeUri.com")
}
If you need to specify it in Testcase. Then you need to remove [TestInitialize]
and it's better to rename it to something like "PrepareTest". And call it by hands in test method. Like this:
[Testcase("http://SomeUri.com")]
public void TestMethod(string uri)
{
this.PrepareTest(uri);
}
Is this solution helps you? Or you need something other?
Upvotes: 2