Cookie Consent by Free Privacy Policy Generator 📌 Automating Android TV app with Nightwatch


✅ Automating Android TV app with Nightwatch


💡 Newskategorie: Programmierung
🔗 Quelle: dev.to

I joined a company that recently introduced a TV app 📺 for their platform. A curious cat 😺 like I am, I raised my hand and immediately jumped into finding ways to automate this piece of art. It is highly similar to Mobile apps but simple clicks and double taps just won't work, we need to use the Directional Pads (DPAD) 🎛️ and their relevant values (aka remote control for TV's).

I did some googling (aka 'research' in the digital world) and long story short, I ended up using Nightwatch 🦉 since we are also planning to launch it with Apple TV. Hence, there are advantages of having a single tool to automate both.

First, we need to install 🚀 the following:

  • Appium, the automation framework for mobile & TV apps and Nightwatch runs at the back of this.
  • Android Studio & SDK tools, IDE used for building and testing Android apps and used to create a TV app emulator
  • Create a TV app emulator from Android Studio via Device Manager TV emulator
  • Java JDK & runtime, as required for any Android activities
  • Nightwatch which will prompt to create a boilerplate framework specifically for Mobile / TV apps.
  • Create a new folder called apps and place the .apk file there (this is the working package and if you don't have it, ask your friendly dev to give it to you).

Then, we need to build the test scripts in the project directory.
The configuration file: nightwatch.conf.js:

  'app.android.emulator': {
      extends: 'app',
      'desiredCapabilities': {
          // More capabilities can be found at https://github.com/appium/appium-uiautomator2-driver#capabilities
          browserName: null,
          platformName: 'android',
          // `appium:options` is not natively supported in Appium v1,but works with Nightwatch.
          // If copying these capabilities elsewhere while using Appium v1,make sure to remove `appium:options`
          // and add `appium:` prefix to each one of its capabilities,e.g. change 'app' to 'appium:app'.
          'appium:options': {
          automationName: 'UiAutomator2',
          // Android Virtual Device to run tests on
          avd: 'TV_1080p',
          orientation: 'PORTRAIT',
          // While Appium v1 supports relative paths,it's more safe to use absolute paths instead.
          // Appium v2 does not support relative paths.
          app: `${__dirname}/apps/tv-app.apk`,
          appActivity: 'com.tv.app.MainActivity', // include this if app does not start on its own - 
          // chromedriver executable to use for testing web-views in hybrid apps.
          // add '.exe' at the end below (making it 'chromedriver.exe') if testing on windows.
          chromedriverExecutable: `${__dirname}/chromedriver-mobile/chromedriver`,
          newCommandTimeout: 0
          }
      }
  },

NOTE: if you don't know the value for appActivity, open the .apk file in Android Studio then look for AndroidManifest.xml then search for "activity":

appActivity

The test / spec file nav.spec.js:

describe('navigate the menus', function() {
    test('should be able to navigate left menu', async function(app) {
        await app.appium.pressKeyCode(20) // presses down once
            .waitForElementVisible('xpath', '//android.widget.TextView[@text="Search"]')

        await app.appium.pressKeyCode(20)  // presses down once
            .waitForElementVisible('xpath', '//android.widget.TextView[@text="Settings"]');

        await app.appium.pressKeyCode(23) // presses the centre pad to close the left menu again
            .waitForElementNotPresent('xpath', '//android.widget.TextView[@text="Home"]');
    });

    // guide on DPADS keys which you can place in a page object file
    // dpadCenter: 23,
    // dpadLeft: 21,
    // dpadRight: 22,
    // dpadUp: 19,
    // dpadDown: 20
});

NOTE: As mentioned earlier, to simulate real user experience, you need to use the remote or directional pads. Refer to this guide for the complete numeric values.

Lastly, we need to test and run if the automation actually works:

  • Run appium from a separate terminal with the same command
  • Open another terminal then open the newly-created emulator with the command emulator -avd TV_1080p
  • Run the test with npx nightwatch tests --env app.android.emulator and watch it work! 🎮

To inspect elements, it is recommended to download the Appium Inspector or use the browser version.

I also joined the Nightwatch Discord channel to ask questions as I had hiccups along the way.

Enjoy! 🎉

...

✅ Automating Android TV app with Nightwatch


📈 53.84 Punkte

✅ Protequus Launches Nightwatch Edge-Computing Smart Halter, An Early Warning System For Horses


📈 34.73 Punkte

✅ Automating your app releases with Google Play


📈 16.8 Punkte

✅ Domo’s App Studio provides simple no-code interface for automating business processes


📈 16.8 Punkte

✅ More Fast Food Restaurants Are Now Automating


📈 14.03 Punkte

✅ Automating security? Robots can't replace humans in decision loop


📈 14.03 Punkte

✅ After Automating Order-Taking, Fast Food Chains Had to Hire More Workers


📈 14.03 Punkte

✅ 'Automating Jobs Is How Society Makes Progress'


📈 14.03 Punkte

✅ What's on the Wireless? Automating RF Signal Identification


📈 14.03 Punkte

✅ Automating TLS Configuration Verification - AppSecUSA 2017


📈 14.03 Punkte

✅ Automating Code Quality


📈 14.03 Punkte

✅ Linux Private-i is a custom enumeration tool to assist in privilege escalation by automating tasks.


📈 14.03 Punkte

✅ Automating in Security With Intelligence


📈 14.03 Punkte

✅ IT Science Case Study: Automating a Statewide Child Welfare System


📈 14.03 Punkte

✅ Automating reports of phishing domains


📈 14.03 Punkte

✅ Artificial intelligence is automating attacks on political campaigns


📈 14.03 Punkte

✅ DEF CON 26 BLUE TEAM VILLAGE - rainbow tables - Automating DFIR The Counter Future


📈 14.03 Punkte

✅ IT Science Case Study: Automating IT Infrastructure to Go with the Flow


📈 14.03 Punkte

✅ PepsiCo Is Laying Off Corporate Employees As the Company Commits To 'Relentlessly Automating'


📈 14.03 Punkte

✅ Automating Arch Linux setup on an RPi


📈 14.03 Punkte

✅ Automating bug hunting by modeling vulnerable code, with examples using Binary Ninja, IDA, and Ghidra


📈 14.03 Punkte

✅ Firmware Slap: Automating the discovery of exploitable vulnerabilities in Firmware


📈 14.03 Punkte

✅ Automating Service Acct PW Changes - Product Recommendation?


📈 14.03 Punkte

✅ Black Hat USA 2018 Automating Exploit Generation for Arbitrary Types of Kernel Vulnerabilities


📈 14.03 Punkte

✅ Automating Secure Configuration Management in the Cloud


📈 14.03 Punkte

✅ DEF CON 27 - Firmware Slap Automating Discovery of Exploitable Vulnerabilities in Firmware


📈 14.03 Punkte

✅ DEF CON 27 - Firmware Slap Automating Discovery of Exploitable Vulnerabilities in Firmware


📈 14.03 Punkte

✅ Guardians of the Cloud: Automating the Response to Security Events


📈 14.03 Punkte

✅ Automating (not securing) one-time use SMS authentication codes


📈 14.03 Punkte

✅ eBook: Automating Incident Response


📈 14.03 Punkte

✅ Slack Bug Allowed Automating Account Takeover Attacks


📈 14.03 Punkte

✅ Customizing and automating an Arch Linux install using Anarchy


📈 14.03 Punkte

✅ CloudBlue Connect’s new features aid businesses in streamlining and automating more processes


📈 14.03 Punkte











matomo

Datei nicht gefunden!