Selenium 3 Compatibility Issue With Firefox 50 Cant Get Any Iframe

Find the data you need here

We provide programming data of 20 most popular languages, hope to help you!

Previous PostNext Post

Selenium 3 compatibility issue with FireFox 50? Can't get any iframe

There are two environments, one is my local with Firefox 47 & Selenium 2.0, the other one is remote vm with Firefox 50 & Selenium 3. With the same code below, the output is different(the ne

    switchToLatestWindow(self.browser)
    time.sleep(3)

    logger.info("===============================================================================================")
    logger.info(self.browser.current_window_handle)
    logger.info(self.browser.find_elements_by_tag_name('iframe'))
    self.browser.switch_to_frame("WorkAreaFrame1popup")
    logger.info("***********************************************************")
    logger.info(self.browser.find_elements_by_tag_name('iframe'))

    # enter firstName and lastName
    result = self.enterFirstName(firstName) and self.enterLastName(lastName)
    if not result:
        return False
    # switch to new windowssss
    logger.info(self.browser.find_elements_by_tag_name('iframe'))
    switchToLatestWindow(self.browser)

    logger.info(self.browser.find_elements_by_tag_name('iframe'))
    time.sleep(3)
    logger.info("++++++++++++++++++++++++++++++++++++++++++++++++++")
    logger.info(self.browser.current_window_handle)
    logger.info(self.browser.find_elements_by_tag_name('iframe'))
    self.browser.switch_to_frame("WorkAreaFrame1popup")
    logger.info("------------------------------------------------------------------")

    time.sleep(2)
    return result
INFO:2017-02-06 12:12:49,615; TCID_4196; createClientProspect.py:1119; ===============================================================================================
INFO:2017-02-06 12:12:49,627; TCID_4196; createClientProspect.py:1120; {e0bbf87b-890d-4b4f-91f9-7c85cb4ac736}
INFO:2017-02-06 12:12:49,635; TCID_4196; createClientProspect.py:1121; [<selenium.webdriver.remote.webelement.WebElement (session="60a21376-7577-4c81-ae79-1233564c227a", element="{23eabe2b-9e57-4319-97d2-d7959f302391}")>, <selenium.webdriver.remote.webelement.WebElement (session="60a21376-7577-4c81-ae79-1233564c227a", element="{db69ec0c-58ba-41ba-b1a9-dd4b1feec08a}")>]
INFO:2017-02-06 12:12:49,644; TCID_4196; createClientProspect.py:1123; ***********************************************************
INFO:2017-02-06 12:12:49,653; TCID_4196; createClientProspect.py:1124; []
INFO:2017-02-06 12:12:49,654; TCID_4196; common_utils.py:339; Randomly generated name:Cagmysp
INFO:2017-02-06 12:12:49,654; TCID_4196; api.py:58; Entering 'Cagmysp' on object named First Name on page New Profile
INFO:2017-02-06 12:12:49,654; TCID_4196; api.py:114; Inject Args: input[id$='builheader_struct.firstname'] to input[id$='builheader_struct.firstname']
INFO:2017-02-06 12:12:50,746; TCID_4196; api.py:142; Successfully interacted with object First Name
INFO:2017-02-06 12:12:50,746; TCID_4196; actionBase.py:103; [PASS] Successfully Entered First Name: Cagmysp
INFO:2017-02-06 12:12:50,746; TCID_4196; common_utils.py:339; Randomly generated name:Bnzpnkbjst
INFO:2017-02-06 12:12:50,746; TCID_4196; api.py:58; Entering 'Bnzpnkbjst' on object named Last Name on page New Profile
INFO:2017-02-06 12:12:50,746; TCID_4196; api.py:114; Inject Args: input[id$='builheader_struct.lastname'] to input[id$='builheader_struct.lastname']
INFO:2017-02-06 12:12:51,872; TCID_4196; api.py:142; Successfully interacted with object Last Name
INFO:2017-02-06 12:12:51,872; TCID_4196; actionBase.py:103; [PASS] Successfully Entered Client Last Name: Bnzpnkbjst
INFO:2017-02-06 12:12:51,881; TCID_4196; createClientProspect.py:1131; []
INFO:2017-02-06 12:12:51,890; TCID_4196; common_utils.py:188; Number of window handles: 2
INFO:2017-02-06 12:12:51,890; TCID_4196; common_utils.py:189; Number of window handles: [u'{3f63d3c1-642f-4e8d-a77b-2136711f94c3}', u'{e0bbf87b-890d-4b4f-91f9-7c85cb4ac736}']
INFO:2017-02-06 12:12:51,894; TCID_4196; common_utils.py:192; Number of window handles: 2
INFO:2017-02-06 12:12:51,894; TCID_4196; common_utils.py:193; Number of window handles: [u'{3f63d3c1-642f-4e8d-a77b-2136711f94c3}', u'{e0bbf87b-890d-4b4f-91f9-7c85cb4ac736}']
INFO:2017-02-06 12:12:51,910; TCID_4196; createClientProspect.py:1134; [<selenium.webdriver.remote.webelement.WebElement (session="60a21376-7577-4c81-ae79-1233564c227a", element="{23eabe2b-9e57-4319-97d2-d7959f302391}")>, <selenium.webdriver.remote.webelement.WebElement (session="60a21376-7577-4c81-ae79-1233564c227a", element="{db69ec0c-58ba-41ba-b1a9-dd4b1feec08a}")>]
INFO:2017-02-06 12:12:59,910; TCID_4196; createClientProspect.py:1136; ++++++++++++++++++++++++++++++++++++++++++++++++++
INFO:2017-02-06 12:12:59,920; TCID_4196; createClientProspect.py:1137; {e0bbf87b-890d-4b4f-91f9-7c85cb4ac736}
INFO:2017-02-06 12:12:59,927; TCID_4196; createClientProspect.py:1138; [<selenium.webdriver.remote.webelement.WebElement (session="60a21376-7577-4c81-ae79-1233564c227a", element="{23eabe2b-9e57-4319-97d2-d7959f302391}")>, <selenium.webdriver.remote.webelement.WebElement (session="60a21376-7577-4c81-ae79-1233564c227a", element="{db69ec0c-58ba-41ba-b1a9-dd4b1feec08a}")>]
INFO:2017-02-06 12:12:59,936; TCID_4196; createClientProspect.py:1140; ------------------------------------------------------------------
INFO:2017-02-06 12:17:54,739; TCID_4196; common_utils.py:193; Number of window handles: [u'2147483651', u'2147483678']
INFO:2017-02-06 12:17:57,759; TCID_4196; createClientProspect.py:1119; ===============================================================================================
INFO:2017-02-06 12:17:57,767; TCID_4196; createClientProspect.py:1120; 2147483678
INFO:2017-02-06 12:17:57,782; TCID_4196; createClientProspect.py:1121; [<selenium.webdriver.firefox.webelement.FirefoxWebElement (session="4079af6b-dda2-4949-95c6-8aa9ff29c49e", element="89bfc3a1-5749-42d4-b0db-da1fc43a0f35")>, <selenium.webdriver.firefox.webelement.FirefoxWebElement (session="4079af6b-dda2-4949-95c6-8aa9ff29c49e", element="3483f682-490c-4c16-8055-fb6c0ee99ad0")>]
INFO:2017-02-06 12:17:57,809; TCID_4196; createClientProspect.py:1123; ***********************************************************
INFO:2017-02-06 12:17:57,821; TCID_4196; createClientProspect.py:1124; []
INFO:2017-02-06 12:17:57,821; TCID_4196; common_utils.py:339; Randomly generated name:Odkdzgvbi
INFO:2017-02-06 12:17:57,821; TCID_4196; api.py:58; Entering 'Odkdzgvbi' on object named First Name on page New Profile
INFO:2017-02-06 12:17:57,822; TCID_4196; api.py:114; Inject Args: input[id$='builheader_struct.firstname'] to input[id$='builheader_struct.firstname']
INFO:2017-02-06 12:17:58,928; TCID_4196; api.py:142; Successfully interacted with object First Name
INFO:2017-02-06 12:17:58,928; TCID_4196; actionBase.py:103; [PASS] Successfully Entered First Name: Odkdzgvbi
INFO:2017-02-06 12:17:58,930; TCID_4196; common_utils.py:339; Randomly generated name:Arrtxwyjs
INFO:2017-02-06 12:17:58,930; TCID_4196; api.py:58; Entering 'Arrtxwyjs' on object named Last Name on page New Profile
INFO:2017-02-06 12:17:58,930; TCID_4196; api.py:114; Inject Args: input[id$='builheader_struct.lastname'] to input[id$='builheader_struct.lastname']
INFO:2017-02-06 12:18:00,101; TCID_4196; api.py:142; Successfully interacted with object Last Name
INFO:2017-02-06 12:18:00,101; TCID_4196; actionBase.py:103; [PASS] Successfully Entered Client Last Name: Arrtxwyjs
INFO:2017-02-06 12:18:00,127; TCID_4196; createClientProspect.py:1131; []
INFO:2017-02-06 12:18:00,138; TCID_4196; common_utils.py:188; Number of window handles: 2
INFO:2017-02-06 12:18:00,138; TCID_4196; common_utils.py:189; Number of window handles: [u'2147483651', u'2147483678']
INFO:2017-02-06 12:18:00,148; TCID_4196; common_utils.py:192; Number of window handles: 2
INFO:2017-02-06 12:18:00,148; TCID_4196; common_utils.py:193; Number of window handles: [u'2147483651', u'2147483678']
INFO:2017-02-06 12:18:00,176; TCID_4196; createClientProspect.py:1134; []
INFO:2017-02-06 12:18:08,177; TCID_4196; createClientProspect.py:1136; ++++++++++++++++++++++++++++++++++++++++++++++++++
INFO:2017-02-06 12:18:08,184; TCID_4196; createClientProspect.py:1137; 2147483678
INFO:2017-02-06 12:18:08,206; TCID_4196; createClientProspect.py:1138; []
INFO:2017-02-06 12:18:08,236; TCID_4196; actionBase.py:103; [FAIL] Failed to create a new Client Prospect
INFO:2017-02-06 12:18:08,236; TCID_4196; actionBase.py:114; Taking a snapshot with filename = screen10319120170206121808.jpg
INFO:2017-02-06 12:18:08,276; TCID_4196; createClientProspect.py:949; Traceback (most recent call last):
  File "C:\ProgramData\sift_client_selenium\developer\createClientProspect.py", line 931, in createNewClientProspect
    result = self.launchNewProfileWindowFirstNameLastName(firstName,lastName) and self.enterProspectDetails() \
  File "C:\ProgramData\sift_client_selenium\developer\createClientProspect.py", line 1139, in launchNewProfileWindowFirstNameLastName
    self.browser.switch_to_frame("WorkAreaFrame1popup")
  File "c:\python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 574, in switch_to_frame
    self._switch_to.frame(frame_reference)
  File "c:\python27\lib\site-packages\selenium\webdriver\remote\switch_to.py", line 85, in frame
    raise NoSuchFrameException(frame_reference)
NoSuchFrameException: Message: WorkAreaFrame1popup

Selenium 3.0.2 and Firefox 50.0.1 Still cannot work together? #3310

Meta - OS: FreeBSD 12-CURRENT Selenium Version: geckodriver 0.11.1 The source code of this program is available at https://github.com/mozilla/geckodriver. This

geckodriver 0.11.1

The source code of this program is available at
https://github.com/mozilla/geckodriver.

This program is subject to the terms of the Mozilla Public License 2.0.
You can obtain a copy of the license at https://mozilla.org/MPL/2.0/.
[email protected]:~/bin % pip list | grep selenium
selenium (3.0.2)
d = webdriver.Firefox()
>>> caps = DesiredCapabilities.FIREFOX
>>> caps["marionette"] = True
>>> caps["binary"] = "/usr/home/blubee/bin/firefox"
>>> d = webdriver.Firefox(capabilities = caps)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/blubee/.local/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py", line 150, in __init__
    keep_alive=True)
  File "/home/blubee/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/home/blubee/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 179, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
  File "/home/blubee/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "/home/blubee/.local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
