Skip to content

Commit aa41e81

Browse files
DavertMikclaude
andcommitted
fix: resolve merge conflicts with 4.x and use WithinContext.endCurrent() in switchTo
Resolve merge conflicts in attachFile for Playwright/Puppeteer (keep 4.x drag-and-drop file upload logic) and webapi tests (keep new context tests). Address review feedback: replace manual withinLocator check + _withinEnd() with WithinContext.endCurrent() in switchTo() for all three helpers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2 parents 7cb9681 + 1501b70 commit aa41e81

34 files changed

+906
-381
lines changed

.github/workflows/publish-beta.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ jobs:
2323
node-version: 22
2424
registry-url: 'https://registry.npmjs.org'
2525

26+
- run: npm install
2627
- run: npm install -g npm@latest
2728

28-
- run: npm ci
29-
3029
- name: Set package version
3130
run: |
3231
TAG="${{ github.event.release.tag_name }}"

docs/helpers/Appium.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,16 +872,21 @@ Returns **[Promise][6]\<void>** Appium: support both Android and iOS
872872
Appends text to a input field or textarea.
873873
Field is located by name, label, CSS or XPath
874874

875+
The third parameter is an optional context (CSS or XPath locator) to narrow the search.
876+
875877
```js
876878
I.appendField('#myTextField', 'appended');
877879
// typing secret
878880
I.appendField('password', secret('123456'));
881+
// within a context
882+
I.appendField('name', 'John', '.form-container');
879883
```
880884

881885
#### Parameters
882886

883887
* `field` **([string][5] | [object][11])** located by label|name|CSS|XPath|strict locator
884888
* `value` **[string][5]** text value to append.
889+
* `context` **([string][5]? | [object][11])** (optional, `null` by default) element located by CSS | XPath | strict locator. (optional, default `null`)
885890

886891
Returns **void** automatically synchronized promise through #recorder
887892

@@ -890,7 +895,7 @@ Returns **void** automatically synchronized promise through #recorder
890895
Selects a checkbox or radio button.
891896
Element is located by label or name or CSS or XPath.
892897

893-
The second parameter is a context (CSS or XPath locator) to narrow the search.
898+
The second parameter is an optional context (CSS or XPath locator) to narrow the search.
894899

895900
```js
896901
I.checkOption('#agree');
@@ -979,15 +984,20 @@ Returns **void** automatically synchronized promise through #recorder
979984
Checks that value of input field or textarea doesn't equal to given value
980985
Opposite to `seeInField`.
981986

987+
The third parameter is an optional context (CSS or XPath locator) to narrow the search.
988+
982989
```js
983990
I.dontSeeInField('email', 'user@user.com'); // field by name
984991
I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
992+
// within a context
993+
I.dontSeeInField('Name', 'old_value', '.form-container');
985994
```
986995

987996
#### Parameters
988997

989998
* `field` **([string][5] | [object][11])** located by label|name|CSS|XPath|strict locator.
990999
* `value` **([string][5] | [object][11])** value to check.
1000+
* `context` **([string][5]? | [object][11])** (optional, `null` by default) element located by CSS | XPath | strict locator. (optional, default `null`)
9911001

9921002
Returns **void** automatically synchronized promise through #recorder
9931003

@@ -1013,7 +1023,7 @@ Returns **void** automatically synchronized promise through #recorder
10131023
Fills a text field or textarea, after clearing its value, with the given string.
10141024
Field is located by name, label, CSS, or XPath.
10151025

1016-
The third parameter is a context (CSS or XPath locator) to narrow the search.
1026+
The third parameter is an optional context (CSS or XPath locator) to narrow the search.
10171027

10181028
```js
10191029
// by label
@@ -1222,17 +1232,22 @@ Returns **void** automatically synchronized promise through #recorder
12221232
Checks that the given input field or textarea equals to given value.
12231233
For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
12241234

1235+
The third parameter is an optional context (CSS or XPath locator) to narrow the search.
1236+
12251237
```js
12261238
I.seeInField('Username', 'davert');
12271239
I.seeInField({css: 'form textarea'},'Type your comment here');
12281240
I.seeInField('form input[type=hidden]','hidden_value');
12291241
I.seeInField('#searchform input','Search');
1242+
// within a context
1243+
I.seeInField('Name', 'John', '.form-container');
12301244
```
12311245

12321246
#### Parameters
12331247

