More robust copy popup handling
authorW. Trevor King <wking@drexel.edu>
Tue, 29 Jun 2010 15:59:54 +0000 (11:59 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 29 Jun 2010 15:59:54 +0000 (11:59 -0400)
sitecore/prof/import.py

index bfcdb9e1d01596bf1a68dbad5b48c779222853e1..e603b31eaed426f6537220d2e5f617011fff1ece 100644 (file)
@@ -56,12 +56,16 @@ class ProfessorAdder (object):
 
     def create_prof_page(self, prof):
         self.s.open_nav_section('Copy of Shyamalendu Bose')
+        old_windows = self.s.w.get_window_handles()
         self.s.w.find_element_by_link_text('Copy To').click()
         time.sleep(self.s.wait_time)
         windows = self.s.w.get_window_handles()
         current_window = self.s.w.get_current_window_handle()
-        self.s.logger.info('handling copy popup %s (from %s)'
-                         % (current_window, windows))
+        popup = [w for w in windows if w not in old_windows][0]
+        if current_window != popup:
+            self.s.logger.info('handling copy popup %s (from %s, old %s)'
+                               % (popup, windows, current_window))
+            self.s.w.switch_to_window(popup)
         name = self.s.w.find_element_by_id('Filename')
         name.clear()
         name.send_keys(
@@ -69,6 +73,9 @@ class ProfessorAdder (object):
             % (prof.name.first, prof.name.last))
         self.s.w.find_element_by_link_text('Copy').click()
         time.sleep(self.s.wait_time)
+        current_window = self.s.w.get_current_window_handle()
+        self.s.logger.info('handled copy popup %s, back to %s'
+                           % (popup, current_window))
 
 
 def main(argv):