NativeScript / nativescript-dev-appium

A package to help with writing and executing e2e Appium tests in NativeScript apps
Apache License 2.0
70 stars 27 forks source link

Unable to select NavigationButton in ActionBar to open radSideDrawer #257

Closed Yermo closed 5 years ago

Yermo commented 5 years ago

Environment

Ubuntu 18.04.1 LTS

✔ Getting NativeScript components versions information...
✔ Component nativescript has 6.1.0 version and is up to date.
✔ Component tns-core-modules has 6.1.1 version and is up to date.
✔ Component tns-android has 6.1.0 version and is up to date.
✔ Component tns-ios has 6.1.0 version and is up to date.

  "dependencies": {
    "@angular/animations": "~8.2.0",
    "@angular/common": "~8.2.0",
    "@angular/compiler": "~8.2.0",
    "@angular/core": "~8.2.0",
    "@angular/forms": "~8.2.0",
    "@angular/platform-browser": "~8.2.0",
    "@angular/platform-browser-dynamic": "~8.2.0",
    "@angular/router": "~8.2.0",
    "nativescript-angular": "~8.2.0",
    "nativescript-theme-core": "~1.0.6",
    "nativescript-ui-sidedrawer": "~7.0.0",
    "reflect-metadata": "~0.1.12",
    "rxjs": "^6.4.0",
    "tns-core-modules": "~6.1.0",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular/compiler-cli": "~8.2.0",
    "@ngtools/webpack": "~8.2.0",
    "@types/chai": "~4.1.7",
    "@types/mocha": "~5.2.5",
    "@types/node": "~10.12.18",
    "chai": "~4.1.2",
    "codelyzer": "~4.5.0",
    "mocha": "~5.2.0",
    "mocha-junit-reporter": "~1.18.0",
    "mocha-multi": "~1.0.1",
    "mochawesome": "~3.1.2",
    "nativescript-dev-appium": "^6.0.0",
    "nativescript-dev-webpack": "~1.2.0",
    "node-sass": "^4.7.1",
    "tslint": "~5.19.0",
    "typescript": "~3.5.3"
  },

Describe the bug

My app is based off the Side Drawer template.

From a test, I would like to open the Rad Side Drawer and select an item from it to navigate to another page.

I am unable to select the NavigationButton or anything else in the ActionBar for that matter.

To Reproduce

For an Android target:

tns create my-drawer-ng --template tns-template-drawer-navigation-ng
 npm install -D nativescript-dev-appium

Add

automationText="Side Drawer Button"

to NavigationButton in src/app/home/home.component.html

Then in e2e/sample.e2e-spec.ts attempt to get a reference to the button using

    it("should find the side drawer button", async function () {
        const btnTap = await driver.findElementByAutomationText("Side Drawer Button");
        await btnTap.click();

        // TODO: select an item from the opened drawer
    });

run the test using:

npm run e2e -- --runType android28 --verbose

Note that it does not find the button:

  1) sample scenario
       should find the side drawer button:
     Error: [waitForElementByXPath("//*[translate(@content-desc,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='side drawer button' or translate(@resource-id,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='side drawer button' or translate(@text,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='side drawer button']",5000)] Element condition wasn't satisfied!
      at /usr/local/YML/Projects/my-drawer-ng/node_modules/wd/lib/commands.js:979:12
      at /usr/local/YML/Projects/my-drawer-ng/node_modules/wd/lib/commands.js:884:11
      at /usr/local/YML/Projects/my-drawer-ng/node_modules/wd/lib/commands.js:966:13
      at /usr/local/YML/Projects/my-drawer-ng/node_modules/wd/node_modules/async/dist/async.js:3888:9
      at /usr/local/YML/Projects/my-drawer-ng/node_modules/wd/node_modules/async/dist/async.js:473:16
      at replenish (node_modules/wd/node_modules/async/dist/async.js:1006:25)
      at /usr/local/YML/Projects/my-drawer-ng/node_modules/wd/node_modules/async/dist/async.js:1016:9
      at eachOfLimit (node_modules/wd/node_modules/async/dist/async.js:1041:24)
      at /usr/local/YML/Projects/my-drawer-ng/node_modules/wd/node_modules/async/dist/async.js:1046:16
      at _parallel (node_modules/wd/node_modules/async/dist/async.js:3879:5)
      at Object.series (node_modules/wd/node_modules/async/dist/async.js:4735:5)
      at /usr/local/YML/Projects/my-drawer-ng/node_modules/wd/lib/commands.js:964:15
      at /usr/local/YML/Projects/my-drawer-ng/node_modules/wd/lib/promise-webdriver.js:52:11
      at _fulfilled (node_modules/q/q.js:854:54)
      at /usr/local/YML/Projects/my-drawer-ng/node_modules/q/q.js:883:30
      at Promise.promise.promiseDispatch (node_modules/q/q.js:816:13)
      at /usr/local/YML/Projects/my-drawer-ng/node_modules/q/q.js:624:44
      at runSingle (node_modules/q/q.js:137:13)
      at flush (node_modules/q/q.js:125:13)
      at process._tickCallback (internal/process/next_tick.js:61:11)

Expected behavior

It should find the NavigationButton so that it can be clicked on.

Sample project

It's just the side drawer sample.

Additional context Is it not possible to select anything in an ActionBar?

SvetoslavTsenov commented 5 years ago

@zbranzov, @DimitarTodorov any idea here

DimitarTodorov commented 5 years ago

Hi, @Yermo

I've just inspected the app with Appium Desktop app and it seems that automationText property is not respected when set on <NavigationButton> or <ActionItem> elements in <ActionBar>. You can use another approach where selecting element by class using android.widget.ImageButton will return you a single element which will be the desired button for opening SideDrawer.

const btn = await driver.findElementByClassName('android.widget.ImageButton');
await btn.click();

Check out the Appium Desktop app with it you can easily inspect elements and record steps for interacting with elements.

support[bot] commented 5 years ago

:wave: @Yermo, we use the issue tracker exclusively for bug reports and feature requests. However, this issue appears to be a support request. Please, use Stackoverflow to get help.