froth-webdriverio-framework 2.0.17 → 2.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commonMethods/assertText.js +11 -10
- package/package.json +1 -1
|
@@ -3,26 +3,27 @@
|
|
|
3
3
|
async function assertText(driver, elementSelector, expectedText) {
|
|
4
4
|
|
|
5
5
|
try {
|
|
6
|
-
console.log("inside the assert text function")
|
|
6
|
+
console.log("inside the assert text function" + elementSelector)
|
|
7
7
|
// Wait for the element to be visible
|
|
8
|
-
await driver.waitUntil(async () => {
|
|
9
|
-
const element = await driver.$(elementSelector);
|
|
10
|
-
return await element.isDisplayed();
|
|
11
|
-
}, { timeout: 30000 });
|
|
12
8
|
|
|
13
9
|
// Get the actual text from the element
|
|
14
10
|
const element = await driver.$(elementSelector);
|
|
11
|
+
console.log("actual text is:" + element)
|
|
15
12
|
const actualText = await element.getText();
|
|
13
|
+
console.log("actual text is:" + actualText)
|
|
14
|
+
|
|
16
15
|
|
|
17
16
|
// Compare the actual text with the expected text
|
|
18
17
|
if (actualText == expectedText) {
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
let annotationMessage = `Assertion pass. Actual text: ${actualText}, Expected text: ${expectedText}.`;
|
|
19
|
+
console.log(`Assertion pass. Actual text: ${actualText}, Expected text: ${expectedText}.`);
|
|
20
|
+
// await driver.execute(`browserstack_executor: {"action": "annotate", "arguments": {"data":"${annotationMessage}","level": "info"}}`);
|
|
21
21
|
return true;
|
|
22
22
|
} else {
|
|
23
|
-
|
|
24
|
-
console.
|
|
25
|
-
|
|
23
|
+
let annotationMessage = `Assertion fail. Actual text: ${actualText}, Expected text: ${expectedText}.`;
|
|
24
|
+
console.log(`Assertion fail. Actual text: ${actualText}, Expected text: ${expectedText}.`);
|
|
25
|
+
// await driver.execute(`browserstack_executor: {"action": "annotate", "arguments": {"data":"${annotationMessage}","level": "info"}}`);
|
|
26
|
+
throw new Error(`Assertion fail.`)
|
|
26
27
|
}
|
|
27
28
|
} catch (error) {
|
|
28
29
|
console.error('Error occurred while verifying text:', error);
|