from marionette_driver.marionette import Marionette
from subprocess32 import call, Popen, PIPE
from random import randint
import os, signal, time

def create_marionette_dir():
    port_number = randint(1000,65535)
    folder_name = "marionette_%d"%(port_number)
    folder_path = "/tmp/%s/"%(folder_name)

    success = False

    while True:
        if success:
            break

        if not os.path.exists(folder_path):
            os.makedirs(folder_path)
            success = True
        else:
            continue

    return port_number, folder_name, folder_path

def create_marionette_instance():
    proc_port, folder, path = create_marionette_dir()


    marionette_prefs_path = path+"/prefs.js"
    marionette_prefs_enabled = "user_pref(\"marionette.defaultPrefs.is_enabled\", true);"
    marionette_prefs_port = "user_pref(\"marionette.defaultPrefs.port\", %d);"%(proc_port)
    profile_path = '-profile \"%s\"'%(path)


    with open(marionette_prefs_path, "w") as of:
        of.write(marionette_prefs_enabled)
        of.write("\n")
        of.write(marionette_prefs_port)
    of.close

    nette = Popen(["firefox -marionette -profile \"/tmp/marionette_%d/\" -new-instance"%(proc_port)], stdout=PIPE, stderr=PIPE, shell=True)
    print(nette.pid)
    # stdout, stderr = nette.communicate()
    # print(stdout, stderr)

    client = Marionette("localhost", port=proc_port)
    client.start_session()
    client.switch_to_window(client.window_handles[-1])
    client.close()
    client.switch_to_window(client.window_handles[0])
    return client, nette.pid


