pythondomautomationpuppeteerplaywright

Cant find keyword using Playwright & Pyppeteer


So when using all kinds of Python automation tools (such as Playwright and Pyppeteer) I can't seem to grab the "Continue with Google" button on https://dropbox.com/login. When I do this through the console like this:

const element = [...document.querySelectorAll('span,button,div,a')].find(el => el.textContent.includes('Doorgaan met Google'));

// Check if the element is found and click it
if (element) {
    element.click();
    console.log('Button clicked successfully!');
} else {
    console.error('Button not found!');
}

It finds and clicks the button in Chrome but not in Firefox. In the programs I've wrote using Playwright and Pyppeteer I couldn't find the button either (although sometimes literally just evaluating the same JS code).

Anyone know what this is caused by?

Thanks in advance.


Solution

  • Apparently the structure generated for FireFox is different from the structure generated for other browsers. This worked on FireFox for me:

    document.querySelector(".L5Fo6c-bF1uUb").click()
    

    In FireFox the button has this structure:

    <div id="some_id_here" class="L5Fo6c-bF1uUb" tabindex="0"></div>
    

    and no inner text. This is why your script did not find it in FireFox.