From Lousy Kitten, 3 Months ago, written in Plain Text.
  1. // javascript
  2.  
  3. const wdio = require("webdriverio");
  4.  
  5. const opts = {
  6.   port: 4723,
  7.   capabilities: {
  8.     platformName: "Android",
  9.     platformVersion: "8.0",
  10.     deviceName: "Android Emulator",
  11.     app: "/home/nabil/FWork/nike_snkrs_automation/ApiDemos-debug.apk",
  12.     automationName: "UiAutomator2"
  13.   }
  14. };
  15.  
  16. (async() => {
  17. const client = wdio.remote(opts);
  18.  
  19. const elementId = await client.findElement("accessibility id","TextField1");    client.elementSendKeys(elementId.ELEMENT, "Hello World!");
  20. const elementValue = await client.findElement("accessibility id","TextField1");
  21. await client.getElementAttribute(elementValue.ELEMENT,"value").then((attr) => {
  22. assert.equal(attr,"Hello World!");
  23. });
  24. })();
  25.  
captcha