How to change the text of a span that acts like a button

女生的网名这么多〃 提交于 2021-02-20 13:29:30

问题


I am working on writing automation tests for a custom web application. I am running into a problem where I can't change the text of a span. I have tried using driver.execute_script but have had no luck. (It would really help if I knew javascript better) As far as I know you can't click a span and the list is populated as a list of . What is the best way to change this text?

enter image description here


回答1:


You need to set the innerHTML using execute_script():

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

where element should point to your span element, could be:

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


来源:https://stackoverflow.com/questions/28863834/how-to-change-the-text-of-a-span-that-acts-like-a-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!