Selenium查看元素属性

1.如果获取图片中的 src 值:
<img id="imgcorrelationId" class="profile-user-img img-responsiveimg-responsive img-circle" alt="User profile picture" style="margin-left: 35px" src="/image/12.png">
driver.find_element_by_xpath("//*[@id='imgcorrelationId']").get_attribute("src")

2.获取 ifranme 中的 id 属性值
<iframe id="download_zxbg" style="display: none" src=""></iframe>
driver.find_element_by_xpath("//*[@id='download_zxbg']").get_attribute("id")
原文地址:https://www.cnblogs.com/peng-lan/p/9679783.html