From: W. Trevor King Date: Tue, 29 Jun 2010 15:59:54 +0000 (-0400) Subject: More robust copy popup handling X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7d5d20e94e3008a78a85826ed1263d23c652afd7;p=sitecorepy.git More robust copy popup handling --- 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):