Static Id generator is not generating same id at any time for few components.

asked 2017-12-18 18:20:27 +0800

newuser gravatar image newuser
101 1

updated 2017-12-20 17:26:18 +0800

Hi, I am testing Idempiere application(version with some testing tool, for this, I need permanent id for every component.

So I have added below line in zk.xml file for getting static ids.

<system-config> <id-generator-class>org.zkoss.zk.ui.impl.StaticIdGenerator</id-generator-class> </system-config>

After adding this, am able to get the same id for text fields on the login page.

Ex: For username field, id is: z_v (it is being same always). FYR: image description

Now my issue is for menu link, i see everytime id is changing.

First time i got id is :z_40


image description second time id is :z_u0


image description

If it is behaving differently at different times, so my testing will get failed. As of now we found for menu buttons and date cells on calender. Could any one please help me on this.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-12-20 18:35:43 +0800

cor3000 gravatar image cor3000
4293 1 7
ZK Team

The StaticIdGenerator cannot guarantee that a component will always get the same fixed id. What it does: it generates IDs in a static predictable sequence. As long as components are created in exactly the same order they will receive the same IDs from the generator. Which is likely the case for a login page.

If components get detached and re-created the sequence will continue giving those components new IDs. Another factor could be UUID recycling which should be disabled.

The more dynamic you UI is the more new/changed IDs you'll find.

Depending on the test tool there are often alternative ways to select an element. E.g. by xpath or css selector.

If you are using a test tool like selenium you have access to the JS runtime where you can select widgets using ZK's extended jquery selectors.

Assume the following zul code (containing component IDs, which are different from the generated UUIDs in the resulting DOM elements).

<hlayout id="topNav">
  <button id="menuButton" label="button"/>

You can still find those components by ID using jquery and the $ prefix to select by component ID (also check the related documentation):

jq('$topNav $menuButton')[0]

So maybe it's just the UUID recycling interfering or you need an alternative selection approach. BTW which test framework are you using?


link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2017-12-18 18:20:27 +0800

Seen: 21 times

Last updated: Dec 20 '17

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More