Currently experimenting with Playwright and encountering an issue.
I have a web form with 4 fields. When 2 of them are filled, a calculated value appears in the third one. I expected .soft to return the newly appeared value as a string: ""
Here is a snippet of the code I am working with:
await page.getByLabel('Buy up price').fill(buyUp); // fill Buy up price
await page.getByLabel('Percent of sale price').fill(percent); // fill Percent of sale price
if (percent != '') {
let salePrice = ((+buyUp) * (+percent)/100 + (+buyUp)).toFixed(8);
const predictPrice = page.locator('//*[@id="fvf_salePrice"]');
await expect.soft(predictPrice).toHaveText(salePrice, {timeout: 5000});
} else {
await page.getByLabel('Sale price', { exact: true }).fill(salePrice); // fill Sale price
}
While debugging, I can see that the value on selector //*[@id="fvf_salePrice"] exists, but the expect.soft part always fails with the following return values: expected string: salePrice received string: "". It seems like Playwright is capturing the placeholder where the value is displayed, but unable to extract the correct value. I have tried using various selectors (Xpath, CSS, etc.), implemented while loops to wait for data updates, but so far nothing has worked. The testing environment is set up on chromium.
Could this issue be related to dynamically changing data, or is there possibly something wrong in my code?