if __name__ == "__main__":
    driver, pid = create_marionette_instance()

    driver.navigate("http://google.com")
    sb = driver.find_element("name", "q")
    sb.clear()
    sb.send_keys("this is not a test\n")

    time.sleep(3)
    os.kill(pid, signal.SIGTERM)

Selenium 3.0.1+ Firefox 50.0 would sometimes have connection refused #399

As issue here SeleniumHQ/selenium#3201 selenium guys said The connection refused would be happening when trying to communicate with GeckoDriver. A trace level log from geckodriver showing the issue; A minimal HTML file (or files) that can be used to reproduce the issue; A Selenium code snippet that can be run as is to reproduce the issues

request = <SubRequest 'driver' for <Function 'test_app_rs_edit_port'>>
driver_class = <class 'selenium.webdriver.firefox.webdriver.WebDriver'>
driver_kwargs = {'firefox_profile': <selenium.webdriver.firefox.firefox_profile.FirefoxProfile object at 0x2603c10>}

    @pytest.yield_fixture
    def driver(request, driver_class, driver_kwargs):
        """Returns a WebDriver instance based on options and capabilities"""
>       driver = driver_class(**driver_kwargs)

/usr/lib/python2.7/site-packages/pytest_selenium/pytest_selenium.py:107: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py:145: in __init__
    keep_alive=True)
