Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different serenity.properties for iOS and Android Appium driver #1070

Closed
risinek opened this issue Jan 3, 2018 · 4 comments
Closed

Different serenity.properties for iOS and Android Appium driver #1070

risinek opened this issue Jan 3, 2018 · 4 comments

Comments

@risinek
Copy link

risinek commented Jan 3, 2018

Hi, is there a way to specify different properties for iOS and Android Appium driver? What I am trying to achieve is, that I want to have iOS and Android tests in one run. So I use @Managed(driver = appium) for both iOS and Android drivers, but I can't figure out, how to set serenity.properties for both Android and iOS and then somehow assign them to managed driver in specific class.
Is it even possible to do so? Like adding some tag to @Managed to choose if I want to use Android properties for this instance of driver or iOS?
Basically right now I have class for Android test steps and another class for iOS test steps. In both of them I initialize @Managed(driver = appium) WebDriver driver but the problem is, it doesn't know, which one to use.

@wakaleo
Copy link
Member

wakaleo commented Jan 3, 2018

This is not currently supported.

@risinek
Copy link
Author

risinek commented Jan 3, 2018

Ok, thanks for answer ;)

@vikramvi
Copy link
Member

vikramvi commented Feb 7, 2018

@risinek currently I handle as below https://github.com/vikramvi/AppiumSerenityPOC/blob/master/serenity.properties

But in this setup you can run on either of Android or iOS

@rahulkulkarniyahoo
Copy link

Hi All,
I have a similar predicament.

I am trying to implement SerenityWithCucumber to execute on Browser Stack.Using a custom driver which reads the serenity.properties file and executes on the BrowserStack cloud server. However, thats the test execution. I want to be able to develop and test on my local machine. How do I manage that?
Please see the code below:
public class BrowserStackSerenityDriver implements DriverSource {

public WebDriver newDriver() {

    System.out.println("*****************************************************************************************************");
    System.out.println("*************************************** CAME TO newDriver  ******************************************");
    System.out.println("*****************************************************************************************************");
    EnvironmentVariables environmentVariables = SystemEnvironmentVariables.createEnvironmentVariables();

    String username = System.getenv("BROWSERSTACK_USERNAME");
    if (username == null) {
        username = (String) environmentVariables.getProperty("browserstack.user");
    }

    String accessKey = System.getenv("BROWSERSTACK_ACCESS_KEY");
    if (accessKey == null) {
        accessKey = (String) environmentVariables.getProperty("browserstack.key");
    }

    String environment = System.getProperty("environment");
    DesiredCapabilities capabilities = new DesiredCapabilities();

    Iterator it = environmentVariables.getKeys().iterator();
    while (it.hasNext()) {
        String key = (String) it.next();

        if (key.equals("browserstack.user") || key.equals("browserstack.key") || key.equals("browserstack.server")) {
            continue;
        } else if (key.startsWith("browserstack.")) {
            capabilities.setCapability(key.replace("browserstack.", ""), environmentVariables.getProperty(key));
            if (key.equals("browserstack.local")) {
                System.setProperty("browserstack.local", "true");
            }
        } else if (environment != null && key.startsWith("environment." + environment)) {
            capabilities.setCapability(key.replace("environment." + environment + ".", ""), environmentVariables.getProperty(key));
            if (key.equals("environment." + environment + ".browserstack.local")) {
                System.setProperty("browserstack.local", "true");
            }
        }
    }

        try {
            System.out.println("*****************************************************************************************************");
            System.out.println("****************************** LOADING BROWSER AT BS  LOCATION  *************************************");
            System.out.println("*****************************************************************************************************");
            return new RemoteWebDriver(new URL("http://" + username + ":" + accessKey + "@" + environmentVariables.getProperty("browserstack.server") + "/wd/hub"), capabilities);
        } catch (Exception e) {
            System.out.println(e);
            return null;
        }

}

public boolean takesScreenshots() {
    return true;
}

}

@wakaleo wakaleo closed this as completed Feb 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants