I have a URL http://travel.aol.co.uk/2016/03/23/best-hotels-for-families-mediterranean/ which has some Social sharing links such as Twitter , Facebook etc. When I click on them they lead to a new window. However, I am not able to perform operations on that window as I cannot switch to that window. Any help is appreciated. I tried switchTo methods but they don't work. Any help is appreciated.
Following is the code
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get('http://travel.aol.co.uk/2016/03/23/best-hotels-for-families- mediterranean/')
window_before = driver.window_handles[0]
linkElement = driver.find_element_by_class_name('share-icon-twitter')
linkElement.click()
window_after = driver.window_handles[1]
driver.switch_to_window(window_after)
print (driver.title)
When I print the title at the end, nothing shows up. But if I switch back to the old window and then print the title, correct title shows up.
Thank you.