Don't try Safari with Selenium Webdriver using Python bindings

Using this web page:

<title>My Test Page</title>

<input type="button" value="Authorize" class="standard" id="authButton">

<form action="" target="_blank">
    <input type="submit" value="Test Button">


I have the following test script that tries to click on buttons but doesn't register the click in Safari, it works with Firefox and Chrome. Running OSX 10.10.3, Python 2.7.9, and Safari 8.

The first button (Sign in) never lights up when pressed, and when the second button (Test button) is pressed, a new web page is never launched. (Again only crashing with Safari, works with Firefox and Chrome)

from selenium import webdriver
import unittest, time
import os

class Test(unittest.TestCase):
    def setUp(self):
            os.environ["SELENIUM_SERVER_JAR"] = "/Users/myhome/lib/selenium-server-standalone-2.45.0.jar"
            self.driver = webdriver.Safari()

    def test_(self):
            driver = self.driver
            self.assertEqual("My Test Page", driver.title)

            auth_button = driver.find_element_by_id("authButton")

            auth_button = driver.find_element_by_css_selector("input[type=\"submit\"]")

    def tearDown(self):

if __name__ == "__main__":


I have tried inserting dormant statements to no avail and also tried these options using JavaScript with no success:

driver.execute_script("arguments[0].click();", auth_button)


Console output

17:22:35.979 INFO - Server started on port 42249
17:22:35.999 INFO - Launching Safari
17:22:36.009 INFO - Waiting for SafariDriver to connect
17:22:38.386 INFO - Connection opened
17:22:38.388 INFO - Driver connected in 2379 ms
17:22:38.471 INFO - Done: [new session: Capabilities [{platform=ANY, javascriptEnabled=true, browserName=safari, version=}]]
17:22:38.487 INFO - Executing: [get: http://localhost/~lbieber/test.html])
17:22:38.564 INFO - Done: [get: http://localhost/~lbieber/test.html]
17:22:38.570 INFO - Executing: [get title])
17:22:38.675 INFO - Done: [get title]
17:22:38.681 INFO - Executing: [find element: authButton])
17:22:38.705 INFO - Done: [find element: authButton]
17:22:41.716 INFO - Executing: [click: 0 [[SafariDriver: safari on MAC (null)] -> id: authButton]])
17:22:41.729 INFO - Done: [click: 0 [[SafariDriver: safari on MAC (null)] -> id: authButton]]
17:22:41.734 INFO - Executing: [find element: By.cssSelector: input[type="submit"]])
17:22:41.739 INFO - Done: [find element: By.cssSelector: input[type="submit"]]
17:22:44.746 INFO - Executing: [click: 1 [[SafariDriver: safari on MAC (null)] -> css selector: input[type="submit"]]])
17:22:44.756 INFO - Done: [click: 1 [[SafariDriver: safari on MAC (null)] -> css selector: input[type="submit"]]]
17:22:49.767 INFO - Executing: [delete session: 447708df-40bc-4e3e-b797-4ef0d65037a5])
17:22:49.767 INFO - Shutting down
17:22:49.767 INFO - Closing connection
17:22:49.768 INFO - Stopping Safari
17:22:49.830 INFO - Stopping server
17:22:49.830 INFO - Stopping server
17:22:49.856 INFO - Shutdown complete
17:22:49.857 INFO - Done: [delete session: 447708df-40bc-4e3e-b797-4ef0d65037a5]


Any suggestions would be appreciated.


source to share

All Articles