I'm writing a code that uses https://www.deepl.com/translator to translate english movie titles to polish (since it's the only translator i know that doesn't translate them literally) but I'm unable to extract translated text from website.
driver.find_element(By.XPATH, '//*[@id="panelTranslateText"]/div[2]/section[2]/div[8]/div[1]/div/div[2]/ol/li[1]/button').click()
print("polish confirmed")
WebDriverWait(driver, 3)
translation = driver.find_element(By.ID, 'target-dummydiv').get_attribute("textContent")
WebDriverWait(driver, 3)
print("translation found")
print(translation)
print(len(translation))
The code runs smoothly until it's time to print out the translated text. It returns 2 character long blank string.
input text to translate
textarea found
sending text
text has been sent
language choice clicked
search bar found
polish inserted
polish confirmed
translation found
2
Here is the HTML code where the translated text is located.
<div class="lmt__inner_textarea_container" title="Kliknij na słowo, aby wyświetlić tłumaczenia alternatywne ">
<textarea aria-labelledby="translation-results-heading" class="lmt__textarea lmt__target_textarea lmt__textarea_base_style" data-gramm_editor="false" dl-test="translator-target-input" autocomplete="off" lang="pl-PL"></textarea>
<div id="target-dummydiv" aria-hidden="true" class="lmt__textarea lmt__textarea_dummydiv" lang="pl-PL">Stranger Things</div>
</div>
I have also tried using get_attribute("innerText")
but it doesn't work either. Is there any other way to extract this text?