I’m new to Appium and I’m using it (writing tests in Java) to automate an Android app (app A). One of the things that this app does it to send an intent which starts another app (app B). Is it possible to automate app B from within the same test case that manipulates app A? I’ve Googled this and found a few results for a similar problem (where you manually start a second app using driver.startActivity()) but I haven’t seen anything yet that provides more info on my specific scenario. Thanks for any information!
@bmt22033: You should be able to do this – we work with multiple applications as part of our automation. Appium is concerned with what’s on the screen at present.
Thanks @willosser. The last line in my current test case looks like this:
driver.findElement(By.id("com.geos.android:id/btnLaunchMapViewer")).click();
Once this line executes, it should click on the button in my app which will then cause the second app to be started. When I do this manually, it works as expected. When I try to do it in my coded test case, the test just ends after this line and I never see the second app. I’ve tried adding something like this in my test case:
WebDriverWait wait = new WebDriverWait(driver, 5);
wait.until(ExpectedConditions.presenceOfElementLocated(By.name("maps")));
Unfortunately, that doesn’t help. The wait just times out, the app exits and I still never see the second app. I’m guessing there’s something else I need to do in order to manipulate this second app but I don’t know what it is. Do I need to re-initialize the driver using the appPackage and appActivity properties for the second app? Or is that just for launching the app? Thanks again for reading this!
@bmt22033 That behavior surprises me as we click on buttons which launch other apps in our automation. We use Ruby, but I wouldn’t suspect the implementations are that different.
Because your call to findElement() doesn’t raise an exception, My guess is that it’s successful. Can you visually confirm that that button is being pressed? Can you try pressing it manually during your explicit wait and verify the app launches in that case?
I’d like to take a look at some logs as well. Can you copy your Appium logs from the moment Appium receives the command to click on the button to the end of the test session? Use something like a pastebin to post your logs so you don’t end up spamming the forum.
@willosser @afwang Thanks to both of you for replying. I appreciate it. As it turns out, there was a bug in the second app that was causing this problem. I’ve gotten that fixed and now it’s working as I expected it to. Thanks again to both of you!