[Python] Selenium Webdriver cannot input text into field by XPATH in TinyMCE

Discussão em 'Python' iniciado por Stack, Março 5, 2025.

  1. Stack

    Stack Membro Participativo

    I have followed the instructions, but my script isn't working:

    # Wait for the iframe to be present
    print("a")
    result_frame = WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.ID, '_tinymce-rwo3euny6y8_ifr'))
    )
    # Switch to the iframe
    print("b")
    driver.switch_to.frame(result_frame)
    # Wait for the body inside the iframe to be located
    print("c")
    mce_edit = WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.XPATH, "//body[@id='tinymce']"))
    )
    # Send keys to the body element
    mce_edit.send_keys("Hello World")


    And here the HTML element base on sequence:

    <tinymce _ngcontent-krn-c55="" id="my-editor" placeholder="Be detailed and creative in your description to attract a buyer. Do not share your Discord, email, Skype, PayPal, or any other personal information as this violates our safety policy and will result in a suspension." class="ng-untouched ng-pristine ng-invalid">

    <textarea class="tinymce-selector" id="_tinymce-rwo3euny6y8" placeholder="Be detailed and creative in your description to attract a buyer. Do not share your Discord, email, Skype, PayPal, or any other personal information as this violates our safety policy and will result in a suspension." style="display: none;" aria-hidden="true"></textarea>

    <iframe id="_tinymce-rwo3euny6y8_ifr" frameborder="0" allowtransparency="true" title="Rich Text Area. Press ALT-0 for help." class="tox-edit-area__iframe"></iframe>


    <body id="tinymce" class="mce-content-body " data-id="_tinymce-rwo3euny6y8" contenteditable="true" spellcheck="false" style="overflow-y: hidden; padding-left: 15px; padding-right: 15px; min-height: 0px;" data-mce-style="overflow-y: hidden; padding-left: 15px; padding-right: 15px; min-height: 0px;" data-mce-placeholder="Be detailed and creative in your description to attract a buyer. Do not share your Discord, email, Skype, PayPal, or any other personal information as this violates our safety policy and will result in a suspension." aria-placeholder="Be detailed and creative in your description to attract a buyer. Do not share your Discord, email, Skype, PayPal, or any other personal information as this violates our safety policy and will result in a suspension." data-lt-tmp-id="lt-197197" data-gramm="false" xpath="1"><p><br data-mce-bogus="1"></p></body>





    I have already tried several answer from stackoverflow but they didn't help. Any help would be appreciated.

    Thanks!

    Continue reading...

Compartilhe esta Página