Run Selenium in Different Browsers

The main difference between launching the webpage in different browsers is by creating a webdriver object and accessing all the methods from that object.

When we create a webdriver object with respective to require browser driver then we can perform our actions on that particular browser.

FireFox Browser

Launch the web page in the FireFox browser.

Example: In the below example we are launching http://www.dummypoint.com/seleniumtemplate.html url using FireFox driver.

  • Configure the FireFox driver to webdriver object
  • Using get() method of webdriver launch the url.
  • Wait for 5 sec.
  • Close the FireFox driver instance.


LaunchWebApp_FireFox.py

from selenium import webdriver
import time

driver = webdriver.Firefox(executable_path="/Users/admin/Documents/Skill2Lead/drivers/geckodriver.exe")

driver.get("http://www.dummypoint.com/seleniumtemplate.html")

time.sleep(5)
driver.quit()


Safari Browser

Launch the webpage in the Safari browser.

First we need to configure the settings to launch the webpage in the safari browser.

For more information please look into our video course for configuration.

  • Launch the safari browser
  • In menu bar click on “safari”
  • Click on “preferences”
  • A new window popup will open. Now click on “Advanced”
  • Now click on checkbox for “ Show Develop menu in menu bar”
  • Click on “Develop” Option in menu bar
  • Now click on “Allow Remote Automation”

Example: In the below example we are launching http://www.dummypoint.com/seleniumtemplate.html url using safari driver.

  • Configure the Safari driver to webdriver object
  • Using get() method of webdriver launch the url.
  • Wait for 5 sec.
  • Close the safari driver instance.

LaunchWebApp_Safari.py

from selenium import webdriver
import time

driver = webdriver.Safari()

driver.get("http://www.dummypoint.com/seleniumtemplate.html")

time.sleep(5)
driver.quit()