Skip to content

Commit 5bda7fc

Browse files
committed
Merge branch '3.x' of github.com:codeceptjs/CodeceptJS into 3.x
2 parents cd0a963 + ba35847 commit 5bda7fc

File tree

4 files changed

+57
-3
lines changed

4 files changed

+57
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 3.1.1
2+
3+
* [Appium] Fixed #2759
4+
`grabNumberOfVisibleElements`, `grabAttributeFrom`, `grabAttributeFromAll` to allow id locators.
5+
16
## 3.1.0
27

38
* [Plawyright] Updated to Playwright 1.13

lib/helper/Appium.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,6 +1352,33 @@ class Appium extends Webdriver {
13521352
return super.grabTextFrom(parseLocator.call(this, locator));
13531353
}
13541354

1355+
/**
1356+
* {{> grabNumberOfVisibleElements }}
1357+
*/
1358+
async grabNumberOfVisibleElements(locator) {
1359+
if (this.isWeb) return super.grabNumberOfVisibleElements(locator);
1360+
return super.grabNumberOfVisibleElements(parseLocator.call(this, locator));
1361+
}
1362+
1363+
/**
1364+
* Can be used for apps only with several values ("contentDescription", "text", "className", "resourceId")
1365+
*
1366+
* {{> grabAttributeFrom }}
1367+
*/
1368+
async grabAttributeFrom(locator, attr) {
1369+
if (this.isWeb) return super.grabAttributeFrom(locator, attr);
1370+
return super.grabAttributeFrom(parseLocator.call(this, locator), attr);
1371+
}
1372+
1373+
/**
1374+
* Can be used for apps only with several values ("contentDescription", "text", "className", "resourceId")
1375+
* {{> grabAttributeFromAll }}
1376+
*/
1377+
async grabAttributeFromAll(locator, attr) {
1378+
if (this.isWeb) return super.grabAttributeFromAll(locator, attr);
1379+
return super.grabAttributeFromAll(parseLocator.call(this, locator), attr);
1380+
}
1381+
13551382
/**
13561383
* {{> grabValueFromAll }}
13571384
*

lib/helper/WebDriver.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,6 @@ class WebDriver extends Helper {
12521252

12531253
/**
12541254
* {{> grabAttributeFromAll }}
1255-
* Appium: can be used for apps only with several values ("contentDescription", "text", "className", "resourceId")
12561255
*/
12571256
async grabAttributeFromAll(locator, attr) {
12581257
const res = await this._locate(locator, true);
@@ -1263,7 +1262,6 @@ class WebDriver extends Helper {
12631262

12641263
/**
12651264
* {{> grabAttributeFrom }}
1266-
* Appium: can be used for apps only with several values ("contentDescription", "text", "className", "resourceId")
12671265
*/
12681266
async grabAttributeFrom(locator, attr) {
12691267
const attrs = await this.grabAttributeFromAll(locator, attr);

test/helper/Appium_test.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ describe('Appium', function () {
573573
});
574574
});
575575

576-
describe('#grabTextFrom, #grabValueFrom, #grabAttributeFrom', () => {
576+
describe('#grabTextFrom, #grabValueFrom, #grabAttributeFrom @quick', () => {
577577
it('should grab text from page', async () => {
578578
const val = await app.grabTextFrom('~buttonTestCD');
579579
assert.equal(val, 'EN Button');
@@ -583,6 +583,30 @@ describe('Appium', function () {
583583
const val = await app.grabAttributeFrom('~buttonTestCD', 'resourceId');
584584
assert.equal(val, 'io.selendroid.testapp:id/buttonTest');
585585
});
586+
587+
it('should be able to grab elements', async () => {
588+
await app.click('~startUserRegistrationCD');
589+
await app.click('~email of the customer');
590+
await app.appendField('~email of the customer', '1');
591+
await app.hideDeviceKeyboard('pressKey', 'Done');
592+
await app.swipeTo(
593+
'//android.widget.Button', '//android.widget.ScrollView/android.widget.LinearLayout', 'up', 30,
594+
100, 700,
595+
);
596+
await app.click('//android.widget.Button');
597+
await app.see(
598+
'1',
599+
'#io.selendroid.testapp:id/label_email_data',
600+
);
601+
const num = await app.grabNumberOfVisibleElements('#io.selendroid.testapp:id/label_email_data');
602+
assert.strictEqual(1, num);
603+
604+
const id = await app.grabNumberOfVisibleElements(
605+
'//android.widget.TextView[@resource-id="io.selendroid.testapp:id/label_email_data"]',
606+
'contentDescription',
607+
);
608+
assert.strictEqual(1, id);
609+
});
586610
});
587611

588612
describe('#saveScreenshot @quick', () => {

0 commit comments

Comments
 (0)