使用 Python Selenium 选择 textarea 中的所有文本

问题描述

我正在尝试选择 pine 脚本的 textarea 中的所有文本。 pinescript image

为此我尝试了:

driver.find_element_by_xpath("//textarea[@class='ace_text-input']").send_keys(keys.CONTROL + "a")

以上是唯一相关的代码,我的python代码将打开chrome转到https://in.tradingview.com/chart/并等待2分钟,然后单击Pine Editor然后

driver.find_element_by_xpath("//textarea[@class='ace_text-input']").send_keys(keys.CONTROL + "a")

但是,它没有被选中,也没有显示错误

解决方法

尝试使用 ActionChains

webdriver.ActionChains(driver).key_down(Keys.CONTROL).send_keys("a").perform()