12341248
* `field` **([string][5] | [object][11])** located by label|name|CSS|XPath|strict locator.
12351249
* `value` **([string][5] | [object][11])** value to check.
1250+
* `context` **([string][5]? | [object][11])** (optional, `null` by default) element located by CSS | XPath | strict locator. (optional, default `null`)
12361251

12371252
Returns **void** automatically synchronized promise through #recorder
12381253

@@ -1260,7 +1275,7 @@ Selects an option in a drop-down select.
12601275
Field is searched by label | name | CSS | XPath.
12611276
Option is selected by visible text or by value.
12621277

1263-
The third parameter is a context (CSS or XPath locator) to narrow the search.
1278+
The third parameter is an optional context (CSS or XPath locator) to narrow the search.
12641279

12651280
```js
12661281
I.selectOption('Choose Plan', 'Monthly'); // select by label

docs/helpers/Playwright.md

Lines changed: 206 additions & 177 deletions
Large diffs are not rendered by default.

docs/helpers/Puppeteer.md

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -357,16 +357,21 @@ Returns **void** automatically synchronized promise through #recorder
357357
Appends text to a input field or textarea.
358358
Field is located by name, label, CSS or XPath
359359

360+
The third parameter is an optional context (CSS or XPath locator) to narrow the search.
361+
360362
```js
361363
I.appendField('#myTextField', 'appended');
362364
// typing secret
363365
I.appendField('password', secret('123456'));
366+
// within a context
367+
I.appendField('name', 'John', '.form-container');
364368
```
365369

366370
#### Parameters
367371

368372
* `field` **([string][6] | [object][4])** located by label|name|CSS|XPath|strict locator
369373
* `value` **[string][6]** text value to append.
374+
* `context` **([string][6]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
370375

371376
Returns **void** automatically synchronized promise through #recorder
372377

@@ -382,15 +387,27 @@ Attaches a file to element located by label, name, CSS or XPath
382387
Path to file is relative current codecept directory (where codecept.conf.ts or codecept.conf.js is located).
383388
File will be uploaded to remote system (if tests are running remotely).
384389

390+
The third parameter is an optional context (CSS or XPath locator) to narrow the search.
391+
385392
```js
386393
I.attachFile('Avatar', 'data/avatar.jpg');
387394
I.attachFile('form input[name=avatar]', 'data/avatar.jpg');
395+
// within a context
396+
I.attachFile('Avatar', 'data/avatar.jpg', '.form-container');
397+
```
398+
399+
If the locator points to a non-file-input element (e.g., a dropzone area),
400+
the file will be dropped onto that element using drag-and-drop events.
401+
402+
```js
403+
I.attachFile('#dropzone', 'data/avatar.jpg');
388404
```
389405

390406
#### Parameters
391407

392408
* `locator` **([string][6] | [object][4])** field located by label|name|CSS|XPath|strict locator.
393409
* `pathToFile` **[string][6]** local file path relative to codecept.conf.ts or codecept.conf.js config file.
410+
* `context` **([string][6]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
394411

395412
Returns **void** automatically synchronized promise through #recorder
396413

@@ -428,7 +445,7 @@ Dismisses the active JavaScript popup, as created by window.alert|window.confirm
428445
Selects a checkbox or radio button.
429446
Element is located by label or name or CSS or XPath.
430447

431-
The second parameter is a context (CSS or XPath locator) to narrow the search.
448+
The second parameter is an optional context (CSS or XPath locator) to narrow the search.
432449

433450
```js
434451
I.checkOption('#agree');
@@ -462,15 +479,20 @@ I.clearCookie('test');
462479

463480
Clears a `<textarea>` or text `<input>` element's value.
464481

482+
The second parameter is an optional context (CSS or XPath locator) to narrow the search.
483+
465484
```js
466485
I.clearField('Email');
467486
I.clearField('user[email]');
468487
I.clearField('#email');
488+
// within a context
489+
I.clearField('Email', '.form-container');
469490
```
470491

471492
#### Parameters
472493

