In is section we will see how to run selenium on 3 major browsers (i.e, Internet Explorer, Firefox and Chrome).
In order to run your code on different browsers, all you have to do is creating an appropriate instance for each browsers and access the selenium methods using them.
Appropriate driver methods for appropriate browsers are used and navigating the selenium WebDriver in executable path. Visit the Link to download suitable WebDriver https://www.seleniumhq.org/download/
Once downloaded place them on you system and set them as values in executable path in the driver method.
Syntax
reference_variable = webdriver.drivername_for_browser(executable_path ="Path\\To\\Your\\Driver\\Exe") Refer the below piece of code for reference
Running Test on Chrome
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome(executable_path="D:\Software\Selenium\chromedriver.exe")
driver.get("http://www.facebook.com")
print(driver.title)
Running Test on Firefox
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox(executable_path="D:\Software\Selenium\geckodriver-v0.24.0-win64\geckodriver.exe")
driver.get("http://www.facebook.com")
print(driver.title)
Running Test on IE
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox(executable_path="D:\Software\Selenium\geckodriver-v0.24.0-win64\geckodriver.exe")
driver.get("http://www.facebook.com")
print(driver.title)
I have attached Python files below for reference