Skip to content

Commit ecd5497

Browse files
authored
Merge pull request #15 from PimySoft/fix-browserstack-workflow-issues
Fix BrowserStack interactions: Use touch actions for clicks
2 parents 614ab37 + 74b2bae commit ecd5497

1 file changed

Lines changed: 35 additions & 1 deletion

File tree

e2e/pages/BasePage.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,34 @@ export class BasePage {
2626

2727
async click(element: WebdriverIOElement, timeout: number = 10000): Promise<void> {
2828
await element.waitForDisplayed({ timeout });
29-
await element.click();
29+
30+
// Dismiss language modal if present (can block interactions on BrowserStack)
31+
await this.dismissLanguageModal();
32+
33+
// Use touch actions directly for BrowserStack compatibility
34+
// BrowserStack sometimes doesn't register regular clicks on real devices
35+
const location = await element.getLocation();
36+
const size = await element.getSize();
37+
const x = location.x + (size.width / 2);
38+
const y = location.y + (size.height / 2);
39+
40+
await this.driver.performActions([
41+
{
42+
type: 'pointer',
43+
id: 'finger1',
44+
parameters: { pointerType: 'touch' },
45+
actions: [
46+
{ type: 'pointerMove', duration: 0, x: Math.round(x), y: Math.round(y) },
47+
{ type: 'pointerDown', button: 0 },
48+
{ type: 'pause', duration: 150 },
49+
{ type: 'pointerUp', button: 0 },
50+
],
51+
},
52+
]);
53+
await this.driver.releaseActions();
54+
55+
// Small pause after click to let UI respond
56+
await this.driver.pause(300);
3057
}
3158

3259
async isDisplayed(element: WebdriverIOElement): Promise<boolean> {
@@ -78,10 +105,14 @@ export class BasePage {
78105
await this.dismissExternalApps();
79106

80107
if (await this.isOnHomePage()) {
108+
await this.dismissLanguageModal();
81109
return;
82110
}
83111

84112
await this.driver.activateApp(APP_PACKAGE_NAME);
113+
114+
// Dismiss language modal that may appear on fresh installs (BrowserStack)
115+
await this.dismissLanguageModal();
85116

86117
const homePageLoaded = await this.isOnHomePage();
87118
if (homePageLoaded) {
@@ -90,6 +121,9 @@ export class BasePage {
90121

91122
await this.driver.pressKeyCode(4);
92123

124+
// Dismiss language modal again after navigation
125+
await this.dismissLanguageModal();
126+
93127
// Excessive timeout to ensure home page is loaded. Team will need to improve performance.
94128
await this.homeButton.waitForDisplayed({ timeout: 40000 });
95129
}

0 commit comments

Comments
 (0)