4

I always got a response status 404 from Safari Web driver on MacOS Sierra when my test script executes command below (see in attachment for full source code):

elemSubmit = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, "submit")))

Steps to Reproduce: 1. Update to MacOS Sierra and Safari 10 2. Install python 3.6 3. Install Python bindings: pip3.6 install -U selenium 4. Run attached test script: python3.6 test.py

Expected Results: The test script should pass

Actual Results: It always fail, I wrote some logs and it shown:

driver_command: isElementDisplayed
params {'id': 'node-64681E7D-D268-429A-9C6F-9908A5D09250', 'sessionId': '7FE8FE61-805E-4B68-9EF5-2C7EA934A382'}
ERROR {'status': 404, 'value': ''}

Version: MacOS Sierra, Python 3.6

import unittest
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
import time

class PythonOrgSearch(unittest.TestCase):

    def setUp(self):
        self.driver = webdriver.Safari(1234, '/usr/bin/safaridriver')

    def test_search_in_python_org(self):
        driver = self.driver
        driver.get("http://www.python.org")
        self.assertIn("Python", driver.title)
        elem = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.NAME, "q")))
        # elem = WebDriverWait(self.driver, 1).until(EC.element_to_be_clickable((By.NAME, "q")))
        # elem = driver.find_element_by_name("q")
        elem.send_keys("pycon")
        elemSubmit = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.ID, "submit")))
        elemSubmit.click()
        assert "No results found." not in driver.page_source
        time.sleep(3)

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

if __name__ == "__main__":
    unittest.main()
PhuTa
  • 59
  • 6

0 Answers0