0

How do I make the elemts in HTML have my Id for use by GEB testing?

asked 2015-10-28 01:31:50 +0800

Danny4Impact gravatar image Danny4Impact
1

For enterprise testing I need to write GEB tests on pages produced by ZK. The most important feature for this is to target elements in the html page by their id, so that the test does not need to know about the page structure, just the items it expects to find on the page.

However ZK uses the id for its own internal requirements and the actual value is not fixed. I have tried adding my own attributes to things so I can target those but I get errors.

For example

<radio id="myRadioButton" label ="myLabel" radiogroup="myRadioGroup" myIDAttribute="xyz" />

error org.zkoss.zk.ui.metainfo.PropertyNotFoundException: Method myIDAttribute not found for class org.zkoss.zul.Radio

delete flag offensive retag edit

Comments

I have tried to provide an answer for my own question but it wont let me or explain why. There are not enough characters in comments to demonstrate the answer. Quick version: put xmlns:h="native" in your window tag. Surround elements you want to target with <h:span id="my id">. Find child of span.

Danny4Impact ( 2015-10-29 05:19:55 +0800 )edit

Ah, it says I can post an answer in 20 hours :( Stand by.

Danny4Impact ( 2015-10-29 05:25:42 +0800 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-10-30 03:30:56 +0800

Danny4Impact gravatar image Danny4Impact
1

The best way forward is to surround an element with an xhtml span and give that span an actual id. You can then navigate to the span by id and find the target inside the span. To do this you need to tell the ZUL page to use an xhtml namespace and then tag the span as belonging to that namespace.

First the window tag needs an xmlns attribute targeting the xhtml native namespace:

<window
    id="registrationInboxWindow"
    title="@load(e.windowTitleText)"
    width="100%" height = "100%" border="normal" contentStyle="overflow:auto;"
    style="font-size:24px;background-color:#d9e5ef;"
    apply="org.zkoss.bind.BindComposer"
    viewModel="@id('e') @init('aController')" 
    mode="overlapped" position="center,top"
    xmlns:h="native">

Then you put a native span tag around the target:

<h:span id="trax1">
   <radio id="cosRadioButton" label ="Conditions of Service" 
      radiogroup="travelReasonsRadioGroup" style="color:darkblue"></radio>
</span>

This will produce html that looks like this:

<span id="trax1">
  <span class="z-radio" id="e8tRl0" style="color: darkblue;">
    <input name="_pgdqdtsp" id="e8tRl0-real" type="radio">
    <label class="z-radio-content" id="e8tRl0-cnt" style="color: darkblue;" for="e8tRl0-real">
        Conditions of Service
    </label>
  </span>
</span>

And so GEB can now rapidly find the precise element thus:

conditionsOfServiceRadioButton   { $('#trax1').find('input') }
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

Follow
1 follower

RSS

Stats

Asked: 2015-10-28 01:31:50 +0800

Seen: 28 times

Last updated: Oct 30 '15

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