Error: `org.openqa.selenium.html5.LocationContext` not found when running Appium 9.5.0 tests

Error: org.openqa.selenium.html5.LocationContext not found when running Appium 9.5.0 tests

I’ve been running Appium tests using the Appium Java Client 9.5.0, and everything was compiling fine until recently. Suddenly, I started getting this error:

error: cannot find symbol
import org.openqa.selenium.html5.LocationContext;
                           ^
  symbol:   class LocationContext
  location: package org.openqa.selenium.html5

The same setup worked perfectly a week ago — no dependency or version changes. My pom.xml already includes io.appium:java-client:9.5.0, testng, and slf4j, but I haven’t explicitly added Selenium dependencies since the Appium client normally brings them in.

Now the build fails saying LocationContext cannot be found. Has org.openqa.selenium.html5.LocationContext been removed or relocated in recent Selenium updates?

Do I now need to explicitly add a compatible Selenium dependency to fix this, or is there a version conflict with Appium 9.5.0?

I ran into the exact same issue after updating some transitive dependencies.

The class **org.openqa.selenium.html5.LocationContext** was removed in Selenium 4.17.0+, and Appium 9.5.0 still references it indirectly in some older parts of the client.

What fixed it for me was locking the Selenium version to something stable:

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-java</artifactId>
  <version>4.16.1</version>
</dependency>

Once I added this explicitly to the pom.xml, the Appium tests compiled again without touching the Appium client version.

Looks like Appium hasn’t fully aligned with the latest Selenium internal package refactors yet.

I faced this recently too, turns out the problem wasn’t Appium itself but a transitive Selenium upgrade pulled in by another library.

The LocationContext interface got deprecated and eventually dropped in newer Selenium releases.

Appium 9.5.0 still expects it.

You can confirm this by running:

mvn dependency:tree | grep selenium

If you see a Selenium version higher than 4.16.1, that’s your culprit.

Just force Appium to use Selenium 4.16.1 (or lower) via dependencyManagement, and the issue disappears.

Yes, org.openqa.selenium.html5.LocationContext was removed in recent Selenium versions as part of the HTML5 refactor.

Appium 9.5.0’s Java client wasn’t yet updated to reflect that change.

You have two clean options:

  1. Pin Selenium to 4.16.1 manually to restore compatibility.

  2. Upgrade to Appium 9.6+ (when released), it’ll likely align with Selenium 4.18+ and fix this dependency mismatch.

For now, I’d go with option 1 since it’s safer and backward-compatible with your existing tests.