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/
Second step- In MAC we have one directory called /usr/local/
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
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://learn-automation.com/"); } }
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.
storm of games says
what a great post sir I am regular visitor of this blog and I love your blog
Mukesh Otwani says
Thanks 🙂
You’re always welcome
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
Mukesh Otwani says
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.
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.
Mukesh Otwani says
Hi Akash,
Would you please let me know, which mistake you found?
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!
Mukesh Otwani says
Hi Riley,
Glad that my blog post helped you. You’re always welcome…:)
Yashasri says
Awesome content Mukesh!
I’m feeling lucky that I found this site.
God bless you Bro!
Mukesh Otwani says
Thanks Yashasri 🙂 Keep in touch.
Mrinal kumar says
And pls share the procedure to launch safari also
Mukesh Otwani says
Hi Mrinal,
For Safari you can install just small plugin in browser and rest Selenium will handle.
To launch call SafariDriver()
Raja says
Really cool!, Thanks buddy.
Mukesh Otwani says
Thanks Raja