Jbehave + Appium


#1

Hi!
Can you help me? how add to appium project Jbehave library? and start test by story.


#3

Hi,

I am using Jbehave with Appium in a project. You can basically use Jbehave Web for Selenium.

To get it working you have to implement the WebDriverProvide interface. The class has to provide the Appium IOSDriver or Android driver. This driver provider class you just pass to the SeleniumConfiguration using the useWebDriverProvider method. This should do the basic setup.

In my project I am running stories in parallel, so I overwrite the DelegatingWebDriverProvider class. It looks similar like this:

public class MyIosDriverProvider extends DelegatingWebDriverProvider {

private DesiredCapabilities iosCapabilities;
private URL hubUrl;

public MyIosDriverProvider(DesiredCapabilities iosCapabilities, URL hubUrl) {
this.iosCapabilities = iosCapabilities;
this.hubUrl = hubUrl;
}

private IOSDriver createDriver() {
return new IOSDriver(hubUrl, iosCapabilities);
}

@Override
public void initialize() {
delegate.set(createDriver());
}

public IOSDriver getAppDriver() {
if (delegate.get() != null) {
return (IOSDriver)delegate.get() ;
}
return null;
}

I pass an object of this class to the step definition classes, so I am able the use the getAppDriver method to get the app driver and use Appium specific methods like resetApp().


#4

Hi @Feature

I’m using jbehave with sellenium

The story :
Given connection to ios with iPhone with sevenPone is established

The Java conversion :

@Given("connection to ios with $device with $version is established")
public void setConnIOS(@Named("device") String device, @Named("version") String version){
    try {
        System.setProperty(ConstStrings.OSTYPE_FIELD, "ios");
        conn = connectionFactory.setConnection("ios", Devices.valueOf(device), Versions.valueOf(version));

        setImplFactory("ios");
    } catch (UnreachableBrowserException | SessionNotCreatedException ex){
        System.err.println("Cannot establish appium connection !!  --->  TERMINATING --> " + ex.getMessage());
        System.exit(1);
    }
}

This is the direction …

Do you need something specific ?


#5

how you will get your locators in page ?


#6

Jbehave is just BDD way of testing, we can still use the same page object pattern and reuse them in this approach