GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Localization testing with appium mocha · Issue #260 · NativeScript/nativescript-dev-appium

Localization testing with appium mocha #260

New issue
Copy link
New issue
Copy link
Open
Open
Localization testing with appium mocha#260
Copy link

Description

@schnapzz
schnapzz
opened on Sep 23, 2019
Issue body actions

Hi.

I'm currently trying to figure out a good way to test localization of an app and have some trouble accessing the label text of a button UIElement after i've accessed the element by automation text. After accessing the button UIElement i'm only able to get the automationText to test against.
It's my first time doing any form of testing with nativescript, appium and mocha and i might go about it completely wrong and if so advise would be much appreciated.

What i'm testing on
iPad simulator (9.7 inch) with OS v. 12.4
node v10.16.3
npm v6.9.0
{N} v. 6.0.1
runtimes v 6.0.1
nativescript-localize for i18n localization

I've followed setup instructions and found some issues here where people hadn't installed carthage, which i've installed.

A simple test looks something like this
const daDK = require(dk.default.json); // localization file for danish const changeUserButton = await driver.findElementByAutomationText('changeUserButton'); expect(await changeUserButton.text()).to.be.equal(daDK.user.change_user);
Doing a log of the await changeUserButton.text() retreives the automationText where it should have been Skift Bruger.

I've also tried to access elements in different way ie. with findElementByXPath and findElementByText (though i've read text is only android).

Any suggestions as to solve this?

Activity

  1. schnapzz commented on Sep 27, 2019

    @schnapzz
    schnapzz
    on Sep 27, 2019
    Author
    More actions

    My struggles to do localization tests continues today and i hope someone can share some light in my currently dark and unimaginative thought process.
    The problem is along the same lines as my previous comment but now i cannot extract text from labels - atleast on ios! Android does this fine though.

    I've got this label on a page
    <Label id="createUserTitle" class="userCreationHLabel" text="{{ L('user.user_create.title') }}" horizontalAlignment="center" automationText="titleLabel" />
    and when i'm fetching this label in my e2e-specc file i'm doing the same as before,
    const titleLabel = await driver.findElementByAutomationText('titleLabel');
    Both platforms locate the object without issue. When I'd like to make a simple test to check the text within the label I do
    expect(await titleLabel.text()).to.be.equal(daDK.user.user_create.title);
    where daDK.user.user_create.title = Bruger.

    If i do this on a textfield and i insert some text using the
    someTextFieldUIElementObject.type('test text')
    and then running
    someTextFieldUIElementObject.text()
    it outputs the text that was just typed. So to me it seem like an issue with ui-element objects that have "static" text like labels and buttons, where they are created with the automation text as their text property instead if the actual textproperty.

  2. schnapzz commented on Jan 6, 2020

    @schnapzz
    schnapzz
    on Jan 6, 2020
    Author
    More actions

    In light of this new blog entry from Nativescript i thought i'd try once more to get appium and Nativescript working with textual elements.
    So i've updated everything to the latest versions as follows,

    Appium: 1.16.0
    nativescript-dev-appium: 6.1.3
    node: 10.18.0
    {N}: 6.1.2
    npm: 6.13.4

    I've isolated the issue enough to conclude it's not something that's wrong with my previous implementation. Creating the default template using
    tns create
    adding appium using
    npm install --save-dev nativescript-dev-appium
    and then adding automationTexts to the UI elements of the main-page.xml still makes it retreive the automation text upon calling
    await someLabelElement.text()

    Is this really intentional and if so what is the best practice to test textual elements? This is quite troublesome, not only for localization testing but also if dynamic text is used anywhere in your app!

    For the sake of clarity i've added a screenshot of the main-page.xml, the e2e.specc generated when adding the appium package and the result.

    ANY help would be appreciated or we have to find some other solution to test with.

    Screenshot 2020-01-06 at 15 49 11

    Screenshot 2020-01-06 at 15 48 54

    Screenshot 2020-01-06 at 15 48 27

  3. keerl commented on May 10, 2020

    @keerl
    keerl
    on May 10, 2020
    More actions

    Hi @schnapzz, I've been having the exact issue as you. I don't know why other people aren't having this issue as well because it seems like a huge impediment if you cannot check text values on iOS. Have you happen to find any work-arounds since your most recent update by chance?

  4. schnapzz commented on May 11, 2020

    @schnapzz
    schnapzz
    on May 11, 2020
    Author
    More actions

    Hi @keerl,
    Sad to hear we're in the same boat and no I have not. Since my latest post our testing have gone fairly stale and time haven't been allocated to research this further. If you by chance succeed in solving the problem I'll be more than pleased to hear the solution!

  5. keerl commented on May 11, 2020

    @keerl
    keerl
    on May 11, 2020
    More actions

    Apparently this is a known problem, but there hasn't been anything that I know of to fix it. https://stackoverflow.com/questions/54797434/nativescript-dev-appium-uielement-text-uielement-getattributevalue-ret

    I did find a work-around though. Anywhere I'm trying to read/check the text value of a label, I bind the automationText property to the exact same value as the text. I can then just search for the text I want using findElementByAutomationText() and that will give me the UIElement I want with that text if it exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.