/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:92: in __init__
    self.start_session(desired_capabilities, browser_profile)
/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:179: in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:236: in execute
    self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x273fad0>
response = {'status': 500, 'value': '{"error":"unknown error","message":"connection refused"}'}

    def check_response(self, response):
        """
            Checks that a JSON response from the WebDriver does not have an error.
    
            :Args:
             - response - The JSON response from the WebDriver server as a dictionary
               object.
    
            :Raises: If the response contains an error message.
            """
        status = response.get('status', None)
        if status is None or status == ErrorCode.SUCCESS:
            return
    
        value = None
        message = response.get("message", "")
        screen = response.get("screen", "")
        stacktrace = None
        if isinstance(status, int):
            value_json = response.get('value', None)
            if value_json and isinstance(value_json, basestring):
                import json
                try:
                    value = json.loads(value_json)
                    status = value.get('error', None)
                    if status is None:
                        status = value["status"]
                        message = value["value"]
                        if not isinstance(message, basestring):
                            value = message
                            try:
                                message = message['message']
                            except TypeError:
                                message = None
                    else:
                        message = value.get('message', None)
                except ValueError:
                    pass
    
        exception_class = ErrorInResponseException
        if status in ErrorCode.NO_SUCH_ELEMENT:
            exception_class = NoSuchElementException
        elif status in ErrorCode.NO_SUCH_FRAME:
            exception_class = NoSuchFrameException
        elif status in ErrorCode.NO_SUCH_WINDOW:
            exception_class = NoSuchWindowException
        elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
            exception_class = StaleElementReferenceException
        elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
            exception_class = ElementNotVisibleException
        elif status in ErrorCode.INVALID_ELEMENT_STATE:
            exception_class = InvalidElementStateException
        elif status in ErrorCode.INVALID_SELECTOR \
                or status in ErrorCode.INVALID_XPATH_SELECTOR \
                or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
            exception_class = InvalidSelectorException
        elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
            exception_class = ElementNotSelectableException
        elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
            exception_class = WebDriverException
        elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
            exception_class = WebDriverException
        elif status in ErrorCode.TIMEOUT:
            exception_class = TimeoutException
        elif status in ErrorCode.SCRIPT_TIMEOUT:
            exception_class = TimeoutException
        elif status in ErrorCode.UNKNOWN_ERROR:
            exception_class = WebDriverException
        elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
            exception_class = UnexpectedAlertPresentException
        elif status in ErrorCode.NO_ALERT_OPEN:
            exception_class = NoAlertPresentException
        elif status in ErrorCode.IME_NOT_AVAILABLE:
            exception_class = ImeNotAvailableException
        elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
            exception_class = ImeActivationFailedException
        elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
            exception_class = MoveTargetOutOfBoundsException
        else:
            exception_class = WebDriverException
        if value == '' or value is None:
            value = response['value']
        if isinstance(value, basestring):
            if exception_class == ErrorInResponseException:
                raise exception_class(response, value)
            raise exception_class(value)
        if message == "" and 'message' in value:
            message = value['message']
    
        screen = None
        if 'screen' in value:
            screen = value['screen']
    
        stacktrace = None
        if 'stackTrace' in value and value['stackTrace']:
            stacktrace = []
            try:
                for frame in value['stackTrace']:
                    line = self._value_or_default(frame, 'lineNumber', '')
                    file = self._value_or_default(frame, 'fileName', '<anonymous>')
                    if line:
                        file = "%s:%s" % (file, line)
                    meth = self._value_or_default(frame, 'methodName', '<anonymous>')
                    if 'className' in frame:
                        meth = "%s.%s" % (frame['className'], meth)
                    msg = "    at %s (%s)"
                    msg = msg % (meth, file)
                    stacktrace.append(msg)
            except TypeError:
                pass
        if exception_class == ErrorInResponseException:
            raise exception_class(response, message)
        elif exception_class == UnexpectedAlertPresentException and 'alert' in value:
            raise exception_class(message, screen, stacktrace, value['alert'].get('text'))
