Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

Short answer: Selenium opens HTTP and HTTPS addresses in the same way: create a WebDriver, call driver.get(url), inspect the page, and finish with driver.quit(). PhantomJS should not be your new default. Selenium’s 3.8.1 Python changelog states, “PhantomJS is now deprecated, please use either Chrome or Firefox in headless mode,” and the PhantomJS repository is archived read-only. For a maintained Python 3 setup, use a supported browser such as Chrome or Firefox in headless mode.

What happened to PhantomJS?

PhantomJS was a headless browser that older Selenium examples used because it could run without a visible desktop window. That historical code still appears in tutorials, but it is not a sensible starting point for a new project. The Selenium 3.8.1 Python changelog explicitly says: “PhantomJS is now deprecated, please use either Chrome or Firefox in headless mode.” The PhantomJS source repository was archived on May 30, 2023, so fixes and compatibility work should not be expected.

You may still need to understand PhantomJS when maintaining an inherited test suite. Treat it as a migration target: identify what the old script does, reproduce the behavior in a supported browser, and remove the PhantomJS dependency. Do not describe PhantomJS as a currently supported Selenium browser.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prerequisites for a current Python 3 Selenium setup

  • Python: Current Selenium Python documentation lists Python 3.10 or newer. Check the release documentation for the exact support range when you publish or deploy.
  • A browser: Chrome, Edge, Firefox, Safari, WebKitGTK, and WPEWebKit are listed by the current Python documentation. Headless operation is available for the browsers that support it.
  • An isolated environment: A virtual environment prevents Selenium and related packages from colliding with other projects.
  • Network access during setup: Selenium Manager can discover, download, and cache a matching driver, but a locked-down build machine may need an approved installation process.

Create and activate a virtual environment

On macOS or Linux:

python3 -m venv .venv
. .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -U selenium

On Windows PowerShell:

py -3 -m venv .venv
..venvScriptsActivate.ps1
python -m pip install --upgrade pip
python -m pip install -U selenium

Pin the Selenium version after checking the current release that your organization supports. Avoid copying an old PhantomJS tutorial’s package pins into a new project.

Open an HTTP or HTTPS URL with Selenium

HTTP and HTTPS are URL schemes passed to the same navigation method. There is no separate Selenium API for each scheme. The browser performs the network connection, redirects, rendering, and certificate checks.

Modern headless Chrome example

This complete script navigates to an HTTPS page, prints the resulting title and URL, and always closes the browser:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options


def main() -> None:
    options = Options()
    options.add_argument("--headless")
    options.add_argument("--window-size=1365,900")

    driver = webdriver.Chrome(options=options)
    try:
        driver.get("https://example.com")
        print("title:", driver.title)
        print("url:", driver.current_url)
    finally:
        driver.quit()


if __name__ == "__main__":
    main()

To open an HTTP destination, change only the URL:

driver.get("http://example.com")

The same get call also follows normal browser redirects. If an HTTP site redirects to HTTPS, inspect driver.current_url to see the final address.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Firefox headless variant

from selenium import webdriver
from selenium.webdriver.firefox.options import Options

options = Options()
options.add_argument("-headless")

driver = webdriver.Firefox(options=options)
try:
    driver.get("https://example.com")
    print(driver.title)
finally:
    driver.quit()

Choose the engine that matches the browser your users run. Fidelity to the production engine is usually more useful than preserving a PhantomJS-specific setup.

How HTTPS certificate handling really works

Selenium instructs the browser; it does not implement TLS itself. Certificate validation, protocol negotiation, mixed-content rules, proxy behavior, and interstitial warnings belong to the selected browser and its configuration.

  • A valid public certificate should load normally.
  • An expired, self-signed, hostname-mismatched, or otherwise invalid certificate may produce a browser warning page rather than the application you expected.
  • A successful driver.get() call does not prove that the page is safe or that certificate validation was bypassed; inspect the resulting page and URL.

