I want to compare double-values (75.999) mixed with text: 75.999 & edit
I got this values from a table and tried to parse it to string, to replace all sign and characters except digits, but nothing worked.
HTML-SNIPET:
<td data-cy="project.chanceOrder" class="text-right editableRow" aria-label="project.chanceOrder: NCDd_3wB0UC4Ud30l6iP">
<div class="ng-star-inserted">
<span class="ng-star-inserted">75.999 % </span>
<!---->
<a class="inlineEditLink" title="Bearbeiten">
<em class="material-icons">edit</em>
</a>
</div>
<!---->
<!---->
</td>
Cypress-Code (NOT working):
cy.get('[data-cy="projectList"]')
.find('[data-cy="project.chanceOrder"]')
.each((MyElement, MyIndex, MyContentOfArray) => {
if(MyIndex == 0)
{
// NOT WORKING
expect(parseFloat(MyElement.text().replace(/[^a-zA-Z0-9 ]/g, ""))).to.equal(project.chanceOrder.replace(/[^a-zA-Z0-9 ]/g, ""))
// NOT WORKING
// let tmp = MyElement.text().replace(/[^a-zA-Z0-9 ]/g, "")
// let OriginValueToCompare = '' + project.chanceOrder
// let tmpStr = OriginValueToCompare.replace(/[^a-zA-Z0-9 ]/g, "")
// expect(tmp).to.equal(tmpStr)
// NOT WORKING
// expect(MyElement.text().replace(/[^a-zA-Z0-9 ]/g, "")).to.equal(project.chanceOrder.replace(/[^a-zA-Z0-9 ]/g, ""))
// NOT WORKING
expect(MyElement.text()).to.equal('' + project.chanceOrder+" % edit")
// NOT WORKING
let tmp1 = "" + MyElement.text()
let tmp2 = "" + project.chanceOrder +" % edit"
if(tmp1 == tmp2)
{
cy.log("=============== YES =====================================")
}
// NOT WORKING
cy.wrap(tmp1).should('eq', tmp2);
// NOT WORKING
cy.wrap(tmp1).should('have.text', tmp2);
})
ERROR-Message (ALWAYS):
expected 75.999 % edit to equal 75.999 % edit
If I compare the output from cypress Log with notepad++
75.999 % edit <-> 75.999 % edit
it always says, that the two files matches.
What am I doing wrong?
You can use this:
This will check that the string
75.999is present in your extracted text.