

New_url.send_keys(Keys.CONTROL + Keys. # And now, the magic! Open fun URL in a new Firefox tab! New_url = driver.find_element_by_xpath("/html/body/div/div/div/div/div/div/div/ul/li/a") # Come up with a creative new URL to go to (this one is great, btw) pip install selenium While the installation of Selenium makes the functionality available to you, you need additional drivers for it to be able to interface with a chosen web browser. # Turn your Firefox browser into a usable object (or something like that) The easiest way to install Selenium on a Python environment is through the installer pip. # Import your stuffsįrom import Keysįfpath = '/home/wt/Documents/Waynes_Python_Education_Directory/Automation_Browser_Drivers' This one takes a page element already in focus and then opens that into a new tab.įinal note: I’m using Ubuntu so not sure if you need to adjust for yourself…Īnyway, here comes the code. I’ll figure that out maybe in another blog post. If you are trying to make a new, unrelated link open in a new tab, this doesn’t work. Python and Selenium are really useful for.

This assumes you are ‘right clicking an element on a page and opening in a new tab’ kind of thing. This guide will show you how to set up an Ubuntu Virtual Private Server (VPS) for web scrapping with Selenium. It may be impossible (so I’ve read online) to perfectly control whether a tab opens on your users’ browser, however, since web automation is probably your browser you should be able to work with this solution and your browser settings to get it going.Īnother important thing before you begin here. Keep that in mind in case you have other headaches.

So this was super duper hard and I believe the reason why is because technically the browser settings and the user choices impact whether or not a clicked link opens in a fresh new tab or a fresh new window.
