You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu下运行Appium的后续操作及Ionic1相关教程咨询

Next Steps After Running appium Command + Ionic1 Appium Tutorial

Hey there! Let's walk through exactly what to do next now that you've got Appium and Appium Doctor set up, plus a tailored guide for testing your Ionic1 app—you're already halfway there!


First: What Happens When You Run appium?

When you execute the appium command in your terminal, you're starting the Appium server. You'll see output like this:

Appium REST http interface listener started on 0.0.0.0:4723

This means the server is listening on port 4723 for test scripts to connect to it. Leave this terminal window open—don't close it while running tests!


Step-by-Step Next Actions

1. Validate Your Environment (Quick Check)

Before diving in, double-check everything is configured correctly with Appium Doctor:

appium-doctor

Fix any red flags it throws (like missing ANDROID_HOME for Android, or Xcode command-line tools for iOS).

2. Prep Your Ionic1 App for Testing

You need a deployable version of your Ionic1 app (for emulator or real device):

  • Android: Run this in your Ionic1 project folder to build a debug APK:
    ionic cordova build android
    
    The APK will be located at platforms/android/app/build/outputs/apk/debug/app-debug.apk
  • iOS: Build the app and open it in Xcode:
    ionic cordova build ios
    
    Open platforms/ios/YourAppName.xcworkspace in Xcode, then compile it to a simulator or real device (you'll need a developer account for real devices).

3. Set Up a Test Project & Dependencies

We'll use WebdriverIO (a popular Appium client for JavaScript) since it's straightforward for Ionic apps.

  1. Create a new folder for your tests:
    mkdir ionic1-appium-tests && cd ionic1-appium-tests
    npm init -y
    
  2. Install required packages:
    npm install webdriverio @wdio/cli @wdio/local-runner @wdio/mocha-framework @wdio/spec-reporter
    

4. Configure WebdriverIO (WDIO)

Generate a config file by running:

npx wdio config

Follow the prompts:

  • Choose Mocha as your test framework
  • Pick Spec as your reporter (simple, readable output)
  • Select Appium as your service

Now open wdio.conf.js and update the capabilities section to match your device and app path. Here are examples:

Android Capabilities Example

capabilities: [{
    platformName: 'Android',
    'appium:deviceName': 'Pixel_3a_API_33', // Use your emulator/device name (check with `adb devices`)
    'appium:automationName': 'UiAutomator2',
    'appium:app': '/full/path/to/your/ionic1-app/platforms/android/app/build/outputs/apk/debug/app-debug.apk',
    'appium:noReset': true, // Optional: Prevents resetting the app between tests
}],

iOS Capabilities Example

capabilities: [{
    platformName: 'iOS',
    'appium:deviceName': 'iPhone 14', // Use your simulator/device name
    'appium:automationName': 'XCUITest',
    'appium:app': '/full/path/to/your/ionic1-app/platforms/ios/build/debug-iphonesimulator/YourAppName.app',
    'appium:noReset': true,
}],

5. Write Your First Ionic1 Test

Create a file at test/specs/app.test.js with this sample test (adjust selectors to match your app):

describe('Ionic1 App Basic Tests', () => {
    it('loads the home page and verifies the title', async () => {
        // Wait for the main content to load (Ionic1 uses ion-content)
        await $('ion-content').waitForDisplayed({ timeout: 10000 });
        
        // Grab the page title (adjust selector to match your app's title element)
        const pageTitle = await $('ion-title').getText();
        console.log('Home page title:', pageTitle);
        
        // Assert the title is correct
        expect(pageTitle).toBe('My Awesome Ionic1 App');
    });

    it('navigates to a second page when a button is tapped', async () => {
        // Find and tap a navigation button (use your button's ID or class)
        const navButton = await $('#nav-to-second-page');
        await navButton.click();
        
        // Wait for the second page to load
        await $('ion-page[aria-label="Second Page"]').waitForDisplayed();
        
        // Verify the second page's title
        const secondPageTitle = await $('ion-title').getText();
        expect(secondPageTitle).toBe('Second Page');
    });
});

6. Run Your Tests

  1. Make sure the Appium server is still running in its terminal window (the one where you ran appium).
  2. In your test project's terminal, run:
    npx wdio run wdio.conf.js
    

You'll see your emulator/real device launch your Ionic1 app, automatically run the test steps, and the terminal will output whether the tests passed or failed.


Ionic1-Specific Tips

  • Element Selection: Use Chrome DevTools (for Android) or Safari Web Inspector (for iOS) to inspect your app's elements. Ionic1 adds classes like ion-button, ion-list, and ion-card that you can use as selectors.
  • WebView Handling: If your app uses WebViews (common in Ionic), switch contexts to interact with web content:
    // Get all available contexts
    const contexts = await driver.getContexts();
    // Switch to the WebView context (replace with your app's package ID)
    await driver.switchContext('WEBVIEW_com.your.app.id');
    
  • Slow Load Times: Ionic1 apps can take a few seconds to load, so use waitForDisplayed() with a reasonable timeout (10-15 seconds) instead of hardcoding delays.

内容的提问来源于stack exchange,提问作者Nidhin Kumar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 10:12:48