4

My code:

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

driver = webdriver.Firefox()
driver.get("https://www.youtube.com")
login_wait = WebDriverWait(driver, 10)

textbox = login_wait.until(EC.visibility_of_element_located((By.ID, 'search')))
textbox.send_keys("a")

time.sleep(10)
driver.close()

No error in Python console but geckodriver.log:

1514074507756   geckodriver INFO    geckodriver 0.19.1
1514074507763   geckodriver INFO    Listening on 127.0.0.1:49865
1514074508870   mozrunner::runner   INFO    Running command: "/Applications/Firefox.app/Contents/MacOS/firefox-bin" "-marionette" "-profile" "/var/folders/kf/8800phd97vx28vtzdytqk1m80000gn/T/rust_mozprofile.oI7AzEUKweAr"
1514074509913   Marionette  ERROR   Error on starting server: [Exception... "Component returned failure code: 0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE) [nsIServerSocket.initSpecialConnection]"  nsresult: "0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE)"  location: "JS frame :: chrome://marionette/content/server.js :: MarionetteServer.prototype.start :: line 95"  data: no]
[Exception... "Component returned failure code: 0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE) [nsIServerSocket.initSpecialConnection]"  nsresult: "0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE)"  location: "JS frame :: chrome://marionette/content/server.js :: MarionetteServer.prototype.start :: line 95"  data: no]
MarionetteServer.prototype.start@chrome://marionette/content/server.js:95:19
MarionetteComponent.prototype.init@jar:file:///Applications/Firefox.app/Contents/Resources/omni.ja!/components/marionette.js:217:5
MarionetteComponent.prototype.handle@jar:file:///Applications/Firefox.app/Contents/Resources/omni.ja!/components/marionette.js:112:5

2017-12-23 19:15:11.556 plugin-container[42994:4077314] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x9b3b, name = 'com.apple.tsm.portname'
See /usr/include/servers/bootstrap_defs.h for the error codes.
2017-12-23 19:15:11.559 plugin-container[42994:4077314] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x9e03, name = 'com.apple.CFPasteboardClient'
See /usr/include/servers/bootstrap_defs.h for the error codes.
User
  • 23,729
  • 38
  • 124
  • 207

1 Answers1

1

If you look ino the error stack trace, the error says it all :

1514074509913   Marionette  ERROR   Error on starting server: [Exception... "Component returned failure code: 0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE) [nsIServerSocket.initSpecialConnection]"  nsresult: "0x804b0036 (NS_ERROR_SOCKET_ADDRESS_IN_USE)"  location: "JS frame :: chrome://marionette/content/server.js :: MarionetteServer.prototype.start :: line 95"  data: no]

This essentially means Marionette is trying to open up a connection on you localhost i.e. 127.0.0.1 through port 49865 but the port is currently occupied due to one of the following reasons :

  • Port 49865 is currently being used by some other application running out of your localhost.
  • Port 49865 is used by some service running from your localhost.
  • Port 49865 haven't been released by a dangling instance of a WebDriver variant e.g. GeckoDriver, ChromeDriver, IEDriverServer or GhostDriver.

Solution :

The solution would be either/all of the following steps :

  • Always use driver.quit() within tearDown() method of your Automation Script. If any dangling instance of WebDriver variant e.g. GeckoDriver, ChromeDriver, IEDriverServer or GhostDriver are present on your system, Kill them programatically/manually.
  • Ensure that Port 49865 is not used by any other application running out of your localhost.
  • Ensure that Port 49865 is not used by some service running from your localhost.
  • Use CCleaner tool before and after executing your Tests to wipe off the OS chores from your system.
  • Take a System Reboot
  • If the issue still persists, uninstall Mozilla Firefox Browser through Revo Uninstaller and install fresh instance of Mozilla Firefox Browser
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 2
    Man, that's a nightmare for Jenkins. If a test doesn't release ports, even if there's a test failure, you have to ssh into the machine or reboot it. – Sridhar Sarnobat May 01 '18 at 19:25