I am working on one automation project everything is working fine But while printing to page content to html file i am facing duplication issue could you please help me.
From the below code content of logE2
and logE1
should be different because they belong to different windows but i can see logE1
is duplicated with the content of logE2
browser.switch_to_window(window_main)
title3 = browser.title
print title3
browser.execute_script("document.getElementById('WIN_0_801800482').click()")
browser.switch_to_window(window_child1)
browser.implicitly_wait(300)
select233 = browser.find_element_by_xpath('//td/nobr/span[text()="ALL_E2_incidents"]')
select233.click()
select = browser.find_elements_by_id("WIN_0_801600035")
browser.execute_script("document.getElementById('WIN_0_801600035').click()")
browser.implicitly_wait(300)
select = browser.find_elements_by_id("WIN_0_801600020")
browser.execute_script("document.getElementById('WIN_0_801600020').click()")
browser.implicitly_wait(300)
select = browser.find_elements_by_id("WIN_0_801600134")
browser.execute_script("document.getElementById('WIN_0_801600134').click()")
browser.switch_to_window(browser.window_handles[-1])
contente2 = browser.page_source
soup2 = BeautifulSoup(contente2, "html5lib")
logE2 = open("c:\\E2incidents.html", "w")
print >>logE2, soup2
print "e2 finished"
title4 = browser.title
print title4
#############
browser.switch_to_window(window_child1)
browser.implicitly_wait(300)
select234 = browser.find_element_by_xpath('//td/nobr/span[text()="ALL_E1_incidents"]')
select234.click()
select = browser.find_elements_by_id("WIN_0_801600035")
browser.execute_script("document.getElementById('WIN_0_801600035').click()")
browser.implicitly_wait(300)
select = browser.find_elements_by_id("WIN_0_801600020")
browser.execute_script("document.getElementById('WIN_0_801600020').click()")
browser.implicitly_wait(300)
select = browser.find_elements_by_id("WIN_0_801600134")
browser.execute_script("document.getElementById('WIN_0_801600134').click()")
time.sleep(5)
browser.switch_to_window(browser.window_handles[-1])
contente3 = browser.page_source
soup3 = BeautifulSoup(contente3, "html5lib")
logE3 = open("c:\\E1incidents.html", "w")
print >>logE3, soup3
print "e1 finished"
title5 = browser.title
print title5