-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi, I am testing Idempiere application(version 8.0.1.1) 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:
Now my issue is for menu link, i see everytime id is changing.
First time i got id is :z_40
FYR:
second time id is :z_u0
FYR:
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.
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"/>
</hlayout>
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?
Robert
Asked: 2017-12-18 18:20:27 +0800
Seen: 28 times
Last updated: Dec 20 '17