Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14185

using selenium to interact with popup print dialogue box not working

$
0
0

I am trying to interact(set options like page size etc) on a print dialogue box that pops up after hitting a print button on a webpage. My attempt at the code is :

win_before = driver.current_window_handle
driver.find_element(By.XPATH,'/html/body/div/div/div1/div/div/main/div/div/div/div[2]/div/div/div[2]/button').click() # clicks the print button on webpage
time.sleep(2)
popup = 0
for handle in driver.window_handles:
   if handle != win_before:
      popup = handle
      break
driver.switch_to.window(popup)
time.sleep(5)
elem = driver.execute_script("return document.querySelector('print-preview-app')")
print(elem.get_attribute('innerHTML'))

at this point since the program has switched to the popped up dialogue box window , we should be able to interact with elements within the box using selenium methods but i have had no success. So i switched to using query selector this way and i still cannot locate any elements.
Html of the print dialogue box


Viewing all articles
Browse latest Browse all 14185

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>