473494
* `field` &#x20;
495+
* `context` **([string][6]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
474496
* `editable` **([string][6] | [object][4])** field located by label|name|CSS|XPath|strict locator.
475497

476498
Returns **void** automatically synchronized promise through #recorder.
@@ -705,15 +727,20 @@ Returns **void** automatically synchronized promise through #recorder
705727
Checks that value of input field or textarea doesn't equal to given value
706728
Opposite to `seeInField`.
707729

730+
The third parameter is an optional context (CSS or XPath locator) to narrow the search.
731+
708732
```js
709733
I.dontSeeInField('email', 'user@user.com'); // field by name
710734
I.dontSeeInField({ css: 'form input.email' }, 'user@user.com'); // field by CSS
735+
// within a context
736+
I.dontSeeInField('Name', 'old_value', '.form-container');
711737
```
712738

713739
#### Parameters
714740

715741
* `field` **([string][6] | [object][4])** located by label|name|CSS|XPath|strict locator.
716742
* `value` **([string][6] | [object][4])** value to check.
743+
* `context` **([string][6]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
717744

718745
Returns **void** automatically synchronized promise through #recorder
719746

@@ -907,7 +934,7 @@ Returns **[Promise][11]<any>** script return value
907934
Fills a text field or textarea, after clearing its value, with the given string.
908935
Field is located by name, label, CSS, or XPath.
909936
910-
The third parameter is a context (CSS or XPath locator) to narrow the search.
937+
The third parameter is an optional context (CSS or XPath locator) to narrow the search.
911938
912939
```js
913940
// by label
@@ -1445,15 +1472,19 @@ This method allows intercepting and mocking requests & responses. [Learn more ab
14451472
Moves cursor to element matched by locator.
14461473
Extra shift can be set with offsetX and offsetY options.
14471474
1475+
An optional `context` (as a second parameter) can be specified to narrow the search to an element within a parent.
1476+
When the second argument is a non-number (string or locator object), it is treated as context.
1477+
14481478
```js
14491479
I.moveCursorTo('.tooltip');
14501480
I.moveCursorTo('#submit', 5,5);
1481+
I.moveCursorTo('#submit', '.container');
14511482
```
14521483
14531484
#### Parameters
14541485
14551486
* `locator` **([string][6] | [object][4])** located by CSS|XPath|strict locator.
1456-
* `offsetX` **[number][10]** (optional, `0` by default) X-axis offset.
1487+
* `offsetX` **([number][10] | [string][6] | [object][4])** (optional, `0` by default) X-axis offset or context locator.
14571488
* `offsetY` **[number][10]** (optional, `0` by default) Y-axis offset.
14581489
14591490
Returns **void** automatically synchronized promise through #recorder
@@ -1877,17 +1908,22 @@ Returns **void** automatically synchronized promise through #recorder
18771908
Checks that the given input field or textarea equals to given value.
18781909
For fuzzy locators, fields are matched by label text, the "name" attribute, CSS, and XPath.
18791910
1911+
The third parameter is an optional context (CSS or XPath locator) to narrow the search.
1912+
18801913
```js
18811914
I.seeInField('Username', 'davert');
18821915
I.seeInField({css: 'form textarea'},'Type your comment here');
18831916
I.seeInField('form input[type=hidden]','hidden_value');
18841917
I.seeInField('#searchform input','Search');
1918+
// within a context
1919+
I.seeInField('Name', 'John', '.form-container');
18851920
```
18861921
18871922
#### Parameters
18881923
18891924
* `field` **([string][6] | [object][4])** located by label|name|CSS|XPath|strict locator.
18901925
* `value` **([string][6] | [object][4])** value to check.
1926+
* `context` **([string][6]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
18911927
18921928
Returns **void** automatically synchronized promise through #recorder
18931929
@@ -2052,7 +2088,7 @@ Selects an option in a drop-down select.
20522088
Field is searched by label | name | CSS | XPath.
20532089
Option is selected by visible text or by value.
20542090
2055-
The third parameter is a context (CSS or XPath locator) to narrow the search.
2091+
The third parameter is an optional context (CSS or XPath locator) to narrow the search.
20562092
20572093
```js
20582094
I.selectOption('Choose Plan', 'Monthly'); // select by label
@@ -2241,7 +2277,7 @@ Returns **void** automatically synchronized promise through #recorder
22412277
Unselects a checkbox or radio button.
22422278
Element is located by label or name or CSS or XPath.
22432279
2244-
The second parameter is a context (CSS or XPath locator) to narrow the search.
2280+
The second parameter is an optional context (CSS or XPath locator) to narrow the search.
22452281
22462282
```js
22472283
I.uncheckOption('#agree');

0 commit comments

Comments
 (0)