I want to open multiple urls on different tabs using Selenium WebDriver and Python.
I'm not sure what is going wrong:
driver = webdriver.Chrome() driver.get(url1) time.sleep(5) driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL+'t') url2 = 'https://www.google.com' driver.get(item2)
I was looking for tutorials and it seems to me that this code should do what I want. In fact, the browser opens, url1 opens, as you would expect, a new tab opens as it should, but url2 is then loaded into the original tab instead of the new one (although the new tab is active).
(I use Chrome because when using Firefox I cannot get it to load any URLs at all. Firefox opens, but does not receive the requested url. I tried to find a solution for this, but to no avail).
Is there anything I can change in my code to open a new URL in a new tab?
Thank you for your help!
python google-chrome selenium
SamH123
source share