From 7d5d20e94e3008a78a85826ed1263d23c652afd7 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Tue, 29 Jun 2010 11:59:54 -0400 Subject: [PATCH] More robust copy popup handling --- sitecore/prof/import.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sitecore/prof/import.py b/sitecore/prof/import.py index bfcdb9e..e603b31 100644 --- a/sitecore/prof/import.py +++ b/sitecore/prof/import.py @@ -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): -- 2.26.2