froth-webdriverio-framework 2.0.5 → 2.0.6
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 +12 -27
- package/package.json +1 -1
|
@@ -1,35 +1,20 @@
|
|
|
1
1
|
// Function to verify text in Android app
|
|
2
|
-
const assert = require('assert');
|
|
3
2
|
|
|
4
3
|
async function assertText(driver, elementSelector, expectedText) {
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
|
|
5
|
+
// Wait for the element to be visible
|
|
6
|
+
await driver.waitUntil(async () => {
|
|
7
|
+
const element = await driver.$(elementSelector);
|
|
8
|
+
// return await element.isDisplayed();
|
|
9
|
+
}, { timeout: 30000 });
|
|
11
10
|
|
|
12
11
|
// Get the actual text from the element
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
await expect(elementSelector).toHaveText(expectedText)
|
|
20
|
-
|
|
21
|
-
// assert.strictEqual(actualText, expectedText, `Expected title to be "${expectedText}", but found "${actualText}"`);
|
|
22
|
-
|
|
23
|
-
// // Compare the actual text with the expected text
|
|
24
|
-
// if (actualText === expectedText) {
|
|
25
|
-
// console.log('Text verification passed. Actual text:', actualText, 'Expected text:', expectedText);
|
|
26
|
-
// return true;
|
|
27
|
-
// } else {
|
|
28
|
-
// console.warn('Text verification failed. Actual text:', actualText, 'Expected text:', expectedText);
|
|
29
|
-
// }
|
|
30
|
-
// } catch (error) {
|
|
31
|
-
// console.error('Error occurred while verifying text:', error);
|
|
32
|
-
// }
|
|
12
|
+
const actualText = await element.getText();
|
|
13
|
+
|
|
14
|
+
console.log('Actual text:', actualText, 'Expected text:', expectedText);
|
|
15
|
+
|
|
16
|
+
await expect(actualText).toBe(expectedText, `Expected text to be "${expectedText}", but found "${actualText}"`);
|
|
17
|
+
|
|
33
18
|
}
|
|
34
19
|
|
|
35
20
|
module.exports = assertText;
|