Skip to content

Commit

Permalink
fix: further improvements for dealing with iframes
Browse files Browse the repository at this point in the history
  • Loading branch information
amtrack committed Nov 15, 2023
1 parent 7ac69a2 commit fc4b6b5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/browserforce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,14 @@ export class Browserforce {
// Wait for either the selector in the page or in the iframe.
// returns the page or the frame
public async waitForSelectorInFrameOrPage(page: Page, selector: string): Promise<Page | Frame> {
await page.waitForSelector(`pierce/${VF_IFRAME_SELECTOR}, ${VF_IFRAME_SELECTOR}, ${selector}`);
const frameElementHandle = await page.$(`pierce/${VF_IFRAME_SELECTOR}, ${VF_IFRAME_SELECTOR}`);
await page.waitForSelector(`pierce/${VF_IFRAME_SELECTOR}, ${selector}`);
const frameElementHandle = await page.$(`pierce/${VF_IFRAME_SELECTOR}`);
let frameOrPage: Page | Frame = page;
if (frameElementHandle) {
const frame = await frameElementHandle.contentFrame();
if (frame) {
await frame.waitForNavigation();
frameOrPage = frame;
}
const frame = await page.waitForFrame(
async (f) => f.name().startsWith('vfFrameId') && f.url()?.length > 0 && f.url() !== 'about:blank'
);
frameOrPage = frame;
}
await frameOrPage.waitForSelector(selector);
return frameOrPage;
Expand Down

0 comments on commit fc4b6b5

Please sign in to comment.