2

Im having problem while testing that correct values are present inside data-table element. Im using Selenium2Library and Robot Framework 3.0 version.

Im using this code to check the values inside element

: FOR    ${item}    IN    @{elements}       INFO        console=yes
\    Wait Until Keyword Succeeds    10    1    Element Should Be Visible    
//th[contains(text(),"${item}")]    Header not found: ${item}

@{elements} is just a list of column values. It find first two column values and the last value fine when there is no more than one space between the column value. Other column values has spaces and '-' marks. I tried copying the direct value from Developer Console but it didn't help.

Element structure is:

<table class="data-table">
<thead><tr class="odd"><th class="top-left" id="col1">Number-one</th> 
<th id="col2">Second-number-column</th>
<th id="col3">Temporary number y-identification</th>
<th id="col4">Temporary numbertwo identification</th>
<th id="col5">Temporary numberthree identification</th>
<th class="top-right" id="col5">Number four</th>
</tr>
</thead>
</table>

Cant put the real column data there but its constructed like that. Problematic values are:

<th id="col3">Temporary number y-identification</th>
<th id="col4">Temporary numbertwo identification</th>
<th id="col5">Temporary numberthree identification</th>
  • 1
    Can you provide the @{elements} values and perhaps a working example html so that it can be reproduced? – A. Kootstra Nov 01 '18 at 13:42
  • Updated the html and added @{elements} – Joonas Venäläinen Nov 02 '18 at 12:52
  • Can you provide the code for creating `@{elements}`. It would make sense if that is not correct. Also be aware that 2+ spaces has a special meaning in Robot. – A. Kootstra Nov 02 '18 at 13:41
  • Yes, i know it has different meaning. @{elements} just contains data-table th column element texts separated +2 spaces. Logic works because its finds the two first columns from @{elements} list but stops when Temporary number y-identification comes. I copied the th values straight from the source code. Also tried with different spaces but no luck. – Joonas Venäläinen Nov 03 '18 at 17:45

1 Answers1

1

Try normalizing by space in xpath,

: FOR    ${item}    IN    @{elements}       INFO        console=yes
\    Wait Until Keyword Succeeds    10    1    Element Should Be Visible    
//th[contains(normalize-space(text()),"${item}")]    Header not found: ${item}
Navarasu
  • 8,209
  • 2
  • 21
  • 32