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

Number values not parser from Appium capability properties in serenity.properties #2911

Closed
nmilosevic opened this issue Sep 2, 2022 · 1 comment

Comments

@nmilosevic
Copy link

Hi,

I am using the following dependency versions in my project:

ext {
    serenityVersion = '3.0.5'
    appiumJavaClientVersion = '7.6.0'
}

I use Appium server v1.22.3.

If I try using the appium.waitForIdleTimeout=0 Appium capability in my serenity.properties file I get a DriverConfigurationError caused by:

Caused by: net.thucydides.core.webdriver.DriverConfigurationError: Could not instantiate new WebDriver instance of type class io.appium.java_client.AppiumDriver (Unable to create a new remote session. Please check the server log for more details. Original error: A new session could not be created. Details: io.appium.uiautomator2.common.exceptions.InvalidArgumentException: Invalid 'waitForIdleTimeout' setting value type. Got: java.lang.String. Expected: java.lang.Long.

I've looked into the code that gathers Appium capabilities from the properties file and it looks that all the properties are gathered with value as a String type and passed like that to Appium.

I've also tested with the latest versions of Serenity and Appium Java client but the issue is there too.

Is there any other way we can generate capabilities and pass that to the Appium driver?

@nmilosevic
Copy link
Author

I found a solution to this by following instruction in https://github.com/serenity-bdd/the-serenity-book/blob/master/modules/ROOT/pages/extending-webdriver.adoc.

I've created a class that implements BeforeAWebdriverScenario and placed it into net.serenitybdd package in my project (note that this package is hardcoded in Serenity version I am using and must be respected).

public class AppiumCapabilityEnhancer implements BeforeAWebdriverScenario {

    @Override
    public DesiredCapabilities apply(EnvironmentVariables environmentVariables, SupportedWebDriver driver,
                                     TestOutcome testOutcome, DesiredCapabilities capabilities) {
        if (driver == SupportedWebDriver.ANDROID) {
            capabilities.setCapability("waitForIdleTimeout", 0);
            capabilities.setCapability("chromeOptions", ImmutableMap.of("w3c", false));
        }

        return capabilities;
    }
}

I've then added an entry into my serenity.properties.

serenity.extension.packages=net.serenitybdd.AppiumCapabilityEnhancer

Now capabilities defined in this class are added to the capabilities taken from the serenity.properties file.

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

1 participant