如何在python中更改selenium中的属性?
我需要用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="">);') 但此代码不起作用:
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");')