Skip to content

Commit 4e4efb3

Browse files
committed
fix: preserve actor reference and custom PageObject methods
- Fixed actor to use existing instance when available - Added container.append() when actor reference changes - Ensures custom PageObject methods are properly added to actor
1 parent 1911ae6 commit 4e4efb3

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

lib/actor.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ export default function (obj = {}, container) {
7676
container = Container
7777
}
7878

79-
// Create a new Actor instance
80-
const actor = new Actor()
79+
// Get existing actor or create a new one
80+
const actor = container.actor() || new Actor()
8181

8282
// load all helpers once container initialized
8383
container.started(() => {
@@ -112,14 +112,17 @@ export default function (obj = {}, container) {
112112
}
113113
})
114114

115-
container.append({
116-
support: {
117-
I: actor,
118-
},
119-
})
115+
// Update container.support.I to ensure it has the latest actor reference
116+
if (!container.actor() || container.actor() !== actor) {
117+
container.append({
118+
support: {
119+
I: actor,
120+
},
121+
})
122+
}
120123
})
121-
// store.actor = actor;
122-
// add custom steps from actor
124+
125+
// add custom steps from actor immediately
123126
Object.keys(obj).forEach(key => {
124127
const ms = new MetaStep('I', key)
125128
ms.setContext(actor)

0 commit comments

Comments
 (0)