webdriverio / webdriverio

Next-gen browser and mobile automation test framework for Node.js
http://webdriver.io
MIT License
9.05k stars 2.51k forks source link

webdriverio v5 didn't run the automation on the mobile device #3230

Closed LayMuiToh closed 5 years ago

LayMuiToh commented 5 years ago

[//]: # NOTE: This repository only maintains packages that are listed in the Readme. Please make sure that your issue is directly caused by one of these packages and if not file an issue in the correct 3rd party package repository.

Environment (please complete the following information):

To Reproduce Steps to reproduce the behavior:

[Include code or an example repository that can easily be set up] Login.page.js:

import Page from './Page';

class Login extends Page {

    /* 
    ** Define elements
    */
    get username()  { return $('~email'); }
    get password()  { return $('~password'); }
    get signin()    { return $('~signin'); }

    open() {
        super.open('login');
    }

    login (user, pass) {
        this.username.setValue(user);
        this.password.setValue(pass);

        driver.isKeyboardShown() &&
        driver.hideDeviceKeyboard();

        this.signin.click();
    }

    //isLoggedIn() {
    //    return this.username.waitForDisplayed() && this.password.waitForDisplayed();
   // }
}

export default new Login();

app.login.spec.js:

import { expect } from 'chai';
import  * as loginacct from '../testdata/config/loginacct';
import Login from '../pageobjects/Login.page';
import Main  from '../pageobjects/Main.page';

module.exports = () => {
 describe('Login test', () => {
  beforeEach(() =>  {
    Login.open();
  });

  afterEach(() => {
  });

  it('should login with a correct credential',  () => {
      let validEmail = loginacct.ALL_ACCESS_EMAILID;
      let validPass =  loginacct.ALL_ACCESS_PASSWORD;

      Login.username.waitForDisplayed();
      Login.username.setValue(validEmail);
      Login.password.waitForDisplayed();
      Login.password.setValue(validPass);
      //Login.isLoggedIn &&
      //Login.login(validEmail, validPass);
      /*
      ** Validate it login to Main Page
      */

Page.js:

export default class Page {
    open(name) {
      driver.isLocked() &&
      driver.unlock();
    }
}

Expected behavior node_modules/.bin/wdio wdio.conf.js --suite login test case should run the automation action on the mobile, but the app just launch and exit

Log No log in appium.log although appium is started [Appium] Welcome to Appium v1.9.1 [Appium] Appium REST http interface listener started on 0.0.0.0:4723 Additional context RUNNING 0-0 in - /test/spec/app.login.spec.js

Test Suites: 0 passed, 1 total (0% completed) Time: 🕕 185.67s but nothing is run on the mobile.

Please use the correct markdown

Gilad-Shnoor commented 5 years ago

@LayMuiToh I had a similar issue in android and have a pending pull request to fix it. Can you please see if you get "Error: InvalidSelectorStrategy" from Login.username.setValue(validEmail); to make sure it's the same error?

christian-bromann commented 5 years ago

@LayMuiToh please use proper markdown to format your code otherwise it is impossible to read. Just pasting your wdio config is not useful too. We need appium logs or wdio logs and maybe even better a minimal reproducible example.

Ponyets commented 5 years ago

@LayMuiToh Just update to 5.2.1. I'd consider it as a bug which was fixed yesterday. https://github.com/webdriverio/webdriverio/pull/3226

christian-bromann commented 5 years ago

Closing this then.

flexin777 commented 5 years ago

Hello Where I can take this object driver? I see only browser.

christian-bromann commented 5 years ago

Where I can take this object driver? I see only browser.

Please have a look at our appium boilerplate https://github.com/webdriverio/appium-boilerplate