>       raise exception_class(message, screen, stacktrace)
E       WebDriverException: Message: connection refused

/usr/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py:192: WebDriverException

1481771416951	addons.manager	DEBUG	Provider finished startup: PluginProvider
1481771416951	addons.manager	DEBUG	Completed startup sequence
1481771417136	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 85"  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 85"  data: no]
[email protected]://marionette/content/server.js:85:19
[email protected]://gre/components/marionettecomponent.js:218:5
[email protected]://gre/components/marionettecomponent.js:142:7

Selenium 3.0.1+ Firefox 50.0 would sometimes have connection refused #380

Browser Version: Firefox 50.0 e.g.: 50.0.2623.87 (64-bit) Expected Behavio If you are having an issue with GeckoDriver starting up, please make sure that your client bindings support using it. Meta - OS: CentOS 7.2 e.g.: Windows 10?

request = <SubRequest 'driver' for <Function 'test_app_rs_edit_port'>>
driver_class = <class 'selenium.webdriver.firefox.webdriver.WebDriver'>
driver_kwargs = {'firefox_profile': <selenium.webdriver.firefox.firefox_profile.FirefoxProfile object at 0x2603c10>}

    @pytest.yield_fixture
    def driver(request, driver_class, driver_kwargs):
        """Returns a WebDriver instance based on options and capabilities"""
>       driver = driver_class(**driver_kwargs)

/usr/lib/python2.7/site-packages/pytest_selenium/pytest_selenium.py:107: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py:145: in __init__
    keep_alive=True)
/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:92: in __init__
    self.start_session(desired_capabilities, browser_profile)
/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:179: in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:236: in execute
    self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x273fad0>
