selenium利用js抓隐藏元素

 

 

 

元素抓取不到时通过控制台及检查元素查看是否获取有元

time.sleep(2)
driver.find_element_by_css_selector('#app > section > section > main > div > div.padding-middle.setting-area > div > div.tab-page.margin-left-large.border-radius-small > div.work-area-bgcolor.tab-containier > div > div.container.full-height > div.device-list.form-style.work-area-bgcolor.padding-middle > form > div:nth-child(2) > div.ant-col.ant-form-item-control-wrapper > div > span > div > div > div').click()
js = "return document.querySelector('#test-uuid > ul > li:nth-child(3)').innerText"
time.sleep(1.5)
driver.find_element_by_css_selector('#test-uuid > ul > li:nth-child(3)').click()
print(js)
text = driver.execute_script(js)
print(text)

 

posted @ 2022-08-16 09:21  代码是肥钦喔  阅读(194)  评论(0编辑  收藏  举报