Basic Selenium

Execute Selenium test on chrome browser on MAC using Selenium

Page Object Model using Selenium Webdriver.

To start any third party browser (Chrome, Opera etc.) Chrome browser on MAC using Selenium we have to use some drivers which will interact with the browsers.

In windows, we have already seen working with IE, Chrome, Firefox and mobile browsers as well.

In windows, it’s quite easy to download and specify the path in the program but in MAC we have to keep all the driver in a specific folder and then Selenium will start the execution directly.

 

First step- Download the drivers for MAC

Download link  http://chromedriver.storage.googleapis.com/index.html?path=2.23/

Chrome Browser ON MAC using Selenium

Second step- In MAC we have one directory called /usr/local/

Chrome Browser ON MAC using Selenium

 

 

Chrome Browser ON MAC using Selenium

In above location, you can create bin folder (if not created).

Now you have to copy the driver in /usr/local/bin and that all

 

Good thing which I like here is we don’t have to remember the path variable like webdriver.chrome.driver

Chrome Browser ON MAC using Selenium

Program for Chrome browser on MAC using Selenium

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;



public class HandleDropDown3 {



   public static void main(String[] args) throws InterruptedException {





       WebDriver driver=new ChromeDriver();



       driver.manage().window().maximize();



       driver.manage().timeouts().pageLoadTimeout(1, TimeUnit.SECONDS);



       driver.get("https://vistasadprojects.com/mukeshotwani-blogs-v2/");





   }



}

 

Hope you have liked the above article, I have used in a straight way but if you know any other way to handle drivers in Selenium then feel free to share your thoughts in comment section.

 

 

author-avatar

About Mukesh Otwani

I am Mukesh Otwani working professional in a beautiful city Bangalore India. I completed by BE from RGPV university Bhopal. I have passion towards automation testing since couple of years I started with Selenium then I got chance to work with other tools like Maven, Ant, Git, GitHub, Jenkins, Sikuli, Selenium Builder etc.

14 thoughts on “Execute Selenium test on chrome browser on MAC using Selenium

  1. what a great post sir I am regular visitor of this blog and I love your blog

    1. Thanks 🙂
      You’re always welcome

  2. Jahnavi says:

    HI Mukesh,
    Thanks for the article, your blog and videos have helped me learn a lot in my automation journey. I am wondering if you have come across a scenarios where you had the program to look at a specific file to load configurations. When I used windows to develop the scripts:
    string configFilePath = Path.Combine(libraryFilePath, “Config\\config.json”);

    We have been moving over to MAC, and it does not seem to like the folder structure, what is the best possible way to resolve this other than getting the OS and including an if condition

    1. Hi Jahnavi,

      Instead absolute or full file path, use relative path with respect to your project root folder like ./Config/config.properties. This will work on all OS.

  3. Akash says:

    I have always used windows for automation purpose. In an interview they gave me Mac to write the script. i wrote it correctly but the browser was not launching. and i got rejected. now i know what mistake i did.

    1. Hi Akash,

      Would you please let me know, which mistake you found?

  4. Riley says:

    Oh my god I’ve searched for an entire day and this article is the ONLY thing that has finally worked! Thank you so much for this! Was getting so frustrated at the complexity of Selenium and the minimal documentation for Mac and this is what finally did the trick for me!

    1. Hi Riley,

      Glad that my blog post helped you. You’re always welcome…:)

  5. Yashasri says:

    Awesome content Mukesh!
    I’m feeling lucky that I found this site.

    God bless you Bro!

    1. Thanks Yashasri 🙂 Keep in touch.

  6. Mrinal kumar says:

    And pls share the procedure to launch safari also

    1. Hi Mrinal,

      For Safari you can install just small plugin in browser and rest Selenium will handle.

      To launch call SafariDriver()

  7. Raja says:

    Really cool!, Thanks buddy.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.