After reading and learning tons of stuff from Stackoverflow, I finally have a question that I can't seem to find an answer to.
I am using Python, Selenium (WebDriver) and Chrome to write some test scripts. In the course of one of the scripts, a link has to be clicked which opens a PDF doc in a new Chrome window. All this is fine, as the new window pops up exactly the way it is supposed to, however, I cannot figure out how to get my code to work with the new window.
wd = WebDriver()
...
my_link = wd.find_elements_by_css_selector('a')[0]
my_link.click() #will open the link target in a new window
I have tried to do things like:
new_wd = WebDriver()
new_wd = my_link.click()
and that doesn't work
and I have also:
new_wd = WebDriver()
new_wd.get(my_link.get_attribute('href')
which doesn't work because the new chrome window isn't logged in like the originating window.
I am not sure what to do here, and have been looking for answers for a while. Thanks
So the answer to this ends up being that I cannot get the new window.
What I ended up doing was building a list of the links that I need to go to along with their href's. Then instead of clicking those links, I iterated through the list with wd.get(listHref) and then going back to the original URL. This approach met my requirements so I am going with it.
Thanks for the help.