Unable to findByXpath using Leadfoot / Intern

325 views Asked by At

Using Intern JS with WebDirver to communicate with Appium 1.4.1, I have a simple functional test, part of which should find a text input box on the login screen of our iOS app, tap into it and type the user's login name:

define([
    'intern!object',
    'intern/chai!assert',
    'require'
], function (registerSuite, assert, require) {
    registerSuite({
        name: 'Suite Name',

        'Login Screen': function () {
            return this.remote
                .setFindTimeout(50000)
 .findByXpath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/UIATextField[1]")
                .tap()
                .type('[email protected]')
                .end()
                .then(function (pagetitle) {
                assert.strictEqual(pagetitle, 'DEMO COLLEGE',
                    'Should land on app dashboard with school title displayed');
            });
    }
});
});

When executed using intern-runner everything appears to go well, Appium launches our app and awaits my input - but no matter what I try I can't find the element I need to type into using Leadfoot's findByXpath:

$ intern-runner config=tests/appium
Listening on 0.0.0.0:9000
Starting tunnel...
Initialised iOS on MAC 8.1
Test main - Suite Name - Login Screen FAILED on iOS on MAC 8.1:
NoSuchElement: [POST http://[appium-server-address]:4723/wd/hub/session/80e20453-452e-4181-8713-4f9e0cfa427f/element /     {"using":"xpath","value":"//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/UIATextField[1]"}] An element could not be located on the page using   the given search parameters.
  at Server._post      <../../.nvm/v0.10.35/lib/node_modules/intern/node_modules/leadfoot/Server.js:68:9>

Using Appium's GUI "inspector" I've confirmed the Xpath to the text-input-box element is:

"//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/UIATextField[1]"

Can anyone suggest where I'm going wrong please?

1

There are 1 answers

0
steveharman On

Looks like the Appium Inspector tool on my Mac was duplicating part of the path?

.findByXPath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/**UIATextField[1]**")
.type("wibble")

Remove the duplicated element in bold (the final UIATextField[1]) ....

.findByXPath("//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIATextField[1]/**UIATextField[1]**")
.type("wibble")

And it works.

Thanks Appium Inspector. Thanks a lot.