response = {'status': 500, 'value': '{"error":"unknown error","message":"connection refused"}'}

    def check_response(self, response):
        """
            Checks that a JSON response from the WebDriver does not have an error.
    
            :Args:
             - response - The JSON response from the WebDriver server as a dictionary
               object.
    
            :Raises: If the response contains an error message.
            """
        status = response.get('status', None)
        if status is None or status == ErrorCode.SUCCESS:
            return
    
        value = None
        message = response.get("message", "")
        screen = response.get("screen", "")
        stacktrace = None
        if isinstance(status, int):
            value_json = response.get('value', None)
            if value_json and isinstance(value_json, basestring):
                import json
                try:
                    value = json.loads(value_json)
                    status = value.get('error', None)
                    if status is None:
                        status = value["status"]
                        message = value["value"]
                        if not isinstance(message, basestring):
                            value = message
                            try:
                                message = message['message']
                            except TypeError:
                                message = None
                    else:
                        message = value.get('message', None)
                except ValueError:
                    pass
    
        exception_class = ErrorInResponseException
        if status in ErrorCode.NO_SUCH_ELEMENT:
            exception_class = NoSuchElementException
        elif status in ErrorCode.NO_SUCH_FRAME:
            exception_class = NoSuchFrameException
        elif status in ErrorCode.NO_SUCH_WINDOW:
            exception_class = NoSuchWindowException
        elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
            exception_class = StaleElementReferenceException
        elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
            exception_class = ElementNotVisibleException
        elif status in ErrorCode.INVALID_ELEMENT_STATE:
            exception_class = InvalidElementStateException
        elif status in ErrorCode.INVALID_SELECTOR \
                or status in ErrorCode.INVALID_XPATH_SELECTOR \
                or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
            exception_class = InvalidSelectorException
        elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
            exception_class = ElementNotSelectableException
        elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
            exception_class = WebDriverException
        elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
            exception_class = WebDriverException
        elif status in ErrorCode.TIMEOUT:
            exception_class = TimeoutException
        elif status in ErrorCode.SCRIPT_TIMEOUT:
            exception_class = TimeoutException
        elif status in ErrorCode.UNKNOWN_ERROR:
            exception_class = WebDriverException
        elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
            exception_class = UnexpectedAlertPresentException
        elif status in ErrorCode.NO_ALERT_OPEN:
            exception_class = NoAlertPresentException
        elif status in ErrorCode.IME_NOT_AVAILABLE:
            exception_class = ImeNotAvailableException
        elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
            exception_class = ImeActivationFailedException
        elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
            exception_class = MoveTargetOutOfBoundsException
        else:
            exception_class = WebDriverException
        if value == '' or value is None:
            value = response['value']
        if isinstance(value, basestring):
            if exception_class == ErrorInResponseException:
                raise exception_class(response, value)
            raise exception_class(value)
        if message == "" and 'message' in value:
            message = value['message']
    
        screen = None
        if 'screen' in value:
            screen = value['screen']
    
        stacktrace = None
        if 'stackTrace' in value and value['stackTrace']:
            stacktrace = []
            try:
                for frame in value['stackTrace']:
                    line = self._value_or_default(frame, 'lineNumber', '')
                    file = self._value_or_default(frame, 'fileName', '<anonymous>')
                    if line:
                        file = "%s:%s" % (file, line)
                    meth = self._value_or_default(frame, 'methodName', '<anonymous>')
                    if 'className' in frame:
                        meth = "%s.%s" % (frame['className'], meth)
                    msg = "    at %s (%s)"
                    msg = msg % (meth, file)
                    stacktrace.append(msg)
            except TypeError:
                pass
        if exception_class == ErrorInResponseException:
            raise exception_class(response, message)
        elif exception_class == UnexpectedAlertPresentException and 'alert' in value:
            raise exception_class(message, screen, stacktrace, value['alert'].get('text'))
>       raise exception_class(message, screen, stacktrace)
E       WebDriverException: Message: connection refused

/usr/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py:192: WebDriverException

1481771416951	addons.manager	DEBUG	Provider finished startup: PluginProvider
1481771416951	addons.manager	DEBUG	Completed startup sequence
1481771417136	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 85"  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 85"  data: no]
[email protected]://marionette/content/server.js:85:19
[email protected]://gre/components/marionettecomponent.js:218:5
[email protected]://gre/components/marionettecomponent.js:142:7

Selenium 3.0.1+ Firefox 50.0 test would have connection refused #432

