Hi! I am working on a script which goes to url click and in the opening new window take some data, but I cannot make it switch to the new opened window, this is the only function I could find with google, but doesn't seem to work. I use selenium 2.7

Hope someone can help me.



# Clicks and open the mlow button.
browser.get('URL')
time.sleep(5);
try:
browser.find_element_by_xpath("//input[@value='klo']").click()
browser.find_element_by_xpath("//input[@value='mlow']").click()
except NoSuchElementException:
pass

return browser

#I am trying to process take data in opening window


driver = webdriver.Firefox()

driver.SwitchTo().Window(driver.WindowHandles.Last());


browser.find_elements_by_xpath('//li[@style="font-family:Arial,Verdana;font-size: 13px;"]/li[@table width="450"]//tr/td[2]')

result1 = browser.find_elements_by_xpath('//div[@style="text-align:right;background-color:#efefef"]//tr/td[3]')

result2 = browser.find_elements_by_xpath('//div[@style="text-align:right;background-color:#efefef"]//tr/td[2]')





return browser