0

I wrote a script to automate my app using appium with java-script(nodejs), but when I run it I am getting error.

This is the code which I have written.

var webdriverio = require('webdriverio'); 
var except = require('chai').expect; 
var config = require(
{
 port: 4723,
 desiredCapabilities: {
   platformName: "Android",
   platformVersion: "8.1.0",
   deviceName: "00b8afc289da4196",
   app: "/home/user/auto_test/xxx.apk",
   automationName: "UiAutomator2"
  }
}); 
const client = webdriverio.remote(config);

//addition testing 
describe("Simple cases", function () {
  before(function () { 
    this.timeout(50000);
    return client.init();
});
afterEach(function(){
    this.timeout(50000);
    return client.init();
});
describe("test-signup", function(){

    it("signup_click", function(){
    client
        .click('android=new UiSelector().resourceId("com.xxx.xxx:id/txt_log_in")')      
    });
});
after(function() {
return client.end(); 
  });
});

And this is the error which I am getting.

2019-01-02T11:49:15.769Z DEBUG wdio-config: wdio-sync not found, running tests asynchronous
TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received type object
at Module.require (internal/modules/cjs/loader.js:653:11)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/home/user/automation/tile2.js:3:14)
at Module._compile (internal/modules/cjs/loader.js:723:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:734:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:776:12)
at executeUserCode (internal/bootstrap/node.js:342:17)
0

The error message tells you that the problem is at line 3, with the require call.

at Module.require (internal/modules/cjs/loader.js:653:11)

at require (internal/modules/cjs/helpers.js:22:18)

at Object. (/home/user/automation/tile2.js:3:14)

When you initialize the config variable, you do not need to call the require function. Check the example here, the relevant part:

// javascript
const opts = {
  port: 4723,
  desiredCapabilities: {
    platformName: "Android",
    platformVersion: "8.0",
    deviceName: "Android Emulator",
    app: "/path/to/the/downloaded/ApiDemos.apk",
    automationName: "UiAutomator2"
  }
};

const client = wdio.remote(opts);

and what you have is:

var config = require(
{
 port: 4723,
 desiredCapabilities: {
   platformName: "Android",
   platformVersion: "8.1.0",
   deviceName: "00b8afc289da4196",
   app: "/home/user/auto_test/xxx.apk",
   automationName: "UiAutomator2"
  }
}); 
const client = webdriverio.remote(config);

So all in all remove the require call from line 3 and leave the rest.

  • @manoj Did you manage to solve the problem? – Bence Kaulics Jan 5 at 22:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.