使用Python
& Selenium web-diver
,我正在从HTML页面生成报告。
#report name starts with 'std'
folderSize = len(driver.find_elements_by_xpath("//*[contains(@id,'std')]"))
reportList = driver.find_elements_by_xpath("//*[contains(@id,'std')]")
innerIterator = 0
while ( innerIterator < folderSize) :
reportList = driver.find_elements_by_xpath("//*[contains(@id,'std')]")
reportName = reportList[innerIterator].text
##### generate report
driver.find_element_by_partial_link_text(reportName).click()
driver.implicitly_wait(3)
driver.switch_to_default_content()
driver.implicitly_wait(3)
reportList = driver.find_elements_by_xpath("//*[contains(@id,'std')]")
##### reportList Becomes NULL here when invoked second time. First Report is successfully generated.
##### Unable to get seocnnd element in the list
print("Generate report")
innerIterator = innerIterator + 1
呼叫reportList
后,{p> NULL
变为switch_to_default_content()
,后续driver.find_elements_by_xpath("//*[contains(@id,'std')]")
次呼叫返回NULL