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")
posted @ 2018-09-20 11:27  黒貓  阅读(5423)  评论(0编辑  收藏  举报