diff --git a/test/selectors-css.spec.ts b/test/selectors-css.spec.ts
index fa2c2421b7f4a..a59752418779b 100644
--- a/test/selectors-css.spec.ts
+++ b/test/selectors-css.spec.ts
@@ -374,3 +374,17 @@ it('should work with :scope', async ({page, server}) => {
expect(await scope.$$eval(`css=* ~ :scope`, els => els.length)).toBe(0);
}
});
+
+it('css on the handle should be relative', async ({ page }) => {
+ await page.setContent(`
+ 1
+
+ 2
+
+ `);
+ expect(await page.$eval(`.find-me`, e => e.id)).toBe('target1');
+
+ const div = await page.$('div');
+ expect(await div.$eval(`.find-me`, e => e.id)).toBe('target2');
+ expect(await page.$eval(`div >> .find-me`, e => e.id)).toBe('target2');
+});
diff --git a/test/selectors-misc.spec.ts b/test/selectors-misc.spec.ts
index cf4dd48ac7fed..feaf41419c5e7 100644
--- a/test/selectors-misc.spec.ts
+++ b/test/selectors-misc.spec.ts
@@ -214,3 +214,17 @@ it('xpath should be relative', async ({ page }) => {
expect(await page.$eval(`div >> //*[@class="find-me"]`, e => e.id)).toBe('target2');
expect(await page.$eval(`div >> xpath=/*[@class="find-me"]`, e => e.id)).toBe('target2');
});
+
+it('data-testid on the handle should be relative', async ({ page }) => {
+ await page.setContent(`
+ 1
+
+ 2
+
+ `);
+ expect(await page.$eval(`data-testid=find-me`, e => e.id)).toBe('target1');
+
+ const div = await page.$('div');
+ expect(await div.$eval(`data-testid=find-me`, e => e.id)).toBe('target2');
+ expect(await page.$eval(`div >> data-testid=find-me`, e => e.id)).toBe('target2');
+});