python - 如何更改像按钮一样的跨度文本

标签 python python-3.x selenium selenium-webdriver

我正在为自定义 Web 应用程序编写自动化测试。我遇到了无法更改跨度文本的问题。我试过使用 driver.execute_script 但没有成功。 (如果我更了解 javascript,那真的会很有帮助)据我所知,您无法单击跨度,并且该列表被填充为 .更改此文本的最佳方法是什么?

enter image description here

最佳答案

您需要设置 innerHTML using execute_script() :

driver.execute_script('arguments[0].innerHTML = "New value";', element)

element 应该指向您的 span 元素,可以是:

element = driver.find_element_by_css_selector('div.file-wrapper span.k-dropdown span.k-input')

关于python - 如何更改像按钮一样的跨度文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28863834/

相关文章:

python - 根据现有列下一行的元素创建新列

Python:在所有元素的二维数组中显示索引

python - 我想打印以奇数或偶数作为索引的字母(字符串)并将它们保存为列表

python - Selenium (Python): Element is not clickable

java - 该网站不显示 chromedriver/geckodriver (Selenium) 中的信息

python - 为什么这些图像 gridspec 子图的高度略有不同?

python - 匹配两个打印中的相同单词

python-3.x - python : iterate over a nested list and a flat list together

python - pathlib.Path 的子类对象在 pickle.load 后丢失自定义属性

python - 如何在 XPath 选择中包含属性