-
-
Notifications
You must be signed in to change notification settings - Fork 747
-
I have a table with following structure and I want to get text inside "p" tag. Text can be empty. In such cases I.grabTextFrom() fails with ElementNotFound exception. I was expecting it to return "" (empty string). Even the try catch block won't catch this exception. Any workaround for this issue?
Sample HTML
<tr>
<td><p>Field1</p></td>
<td><p></p>sometext</td>
</tr>
<tr>
<td><p>Field2</p></td>
<td><p></p></td>
</tr>
Code to grabtext
let element = { xpath: `//p[text()='${fieldName}']/following::p` };
try {
// I see element passes fine
I.seeElement(element);
return await I.grabTextFrom(element);
} catch (error) {
return "";
}
Error
Element "xpath=//p[text()='Field2']/following::p" was not found by text|CSS|XPath
at new ElementNotFound (node_modules/codeceptjs/lib/helper/errors/ElementNotFound.js:15:11)
at assertElementExists (node_modules/codeceptjs/lib/helper/Playwright.js:3742:11)
at Playwright.grabTextFrom (node_modules/codeceptjs/lib/helper/Playwright.js:2089:5)
Codeceptjs: 3.6.5
Browser: chromium
Helper: Playwright
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment