如何在 python 中使用 selenium 将整个文本发送到文本区域而不是逐行发送?

问题描述

我的代码将文本逐行输入到网页的文本区域,如何让它一次插入整个文本,有没有解决方案?因为一行一行需要很多时间

My code inputs text into the text area of the web page , line by line, how to make it insert the entire text all at once instead, is there a solution for this? because line by line takes a lot of time

def Translated_Content(content):

    driver= webdriver.Chrome("C:\Users\shricharan.arumugam\Desktop\PDF2txt\chromedriver.exe")
    driver.get('https://translate.shell.com/')

    input_box = driver.find_element_by_id('translateText')
    input_box.send_keys(content)

    translate_button = driver.find_element_by_id('translate')
    translate_button.click()
    translated_text_element= driver.find_element_by_id('translatedText')
    time.sleep(4)


    translated_text=translated_text_element.get_attribute('value')

    driver.close()

    return translated_text


解决方案

通过 Python 使用 selenium 将整个文本块发送到