简体   繁体   中英

How to switch on pop-up (PDF) by using python selenium

I am trying to switch on popup window which has the pdf file by using python selenium package but unable to switch.

I have tried this:

parent_h = browser.current_window_handle
browser.find_elements_by_xpath(".//i[@class = 'fa fa-certificate']")[i].click()
browser.find_element_by_xpath(".//object[@data]")

handles = browser.window_handles # before the pop-up window closes
handles.remove(parent_h)

browser.switch_to_window(handles.pop())

link: https://maharerait.mahaonline.gov.in/searchlist/search?MenuID=1069

Fill the project name 'Hirandani' than click on search and than click on 'View Certificate' icon, will get the popup.

Pop up is not different window. So no handler or switching is required. It is embedded in html. If you are just trying to get the pdf data then use this.

pdf_data = browser.find_element_by_tag_name('object').get_attribute('data')

To close pdf pop up

browser.find_element_by_id('button.ui-button.ui-widget').click()

我可以使用标签方法打开pdf框架。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM