how to keep a fixed id for an element in zkoss page?

asked 2016-07-27 07:50:25 +0800

charansai gravatar image charansai

i'm having hard time testing a web application. i use selenium ide to test my application and whenever the page gets refreshed or loaded again from home screen, id's of web page elements get changed. is there anyway to fix this? an error message keeps popping up when a test case is recorded and played back. For ex: [error] Element //input[@id='zkcomp1007'] not found.

delete flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted

answered 2016-07-28 04:05:22 +0800

JustinFrost gravatar image JustinFrost
139 1 6

Hi charansai,

The ids of components are generated each time the page loads - so you will never get the same ids for HTML tags in the dom, that is why selenium fails. You have three options:

  • Add attributes to your components that selenium can use to identify them. We use data-attributes, these will remain unique and consistent.
  • Use javascript to determine the uuid (dom id) of your element from the id you assign in ZK
  • Implement ID Generator

The last two of these are covered in this link: https://www.zkoss.org/wiki/ZKDeveloper'sReference/Testing/Testing_Tips

link publish delete flag offensive edit

answered 2016-07-31 09:17:02 +0800

Darksu gravatar image Darksu
1991 1 4


Also for more information please refer to the following documentation:


Best Regards,


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

1 follower



Asked: 2016-07-27 07:50:25 +0800

Seen: 45 times

Last updated: Jul 31 '16

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