froth-webdriverio-framework 2.0.6 → 2.0.7

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.
@@ -2,19 +2,31 @@
2
2
 
3
3
  async function assertText(driver, elementSelector, expectedText) {
4
4
 
5
- // Wait for the element to be visible
6
- await driver.waitUntil(async () => {
5
+ try {
6
+ // Wait for the element to be visible
7
+ await driver.waitUntil(async () => {
8
+ const element = await driver.$(elementSelector);
9
+ return await element.isDisplayed();
10
+ }, { timeout: 30000 });
11
+
12
+ // Get the actual text from the element
7
13
  const element = await driver.$(elementSelector);
8
- // return await element.isDisplayed();
9
- }, { timeout: 30000 });
10
-
11
- // Get the actual text from the element
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
-
14
+ const actualText = await element.getText();
15
+
16
+ // Compare the actual text with the expected text
17
+ if (actualText === expectedText) {
18
+ console.log('Text verification passed. Actual text:', actualText, 'Expected text:', expectedText);
19
+ driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"Text verification passed. Actual text:'+actualText+'",Expected text:"'+expectedText+'","level": "info"}}');
20
+ return true;
21
+ } else {
22
+ driver.execute('browserstack_executor: {"action": "annotate", "arguments": {"data":"Text verification failed. Actual text:'+actualText+'",Expected text:"'+expectedText+'","level": "error"}}');
23
+ console.error('Text verification failed. Actual text:', actualText, 'Expected text:', expectedText);
24
+ throw error;
25
+ }
26
+ } catch (error) {
27
+ console.error('Error occurred while verifying text:', error);
28
+ throw error;
29
+ }
18
30
  }
19
31
 
20
32
  module.exports = assertText;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "froth-webdriverio-framework",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "readme": "WebdriverIO Integration",
5
5
  "description": "WebdriverIO and BrowserStack App Automate",
6
6
  "license": "MIT",