Do not disable certificate checks as a routine workaround. If an isolated test intentionally uses an invalid certificate, configure the selected browser only for that test and consult its current official options. Keep such settings out of production automation, because accepting invalid certificates can hide deployment and security failures.

Selenium Manager versus manual drivers

Current Selenium documentation says Selenium Manager generally discovers, downloads, and caches the browser driver when you create a WebDriver. That is why the examples can use webdriver.Chrome() or webdriver.Firefox() without a hard-coded executable path.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Older guides often tell you to download a driver manually and pass its path. That remains useful when your company controls browser binaries centrally, outbound downloads are blocked, or a reproducible build requires an explicitly provisioned driver. It is a legacy-style workflow, not a requirement for every current installation.

When an explicit driver path is appropriate

  • The browser is installed in a non-standard location.
  • A CI image is built without Internet access and receives drivers from an internal artifact store.
  • You must pin a tested browser/driver pair for a regulated or highly reproducible environment.
  • Your platform policy prevents Selenium Manager from downloading binaries.

Pass the path using the browser’s current Selenium service class rather than copying an obsolete constructor from a PhantomJS tutorial. Keep the browser and driver versions aligned according to the browser and Selenium documentation you are using.

What old PhantomJS code looked like—and how to replace it

Legacy scripts commonly created a PhantomJS driver, called get, read a title or page source, and quit. The useful part of that flow is independent of PhantomJS:

  1. Create a WebDriver for a supported browser.
  2. Configure headless mode when a visible window is unnecessary.
  3. Call driver.get("http://…") or driver.get("https://…").
  4. Wait for the page state your test needs, then inspect elements, text, screenshots, or source.
  5. Run driver.quit() in a finally block.

Replace PhantomJS-only assumptions—such as its old JavaScript engine, rendering quirks, or command-line flags—with behavior supported by the browser you select. A test that passes in PhantomJS is not automatically equivalent to one that passes in Chromium or Firefox; re-check selectors, timing, fonts, downloads, and security behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choosing a replacement browser

Decision factor Chrome/Chromium Firefox Other Selenium-listed browsers
Historical Selenium recommendation Named as a headless replacement in the Selenium 3.8.1 changelog Named as a headless replacement in the Selenium 3.8.1 changelog Not named in that historical sentence
Current Python documentation Listed Listed Edge, Safari, WebKitGTK, and WPEWebKit are also listed
Best first question Does your production site use Chromium behavior? Does your production site use Firefox behavior? Is the target browser available and supported in your deployment environment?
Driver setup Selenium Manager can generally manage the driver Selenium Manager can generally manage the driver Verify current Manager and browser support for that platform
Headless use Use the browser’s current headless option Use the browser’s current headless option Follow the selected browser’s current Selenium guidance

There is no universal “PhantomJS replacement” independent of your compatibility target. Match the browser engine used in production, confirm it can run in your CI or container, and test the exact Selenium and browser versions you deploy.

Waiting, screenshots, and page state

A navigation call returns after the browser considers the document loaded according to its normal page-load strategy; client-side applications may still be rendering. For dynamic pages, wait for a meaningful element rather than inserting an arbitrary long sleep.

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

# after driver.get(...)
main = WebDriverWait(driver, 20).until(
    EC.visibility_of_element_located((By.CSS_SELECTOR, "main"))
)
print(main.text)

Use an explicit wait for a selector, text, or state that represents readiness. This reduces flaky tests and avoids assuming that HTTP response completion equals application readiness.

Troubleshooting common failures

“Unable to obtain driver” or Selenium Manager cannot download

Cause: The machine cannot reach the download service, a proxy blocks the request, or the browser installation is not discoverable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix: Confirm the browser is installed, check proxy and firewall policy, and provide a centrally installed driver when downloads are prohibited. Keep the driver compatible with the browser version.

Browser binary not found

Cause: The browser is absent, installed in a custom location, or unavailable inside the container.

Fix: Install the supported browser in the runtime image or configure its documented binary location. Verify the same user and environment that runs the Python process.

