Brandon Tweed Brandon Tweed - 1 year ago 87
Bash Question

Removing a specific adb shell command in favor of using Appium

I'm reviewing some existing Appium-based automation for an Android app and in a few places there are direct shell calls to adb from within the code. I suspect the author did this because he or she could not find a good way to perform the equivalent action with Appium. Here is the adb command:

adb shell am start -d https://<various_url_details_here>

When the automation executes it has the effect of triggering the 'Open with' dialog so that the user can tap on various options, such as the Browser or an app. Is there a way to execute this specific command with Appium without directly executing shell commands? If such a way exists, is it a good idea?

Answer Source

Using AndroidDriver.get() function:

private WebDriver driver;

public void setUp() throws Exception {
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability(..., ...);
    driver = new AndroidDriver(new URL(""), capabilities);

public void testcase_001() throws Exception{
    driver.get("https://<various_url_details_here>");  // Here is what you want
    WebDriverWait wait = new WebDriverWait(driver, 30);

public void tearDown() throws Exception {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download