Python Selenium Webdriver: finding #document element -
i have been using python's selenium webdriver getting elements html code. however, not access of elements within #document tag.
i used both driver.find_element_by_xpath("html/body/div[@id='frame']/iframe/*"), , tried elem = driver.find_element_by_tag("iframe"), next elem.find_element_by_xpath find inner elements failed.
i tried driver.switch_to_frame(driver.find_element_by_tag("iframe")), next xpath expressions find inner elements, did not work.
frame:
<div> <iframe> #document <html> <body> <div> .... </div> </body> </html> </iframe> </div>
switching iframe , using normal query methods right approach use. utilize throughout big test suite.
remember switch default content when you've finished working within iframe though.
now, solve problem. how serving contents of iframe? have literally written html , saved file or looking @ illustration site. might find iframe doesn't contain content expect. seek this.
from selenium.webdriver import firefox b = firefox() b.get('localhost:8000') # or wherever serving html iframe = b.find_element_by_css_selector('iframe') b.switch_to_frame(iframe) print b.page_source that html within iframe. contents expect? or empty. if it's empty suspect it's because need serve contents of iframe separately.
python selenium xpath selenium-webdriver webdriver
No comments:
Post a Comment