setText object which looks at parent and child


Is there someone that can help me with an issue I am having. I’ve tried to look around on the internet but as someone who lacks a lot of html experience and knowledge, I’m not able to get it fixed.

So what I want is the following. I want to create an object which looks at the parent column and does a setText into the child.
Meaning: I want to fill in the text in the text field, based on the “title” of the text field on the left (see screenshot).

The title on the left I can define as: text equals Achternaam (zonder diakriet)
And the setText I can define as: ID contains operator_alphanumeriek::content

But when I set the object like this… It doesnt work.

Could someone help me with this?

<tr class="xta" style="outline-style:none;" id="pt:dyntdc:r1:1:pt:r0:0:z_sf:t1:0:t2:1:fRow"><td class="x15 x4z" style="text-align:left"><label class="af_panelLabelAndMessage_label-text">Achternaam (zonder diakriet)</label></td><td class="xvo xtk" valign="top"><table summary="" role="presentation" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td><table summary="" role="presentation" id="pt:dyntdc:r1:1:pt:r0:0:z_sf:t1:0:t2:1:pgl_alphanumeriek" class="x1a" style="outline-style:none" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="100%"></td><td><span id="pt:dyntdc:r1:1:pt:r0:0:z_sf:t1:0:t2:1:operator_alphanumeriek" class="x1z"><select id="pt:dyntdc:r1:1:pt:r0:0:z_sf:t1:0:t2:1:operator_alphanumeriek::content" name="pt:dyntdc:r1:1:pt:r0:0:z_sf:t1:0:t2:1:operator_alphanumeriek" style="width:100px;" class="x2h" title="="><option value="0" selected="" title="=">=</option><option value="1" title="<>">&lt;&gt;</option><option value="3" title="is leeg">is leeg</option><option value="4" title="is niet leeg">is niet leeg</option></select></span></td><td><span id="pt:dyntdc:r1:1:pt:r0:0:z_sf:t1:0:t2:1:input_alphanumeriek" class="x1u"><input id="pt:dyntdc:r1:1:pt:r0:0:z_sf:t1:0:t2:1:input_alphanumeriek::content" name="pt:dyntdc:r1:1:pt:r0:0:z_sf:t1:0:t2:1:input_alphanumeriek" style="width:207px" class="x25" maxlength="100" type="text" value=""></span></td></tr></tbody></table></td><td class="xvq"><table summary="" role="presentation" id="pt:dyntdc:r1:1:pt:r0:0:z_sf:t1:0:t2:1:j_id__ctru127pc7" class="x1a" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td><div id="pt:dyntdc:r1:1:pt:r0:0:z_sf:t1:0:t2:1:delrl" class="x24w xfl p_AFTextOnly" _afrgrp="0" role="presentation"><a href="#" onclick="this.focus();return false" data-afr-fcs="true" class="xfn" role="button"></a></div></td></tr></tbody></table></td></tr></tbody></table></td></tr>

Your HTML has the following fragment:

<option value="1" title="<>">&lt;&gt;</option>

This fragment is illegal. This is not a well-formed HTML. Most software can not parse the text as HTML. I am not surprised if KS fails to do setText on this web page. Your HTML should be corrected before testing with KS.

The fragment should rather be:

<option value="1" title="&lt;&gt;">&lt;&gt;</option>

How did I find the error? I copied and pasted the given HTML fragment into Emacs editor and applied nXML. Then nXML gave a error message: <> should not be there in attribute value.

Unless you have knowledge that the OP is dealing with an XML document (possibly XHTML) then that is not true.

Really? I did not know it.

How can I include a double quotation character in an Attribute value?

Can I write

<span id=""">foo</span>

Surely not. Should rather write

<span id="&quot;">foo</span>
<span attr='"'>foo</span>

There are of course special cases due to the per-ordained use and purpose of some attributes (id and class being good examples). But even then, HTML5 (and the living standard that followed) relaxed those to a greater extent than previous versions.

Aha, yes.

By the way, I am working on the original question from paulo. Wait for a while …

I could solve it. See the video, this shows how my experimental project works.


That looks nice! How is your object define? I would love to try your solution on the webpage from my work.

I have made a GitHub project:

The original question was

I want to fill in the text in the text field, based on the “title” of the text field on the left (see screenshot). The title on the left I can define as: text equals Achternaam (zonder diakriet)

You can try the demo by running “Test Suites/TS1”. My TS1 successfully inputs a text “As you like it” into the <input> element with a label Achternaam (zonder diakriet) . You can see the video which shows how the “TS1” runs.

The key solution was an XPath like this:

//td[contains(normalize-space(),'Achternaam (zonder diakriet)')]/following-sibling::td[1]/table/tbody/tr/td/table/tbody/tr[1]/td[3]/span/input

Do you understand this? Well, I would admit to say it is very complicated. However, I could not make it shorter, easier because the target HTML structure is compilcated. The complicated HTML requires complicated XPath to search contents inside. You can not reduce the complexity of the AUT.

I think I understand the XPath.
It first looks for the TD which contains the specific name. Then it follows up the sibling(child) which then tells which part in the table it looks for (which is where you will set the Text).

Im going to try this out tomorrow morning. I will let you know. Thanks :slight_smile:

I tested it and it works. Thanks a lot !