How to Interact with iframe in Google Form “add file” feature Using Python and Playwright? - Stack Overflow

admin2025-04-30  1

I am trying to use Python and Playwright to automate the process of filling out a Google Form.

However, I am encountering an issue when attempting to interact with the "My Drive" button (The "My Drive" button that needs to be clicked.) in the add file feature (The 'Add file' feature in Google Form.).

I've attempted to retrieve all iframes using page.frames to locate the target iframe that contains the "My Drive" button( The structure of iframe. ) but fail.

questions = page.locator('.Qr7Oae') 

# click 'Add file' button to show the google drive iframe
questions.nth(0).locator( '.uArJ5e.cd29Sd.UQuaGc.AeAAkf.jyLEF' ).click() 

# Get all frames on the page 
frames = page.frames   
 
# print the frames 
for f in frames : 
    print ( 'all frames >>>', f, '<<<\n' )

It returned other frames, but not the iframe for the "Add file" feature.

iframe's name and url are not fixed, making it difficult to reliably locate the desired iframe.

Here's the link of the form ()

Any help or guidance on this issue would be greatly appreciated!

转载请注明原文地址:http://anycun.com/QandA/1746022218a91466.html