Search code examples
javascriptwinappdriver

WinAppDriver canonot find element when new window of desktop application created


"use strict";
require("./helpers/setup");

var wd = require("wd"),
    _ = require('underscore'),
    serverConfigs = require('./helpers/appium-servers'),
    Q = require('q');

describe("Windows test from Node", function () {
  this.timeout(300000);
  var driver;
  var allPassed = true;

  before(function () {
    var serverConfig = serverConfigs.local;
    driver = wd.promiseChainRemote(serverConfig);
    require("./helpers/logging").configure(driver);

    var desired = _.clone(require("./helpers/caps").CMS);

    return driver
    .init(desired);

  });

  after(function () {
    return driver
      .quit();
  });

  afterEach(function () {
    allPassed = allPassed && this.currentTest.state === 'passed';
  });

  it("should open CMS.", function () {
    return driver
    .elementByName('CharwellDB').doubleclick()
    .sleep(20000);
  });

  it("should login CMS.", function () {    
    return driver
    .elementByAccessibilityId('m_tbUserID').sendKeys("")
    .elementByAccessibilityId('m_tbPassword').sendKeys("")
    .elementByAccessibilityId('m_btnOk').click();
  });
});

Hi, I'm using https://github.com/Clemensreijnen/AppiumOnWindowsWithJS/blob/master/README.md framework and trying to automate a desktop application. After "should open CMS", a new desktop window open and the winappdriver couldn't locate the element on that window, I tried to work with WindowHandle but not going well with JavaScript, Please give some advise, thanks in advance!


Solution

  • I couldn't find my source code, but the solution is to implement windowHandle and as well as promise in JavaScript.