SessionNotCreatedException or version mismatch

Cause: The browser updated while the driver stayed older, or a manually supplied driver targets another browser version.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix: Record browser, driver, Selenium, Python, and operating-system versions. Let Selenium Manager resolve the pair where policy permits, or update the pinned pair together.

Permission denied, sandbox, or CI startup errors

Cause: The service account cannot execute the browser, write its profile/cache, or access required system resources.

Fix: Check executable and profile-directory permissions, use a writable temporary profile, and apply only the security settings required by your CI image. Do not copy random PhantomJS flags into a modern browser.

HTTPS warning page instead of the application

Cause: The certificate is invalid, the hostname does not match, a proxy is intercepting TLS, or the browser reached a security interstitial.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Fix: Inspect the browser’s resulting URL and page text, correct the certificate or proxy configuration, and reserve any certificate-acceptance option for an explicitly isolated test.

HTTP page unexpectedly becomes HTTPS

Cause: The server, redirect policy, or browser security policy upgrades the request.

Fix: Read driver.current_url, inspect response behavior outside the browser if needed, and test the final scheme your application actually serves.

Performance and reliability practices

  • Reuse a driver for a related sequence of pages, but quit it promptly when the job ends.
  • Use headless mode in CI and set a deliberate window size so responsive breakpoints are predictable.
  • Prefer explicit waits tied to application state over fixed sleeps.
  • Capture browser and driver versions in CI logs so failures can be reproduced.
  • Give navigation and waits finite timeouts; an unreachable host should fail a job rather than consume workers indefinitely.
  • Use a clean profile for isolation, especially when cookies, extensions, or cached service-worker data can affect results.
  • Test both HTTP and HTTPS when redirects, mixed content, authentication, or certificate handling are part of the requirement.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is a clean image or PDF rather than interactive browser control, ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns PNG, JPEG, WebP, or PDF output. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Only clean shots are billed. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.

See the ScreenshotNeo API documentation for the complete parameter list. This one-call example captures Stripe as WebP:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo includes full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets plus custom viewports, retina scale, PDF paper sizes and page ranges, HTML/CSS-to-image, custom CSS and JavaScript, click-before-capture, selector hiding, selector/delay/network-idle waits, request and resource blocking, custom headers/cookies/user agents and Authorization, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed links, asynchronous jobs with signed webhooks, bulk capture of up to 100 URLs per call, a usage API, an OpenAPI specification, and compatibility with parameter names used by other screenshot APIs.

The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; yearly billing gives two months free, and every feature is on every plan. Create a free ScreenshotNeo account to start without a card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

FAQ

Can Selenium still launch PhantomJS?

Older Selenium and PhantomJS combinations may run in a preserved environment, but the project is archived and Selenium deprecated it. Use that only to understand or temporarily maintain legacy code while migrating.

Does an HTTPS URL require a different Selenium method?

No. Pass the HTTPS address to driver.get just as you pass an HTTP address. The browser, not Selenium’s navigation API, handles TLS.

Should I use Chrome or Firefox for a migration?

Start with the engine that matches your production browser and deployment image. Both were named by Selenium’s historical deprecation guidance, and both are listed in current Python documentation.

Is a screenshot API a replacement for Selenium tests?

No. Selenium remains appropriate when you must interact with controls, assert application behavior, or exercise a user journey. An API is simpler when the deliverable is a rendered screenshot or PDF.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Frequently Asked Questions

What Python version should a new Selenium project target?

The current Selenium Python documentation lists Python 3.10 and newer; verify the supported range against the release you install.

Why does my HTTP test show an HTTPS URL afterward?

The server or an intermediary may redirect or upgrade the request. Read driver.current_url and test the final URL your application intends to serve.

The Bottom Line

Use Selenium’s supported Chrome or Firefox headless modes for new Python 3 automation. Keep the navigation code identical for HTTP and HTTPS, let Selenium Manager handle drivers where policy allows, and treat PhantomJS as legacy code to migrate rather than a current solution.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.