support engine names
This commit is contained in:
parent
5a162c5840
commit
2abcdbe67d
|
|
@ -197,13 +197,25 @@ function innerAsLocators(factory: LocatorFactory, parsed: ParsedSelector, isFram
|
|||
const locatorParts = [locatorPart, locatorPartWithEngine].filter(Boolean) as string[];
|
||||
|
||||
if (nextPart && nextPart.name === 'internal:control' && (nextPart.body as string) === 'enter-frame') {
|
||||
// Two options:
|
||||
// two options plus engine name:
|
||||
// - locator('iframe').contentFrame()
|
||||
// - locator('css|xpath=iframe').contentFrame()
|
||||
// - frameLocator('iframe')
|
||||
tokens.push([
|
||||
...locatorParts.map(p => factory.chainLocators([p, factory.generateLocator(base, 'frame', '')])),
|
||||
// - frameLocator('css|xpath=iframe')
|
||||
|
||||
const contentFrame = factory.generateLocator(base, 'frame', '')
|
||||
const options = [
|
||||
factory.chainLocators([locatorPart, contentFrame]),
|
||||
factory.generateLocator(base, 'frame-locator', selectorPart),
|
||||
]);
|
||||
]
|
||||
|
||||
if (locatorPartWithEngine)
|
||||
options.push(
|
||||
factory.chainLocators([locatorPartWithEngine, contentFrame]),
|
||||
factory.generateLocator(base, 'frame-locator', stringifySelector({ parts: [part] }, /* forceEngineName */ true)),
|
||||
)
|
||||
|
||||
tokens.push(options);
|
||||
nextBase = 'frame-locator';
|
||||
index++;
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -588,7 +588,9 @@ it('parse locators strictly', () => {
|
|||
it('parseLocator frames', async () => {
|
||||
expect.soft(parseLocator('javascript', `locator('iframe').contentFrame().getByText('foo')`, '')).toBe(`iframe >> internal:control=enter-frame >> internal:text=\"foo\"i`);
|
||||
expect.soft(parseLocator('javascript', `frameLocator('iframe').getByText('foo')`, '')).toBe(`iframe >> internal:control=enter-frame >> internal:text=\"foo\"i`);
|
||||
expect.soft(parseLocator('javascript', `frameLocator('css=iframe').getByText('foo')`, '')).toBe(`css=iframe >> internal:control=enter-frame >> internal:text=\"foo\"i`);
|
||||
|
||||
expect.soft(parseLocator('python', `locator("iframe").content_frame.get_by_text("foo")`, '')).toBe(`iframe >> internal:control=enter-frame >> internal:text=\"foo\"i`);
|
||||
expect.soft(parseLocator('python', `frame_locator("iframe").get_by_text("foo")`, '')).toBe(`iframe >> internal:control=enter-frame >> internal:text=\"foo\"i`);
|
||||
expect.soft(parseLocator('python', `frame_locator("css=iframe").get_by_text("foo")`, '')).toBe(`css=iframe >> internal:control=enter-frame >> internal:text=\"foo\"i`);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue