Download Python "bindings" for Selenium. Bindings are just some code that enables you to write tests using the Python programming language.

  1. Make sure you have pip installed. pip is a Python's package manager. Basically, it allows you to get different code written in Python from they internet. Open Terminal and run which pip. You should see a path to the pip installation, i.e. /usr/local/bin/pip. If you don't, Google how to install pip .
  2. Run pip install selenium. You should get a confirmation that Selenium was installed. If you get errors, try figuring them out.
  3. OK, which browser will you run the tests in? The easiest to get started on a Mac with is probably Safari because you don't need to install a driver and it's already installed on every Mac. Open Safari and check if you have a Develop menu item in the menu bar. If you don’t see the Develop menu, choose Safari > Preferences, click Advanced, then select “Show Develop menu in menu bar.”
  4. Go to Develop → enable Allow Remote Automation.
  5. Cool. You're doing great. Now for the fun part, ready? Open Sublime Text, press "Command" + N to create a new file and copy-paste this script:
import time
import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

class GoogleSearchTest(unittest.TestCase):

    def setUp(self):
        self.driver = webdriver.Safari()
  
    def test_search_returns_expected_result(self):
        driver = self.driver
        driver.get("<http://www.google.com>")

        search_text_field = driver.find_element_by_name("q")
        search_text_field.send_keys("Let me google that for you")

        self.wait_for(seconds=3)

        search_text_field.send_keys(Keys.RETURN)

        self.wait_for(seconds=3)

        expected_result = "LMGTFY - Search Made Easy"

        assert expected_result in driver.page_source

    def wait_for(self, seconds=0):
        time.sleep(seconds)

    def tearDown(self):
        self.driver.close()

if __name__ == "__main__":
    unittest.main()
  1. Save the file and press "command" + B. If all goes well, a console view should open in Sublime and Safari should launch and navigate to Google. If you get the dialog below, just click "Continue Session"

  1. Well, if that worked, you've just written your first automated test! (I'm just assuming you haven't written any before—I could be totally wrong). The console should tell you that the test passed: