I am using Selenium to scrape results from an online database. However, once I have selected my results and go to export them a pop-up window appears. Normally I would just switch the frame to this window but it appears to be javascript generated. While there are elements on this pop up, the specific name keeps changing. So for instance there is a submitButton id tag. However, it is alway appended with a different ending. So for instance it will be id="submitButton_15bb0b69431" but the next time it will be something completely different such as id="submitButton_15bb0c03e8e". My normal method of finding by ID or CSS or XPATH, therefore, does not work.
How can I handle this window to select the elements I need? Could I perhaps somehow get the page source for the popup?
The code I have so far is as follows:
for i in listofpa:
try:
driver.find_element_by_xpath(i).click()
driver.find_element_by_css_selector('#mainContentRight > div.pagination > ul > li:nth-child(13) > a').click()
except:
pass
This is the part I am stuck on
time.sleep(5)
window_before = driver.window_handles[0]
driver.find_element_by_id("tsMore").click()
try:
driver.find_element_by_css_selector('#saveExportLink_6').click()
window_after = driver.window_handles[1]
driver.switch_to_window(window_after)
html = driver.page_source()
print html