Playwright を使用して Web サイトの非表示の textarea 入力要素にクリップボードからテキストを貼り付けようとしていますが、要素に属性があるため、問題が発生し続けます。
style="visibility:hidden, display:none;"
Playwright の page.evaluate コマンドで解決しようとしていますが、要素の可視性ステータスを変更できないようです。返されるエラーは次のとおりです。
page.evaluate("[id=txbLongDescription] => document.querySelector('[id=txbLongDescription]')", style='visibility:visible')
TypeError: Page.evaluate() got an unexpected keyword argument 'style'
これまでの私のコードは次のとおりです。
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
context = browser.new_context(accept_downloads=True)
page = context.new_page()
# Click in description input field
#paste description from clipboard
paste = pc.paste()
page.evaluate("[id=txbLongDescription] => document.querySelector('[id=txbLongDescription]')", style='visibility:visible')
page.fill('textarea[id=\"txbLongDescription\"]', f'{paste}')
#---------------------
context.close()
browser.close()
with sync_playwright() as playwright:
run(playwright)
print('Done')