如何在python中更改selenium中的属性?

如何在python中更改selenium中的属性?,python,selenium,Python,Selenium,我需要用python中的selenium更改img标记中的src属性 浏览器是firefox HTMLcode: <div style="" id="image_sec"> <img src="city.png" alt=""> </div> driver.execute_script('$("#image_sec img").innerHtml(<img src="new_city.png" alt="">);') 但此代码不起作用:

我需要用python中的selenium更改
img
标记中的
src
属性

浏览器是
firefox

HTML
code:

<div style="" id="image_sec">
    <img src="city.png" alt="">
</div>
driver.execute_script('$("#image_sec img").innerHtml(<img src="new_city.png" alt="">);')

但此代码不起作用:-(

尝试在下面的行中实现

driver.execute_script('document.querySelector("#image_sec>img").src="new_city.png";')

driver.execute_script('document.querySelector("#image_sec>img").src="new_city.png";')
driver.execute_script('document.querySelector("#image_sec>img").setAttribute("src", "new_city.png");')