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

Is it possible to test two application simultaneously through Selendroid? #551

Closed
ygsh opened this issue Aug 28, 2014 · 8 comments
Closed

Comments

@ygsh
Copy link

ygsh commented Aug 28, 2014

Hi,

I am looking to automate the testing of our product that basically has two apps that talk to each other.
I have tried to follow the example configuration provided and see if this is possible, so far I have not had success. Can you please tell me if this is possible at all?

Small snippet is below, the fist app's config launches fine, on the 2nd app, I am getting the following error.

Aug 28, 2014 3:27:38 PM io.selendroid.server.model.DeviceStore findAndroidDevice
INFO: Evaluating if this device is a match for this session: AndroidEmulator [screenSize=WQVGA432, targetPlatform=ANDROID17, serial=emulator-5554, avdName=Android4.4.2_Test]
Aug 28, 2014 3:27:38 PM io.selendroid.server.model.DeviceStore findAndroidDevice
INFO: Device is in use.

This is the command I used to launch the server with both the application provided.

java -jar selendroid-standalone-0.11.0-with-dependencies.jar -app test_android.apk -app test_android_service.apk

Thanks,
Ygsh

@operatiay
Copy link
Contributor

Ygsh, you need to work with 2 selendroid server instances. Each of the instances would work with dedicated app. Make sure to use different ports.

@ygsh
Copy link
Author

ygsh commented Aug 28, 2014

Thank you operatiay. I will try this.

Best,
Ygsh

@ygsh
Copy link
Author

ygsh commented Aug 28, 2014

Hi Operatiay,

I tried to do this and also went through #106 but have come across 2nd Selenium server not coming up on my device.

For the first Selendroid server I get as below:

INFO: got response status code: 200
Aug 28, 2014 5:02:36 PM io.selendroid.android.impl.AbstractDevice isSelendroidRunning
INFO: got response value: {"value":{"supportedApps":[],"build":{"browserName":"selendroid","version":"0.11.0"},"os":{"arch":"armeabi-v7a","version":"17","name":"Android"},"supportedDevices":[]},"status":0}
new Session URL: http://localhost:4444/wd/hub/session/e64910cb-a2cb-3def-0070-da9dd9c91f6e
Aug 28, 2014 5:02:37 PM io.selendroid.server.handler.GetCapabilities handle
INFO: get capabilities command

It does not proceed from here.

For the 2nd Selendroid instance I am getting error as below:

INFO: I/O exception (java.net.SocketException) caught when processing request to {}->http://localhost:8084: Connection reset
Aug 28, 2014 5:03:04 PM org.apache.http.impl.client.DefaultHttpClient tryExecute
INFO: Retrying request to {}->http://localhost:8084
Aug 28, 2014 5:03:04 PM io.selendroid.android.impl.AbstractDevice isSelendroidRunning
SEVERE: Error getting status: java.net.SocketException: Connection reset
Aug 28, 2014 5:03:04 PM io.selendroid.server.handler.CreateSessionHandler handle
SEVERE: Error while creating new session: Selendroid server on the device didn't came up after 20sec:
io.selendroid.exceptions.SelendroidException: Selendroid server on the device didn't came up after 20sec:

This is my code that interacts with these Selenium servers:

SelendroidConfiguration config1 = new SelendroidConfiguration();
SelendroidConfiguration config2 = new SelendroidConfiguration();
config1.addSupportedApp("src/main/resources/test_android.apk");
config2.addSupportedApp("src/main/resources/test_android_service.apk");
selendroidServer = new SelendroidLauncher(config1);
selendroidServer = new SelendroidLauncher(config2);
SelendroidCapabilities caps1 = SelendroidCapabilities.device("com.test.basicapp:1.9.2");
first_driver = new SelendroidDriver(new URL("http://localhost:4444/wd/hub"), caps1);
SelendroidCapabilities caps2 = SelendroidCapabilities.device("com.test.service.demo:4.2.4");
serviceapp_driver = new SelendroidDriver(new URL("http://localhost:4445/wd/hub"), caps2);

Please let me know if there are mistakes in my approach.

Best,
Ygsh

@sri096
Copy link

sri096 commented Aug 28, 2014

Hi Ygsh,

You can only run one instance of Selendroid Standalone server at any instance of time. so you dont need to create two Configs. use config.addSupportedApp("test1.apk"), config.addSupportedApp("test2.apk") function to add as many AUT's you are planning to test. Create two web driver objects with same URL http://localhost:4444/wd/hub, but with two different capabilities. Use Selendroid Driver object, and use driver.backgroundApp() to move AUT to background, and use driver.resumeApp() to bring the AUT to foreground.

I didnt tried this but this should work. Probably I will try this and get back to you soon.

Regards,
Kamesh.

@ygsh
Copy link
Author

ygsh commented Aug 28, 2014

Hi Kamesh,

Thank you for your input. I have tried this but does not seem to work. When the 2nd app is getting installed at that time I get an error saying "Device in use".

Do let me know if you are able to do this.
Thanks,
Ygsh

@sri096
Copy link

sri096 commented Sep 2, 2014

Hi Ygsh,

This is working, I am able to switch between AUTs. Below is the sample code I used in my setup method.

    SelendroidConfiguration config = new SelendroidConfiguration();

    config.addSupportedApp(“test1.apk");
    config.addSupportedApp(“test2.apk");

    selendroidServer = new SelendroidLauncher(config);
    selendroidServer.launchSelendroid();


    SelendroidCapabilities testApp1Caps = SelendroidCapabilities.device(AUT1);
    URL url = new URL("http://localhost:4444/wd/hub");

    testApp1Driver = new SelendroidDriver(url, testApp1Caps);
    testApp1Driver.backgroundApp();  

    SelendroidCapabilities testApp2Caps = SelendroidCapabilities.device(AUT2);

    testApp2Driver = new SelendroidDriver(url, testApp2Caps);
    testApp2Driver.backgroundApp();  
    testApp1Driver.resumeApp();

In case you see any issues, restart adb server from command line.

Regards,
Kamesh.

@DominikDary
Copy link
Member

A while ago I verified this and in general it works. The issue is, that before #106 is not done, this is not available via selendroid-standalone.

@ygsh
Copy link
Author

ygsh commented Sep 4, 2014

Thank you so much @sri096 @DominikDary.
Best,
Ygsh

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