I am currently working on verifying the contents of a complex TD cell, which includes a SPAN tag and multiple BR tags. My testing is limited to using Selenium IDE for this task. The HTML source code in question looks like this:
<td>
<span><b style="whatever">TEXT_1</b></span>
<br style="whatever">
TEXT_2
<br style="whatever">
TEXT_3
<br>
</td>
It's important to note that TEXT_1, TEXT_2, and TEXT_3 do not contain any spaces.
To tackle this, I retrieve the TD cell contents into a variable named 'td_cell_contents'. Then, I use Javascript to split this variable based on a single space:
store | javascript{storedVars['td_cell_contents'].split(' ')[0]} | var_1
store | javascript{storedVars['td_cell_contents'].split(' ')[1]} | var_2
As expected, var_1 correctly evaluates to "TEXT_1" due to the presence of a space separating it from the rest of the cell. However, when I check var_2, the log output displays a new line between "TEXT_2" and "TEXT_3" because of the BR tag used:
[info] echo: var_2: TEXT 2
TEXT 3
Attempting to remove these new lines using JavaScript did not yield the desired result:
runScript | var_2 = var_2.replace(/(?:\r\n|\r|\n)/g, '<br />'); |
Subsequent echoes of var_2 still show the presence of the unwanted newline, hindering string matching capability.
I am seeking assistance and exploring alternative methods within Selenium IDE to verify the cell contents effectively, even if the newlines cannot be removed.