As issue here SeleniumHQ/selenium#3201 selenium guys said The connection refused would be happening when trying to communicate with GeckoDriver. A trace level log from geckodriver showing the issue; A minimal HTML file (or files) that can be used to reproduce the issue; A Selenium code snippet that can be run as is to reproduce the issues

request = <SubRequest 'driver' for <Function 'test_app_rs_edit_port'>>
driver_class = <class 'selenium.webdriver.firefox.webdriver.WebDriver'>
driver_kwargs = {'firefox_profile': <selenium.webdriver.firefox.firefox_profile.FirefoxProfile object at 0x2603c10>}

    @pytest.yield_fixture
    def driver(request, driver_class, driver_kwargs):
        """Returns a WebDriver instance based on options and capabilities"""
>       driver = driver_class(**driver_kwargs)

/usr/lib/python2.7/site-packages/pytest_selenium/pytest_selenium.py:107: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python2.7/site-packages/selenium/webdriver/firefox/webdriver.py:145: in __init__
    keep_alive=True)
/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:92: in __init__
    self.start_session(desired_capabilities, browser_profile)
/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:179: in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
/usr/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py:236: in execute
    self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x273fad0>
response = {'status': 500, 'value': '{"error":"unknown error","message":"connection refused"}'}

    def check_response(self, response):
        """
            Checks that a JSON response from the WebDriver does not have an error.
    
            :Args:
             - response - The JSON response from the WebDriver server as a dictionary
               object.
    
            :Raises: If the response contains an error message.
            """
        status = response.get('status', None)
        if status is None or status == ErrorCode.SUCCESS:
            return
    
        value = None
        message = response.get("message", "")
        screen = response.get("screen", "")
        stacktrace = None
        if isinstance(status, int):
            value_json = response.get('value', None)
            if value_json and isinstance(value_json, basestring):
                import json
                try:
                    value = json.loads(value_json)
                    status = value.get('error', None)
                    if status is None:
                        status = value["status"]
                        message = value["value"]
                        if not isinstance(message, basestring):
                            value = message
                            try:
                                message = message['message']
                            except TypeError:
                                message = None
                    else:
                        message = value.get('message', None)
                except ValueError:
                    pass
    
        exception_class = ErrorInResponseException
        if status in ErrorCode.NO_SUCH_ELEMENT:
            exception_class = NoSuchElementException
        elif status in ErrorCode.NO_SUCH_FRAME:
            exception_class = NoSuchFrameException
        elif status in ErrorCode.NO_SUCH_WINDOW:
            exception_class = NoSuchWindowException
        elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
            exception_class = StaleElementReferenceException
        elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
            exception_class = ElementNotVisibleException
        elif status in ErrorCode.INVALID_ELEMENT_STATE:
            exception_class = InvalidElementStateException
        elif status in ErrorCode.INVALID_SELECTOR \
                or status in ErrorCode.INVALID_XPATH_SELECTOR \
                or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
            exception_class = InvalidSelectorException
        elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
            exception_class = ElementNotSelectableException
        elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
            exception_class = WebDriverException
        elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
            exception_class = WebDriverException
        elif status in ErrorCode.TIMEOUT:
            exception_class = TimeoutException
        elif status in ErrorCode.SCRIPT_TIMEOUT:
            exception_class = TimeoutException
        elif status in ErrorCode.UNKNOWN_ERROR:
            exception_class = WebDriverException
        elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
            exception_class = UnexpectedAlertPresentException
        elif status in ErrorCode.NO_ALERT_OPEN:
            exception_class = NoAlertPresentException
        elif status in ErrorCode.IME_NOT_AVAILABLE:
            exception_class = ImeNotAvailableException
        elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
            exception_class = ImeActivationFailedException
        elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
            exception_class = MoveTargetOutOfBoundsException
        else:
            exception_class = WebDriverException
        if value == '' or value is None:
            value = response['value']
        if isinstance(value, basestring):
            if exception_class == ErrorInResponseException:
                raise exception_class(response, value)
            raise exception_class(value)
        if message == "" and 'message' in value:
            message = value['message']
    
        screen = None
        if 'screen' in value:
            screen = value['screen']
    
        stacktrace = None
        if 'stackTrace' in value and value['stackTrace']:
            stacktrace = []
            try:
                for frame in value['stackTrace']:
                    line = self._value_or_default(frame, 'lineNumber', '')
                    file = self._value_or_default(frame, 'fileName', '<anonymous>')
                    if line:
                        file = "%s:%s" % (file, line)
                    meth = self._value_or_default(frame, 'methodName', '<anonymous>')
                    if 'className' in frame:
                        meth = "%s.%s" % (frame['className'], meth)
                    msg = "    at %s (%s)"
                    msg = msg % (meth, file)
                    stacktrace.append(msg)
            except TypeError:
                pass
        if exception_class == ErrorInResponseException:
            raise exception_class(response, message)
        elif exception_class == UnexpectedAlertPresentException and 'alert' in value:
            raise exception_class(message, screen, stacktrace, value['alert'].get('text'))
