ham*_*yad 1 textarea enter submit python-3.x selenium-webdriver
我想将文本发送到字段并提交。显示了 HTML 代码。我应该怎么做?这是我的 HTML 代码:
<form class="_b6i0l"><textarea aria-label="Add a comment…" placeholder="Add a comment…" class="_bilrf" autocomplete="off" autocorrect="off" style="height: 18px;"></textarea>
<textarea aria-label="Add a comment…" placeholder="Add a comment…" class="_bilrf" autocomplete="off" autocorrect="off" style="height: 18px;"></textarea>
</form>
Run Code Online (Sandbox Code Playgroud)
我想用以下代码将文本发送到框:
driver.execute_script("arguments[0].value = arguments[1]", driver.find_element_by_css_selector("textarea._bilrf"), "nice!")
Run Code Online (Sandbox Code Playgroud)
如何按 Enter 发送我的文本?请问你能帮帮我吗?
小智 6
尝试使用send_keys()(https://seleniumhq.github.io/selenium/docs/api/py/webdriver_remote/selenium.webdriver.remote.webelement.html#selenium.webdriver.remote.webelement.WebElement.send_keys)和特殊键模块(https://seleniumhq.github.io/selenium/docs/api/py/webdriver/selenium.webdriver.common.keys.html#module-selenium.webdriver.common.keys )
from selenium.webdriver.common.keys import Keys
...
driver.find_element_by_css_selector("textarea._bilrf").send_keys("nice!", Keys.ENTER)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11888 次 |
| 最近记录: |