When Start Test "<Platform>"
Then Do the test
Examples:
| Platform |
| Android |
| IOS |
Calls to my Test.java:
public class Test {
public <typeofvariable> driver;
@When("Start Test {string}")
public Start_test (String platform){
if (platform.equals("Android"))
{
driver = new InitAndroidDriver();
}
else { driver = new InitIOSDriver();}
}
@When("Do the test")
public Do_the_test{
driver.context("NATIVE_APP");
}
}
But I don’t know what type of variable needs to be “driver” to accept AndroidDriver and also IOSDriver, I tried putting AppiumDriver in but It not works for me, because in the “Do the test” section I need to switch between context and AppiumDriver dont seems to have that function.
But I don’t know what type of variable needs to be “driver” to accept AndroidDriver and also IOSDriver, I tried putting AppiumDriver in but It not works for me, because in the “Do the test” section I need to switch between context and AppiumDriver dont seems to have that function.
This is exactly what interfaces were invented for. Simply cast your common class to the desired interface type, for example ((SupportsContextSwitching) driver).getContext()