SeleniumHQ/selenium · error · Error::WebDriverError

cannot locate extension id in #{rdf_path}

Error message

cannot locate extension id in #{rdf_path}

What it means

Raised by Firefox::Extension#read_id_from_install_rdf (Error::WebDriverError) when an install.rdf exists but neither an <em:id> element/attribute in the Mozilla RDF namespace can be located. The extension id is required to name the installed extension directory. This indicates a malformed or legacy install.rdf missing the identifier.

Source

Thrown at rb/lib/selenium/webdriver/firefox/extension.rb:82

          read_id_from_install_rdf(directory) || read_id_from_manifest_json(directory)
        end

        def read_id_from_install_rdf(directory)
          rdf_path = File.join(directory, 'install.rdf')
          return unless File.exist?(rdf_path)

          doc = REXML::Document.new(File.read(rdf_path))
          namespace = doc.root.namespaces.key(NAMESPACE)

          if namespace
            id_node = REXML::XPath.first(doc, "//#{namespace}:id")
            return id_node.text if id_node

            attr_node = REXML::XPath.first(doc, "//@#{namespace}:id")
            return attr_node.value if attr_node
          end

          raise Error::WebDriverError, "cannot locate extension id in #{rdf_path}"
        end

        def read_id_from_manifest_json(directory)
          manifest_path = File.join(directory, 'manifest.json')
          return unless File.exist?(manifest_path)

          manifest = JSON.parse(File.read(manifest_path))
          applications_gecko_id(manifest) || name_and_version(manifest)
        end

        def applications_gecko_id(manifest)
          manifest.dig('applications', 'gecko', 'id')&.strip
        end

        def name_and_version(manifest)
          [manifest['name'].delete(' '), manifest['version']].join('@')
        end
      end # Extension

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Switch the extension to a WebExtension with a valid manifest.json (which read_id_from_manifest_json also supports).
  2. Repair install.rdf to include a proper <em:id>...</em:id> under the http://www.mozilla.org/2004/em-rdf# namespace.
  3. Re-download the addon from a trusted source in case of corruption.

Example fix

// before: install.rdf missing em:id
# <RDF><Description about="urn:mozilla:install-manifest"> ... </Description></RDF>

// after: add the em:id element with the namespace
# <RDF xmlns:em="http://www.mozilla.org/2004/em-rdf#">
#   <Description about="urn:mozilla:install-manifest">
#     <em:id>my-extension@example.com</em:id>
#     ...
#   </Description>
# </RDF>
Defensive patterns

Strategy: validation

Validate before calling

rdf = File.join(dir, 'install.rdf')
manifest = File.join(dir, 'manifest.json')
if File.exist?(manifest)
  profile.add_extension(path)  # WebExtension path
elsif File.exist?(rdf)
  doc = REXML::Document.new(File.read(rdf))
  ns = doc.root.namespaces.key('http://www.mozilla.org/2004/em-rdf#')
  raise 'install.rdf has no em:id' unless ns && REXML::XPath.first(doc, "//#{ns}:id")
  profile.add_extension(path)
else
  raise 'extension has neither manifest.json nor a valid install.rdf'
end

Prevention

When it happens

Trigger: Installing a Firefox extension whose install.rdf lacks the em-rdf namespace id element/attribute; a hand-edited or truncated install.rdf; an old extension format Selenium cannot parse.

Common situations: Legacy extensions with non-standard manifests; extensions generated by tooling that omits the id; corrupted rdf after a partial extraction.

Related errors


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/49bd9d6dfb2ab3eb. Report an issue: GitHub.