>       raise exception_class(message, screen, stacktrace)
E       WebDriverException: Message: connection refused

/usr/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py:192: WebDriverException

1480494227580	addons.manager	DEBUG	Provider finished startup: GMPProvider
1480494227580	addons.manager	DEBUG	Starting provider: PluginProvider
1480494227580	addons.manager	DEBUG	Registering shutdown blocker for PluginProvider
1480494227581	addons.manager	DEBUG	Provider finished startup: PluginProvider
1480494227581	addons.manager	DEBUG	Completed startup sequence
1480494227805	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 85"  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 85"  data: no]
[email protected]://marionette/content/server.js:85:19
[email protected]://gre/components/marionettecomponent.js:218:5
[email protected]://gre/components/marionettecomponent.js:142:7

Which version of Firefox is compatible with selenium

Before Selenium3, Firefox used to be the default browser for Selenium. But after Selenium3, by using GeckoDriver explicitly, we can initialize the script in FireFox. FireFox was fully supported only in previous versions i.e. v47 and earlier. Selenium WebDriver version 2.53 is not compatible with Mozilla FireFox version 47.0+.

public class FirefoxTest {
   @Test
   public void startFfBrowser() {
      WebDriver driver = new FirefoxDriver();
      driver.get("http://www.tutorialspoint.com");
   }
}
public class FirefoxTest {
   @Test
   public void startFfBrowser () {
      System.setProperty("webdriver.gecko.driver",Path of your GeckoDriver.exe file);
      FirefoxDriver driver = new FirefoxDriver();
      driver.get("http://www.tutorialspoint.com");
   }
}

Selenium Easy

The above code is verified with selenium-server-standalone-3.0.0-beta2 and Firefox 48 version. Please let me know if you have any issues. In your Maven project, just add / update the following selenium dependency to your pom.xml:

System.setProperty("webdriver.gecko.driver","path of geckodriver.exe");
WebDriver driver = new FirefoxDriver();
System.setProperty("webdriver.gecko.driver", "/Users/username/Downloads/geckodriver");
WebDriver driver = new FirefoxDriver();
java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
	at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
	at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
	at org.openqa.selenium.firefox.GeckoDriverService.access$100(GeckoDriverService.java:38)
	at org.openqa.selenium.firefox.GeckoDriverService$Builder.findDefaultExecutable(GeckoDriverService.java:91)
	at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
	at org.openqa.selenium.firefox.FirefoxDriver.createCommandExecutor(FirefoxDriver.java:245)
	at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:220)
	at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:215)
	at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:211)
	at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:124)
package com.test;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

public class ExampleThree {
	
	String driverPath = "<path to gecko driver executable>";
	public WebDriver driver;
	
	@Test
	public void launchBrowser() {
		System.out.println("launching firefox browser"); 
		System.setProperty("webdriver.gecko.driver", driverPath+"geckodriver.exe");
		driver = new FirefoxDriver();
	}

	@Test
	public void openApplication() {
		driver.navigate().to("http://www.google.com");
	}
	
	@Test
	public void closeDriver() {
		if(driver!=null) {
			driver.close();
		}
	}
}
System.setProperty("webdriver.gecko.driver", driverPath+"geckodriver.exe");
DesiredCapabilities capabilities=DesiredCapabilities.firefox();
capabilities.setCapability("marionette", true);
WebDriver driver = new FirefoxDriver(capabilities);
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.0.0-beta2</version>
    </dependency>  
Sep 1, 2016 3:07:19 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end

Previous PostNext Post

Related code examples