Last week everything compiled and ran fine with Appium Java Client 9.5.0, but now I see this error:
error: cannot find symbol
import org.openqa.selenium.html5.LocationContext;
^
symbol: class LocationContext
location: package org.openqa.selenium.html5
In my pom.xml, I have:
io.appium
java-client
9.5.0
I did not explicitly add a Selenium dependency—only Appium’s client. The class org.openqa.selenium.html5.LocationContext used to be there. Has it been removed or moved in the newer Selenium/Appium versions? Do I need to add a specific Selenium version to fix this?
I’ve worked with Selenium/Appium upgrades for years now, and this one pops up quite often.
You’re seeing the “class file for org.openqa.selenium.html5.locationcontext not found” error simply because LocationContext was removed in Selenium 4. Appium Java Client 9.5.0 uses Selenium 4+, so that class no longer exists in the dependency chain.
It used to work only because older Appium versions relied on Selenium 3, where LocationContext was still part of the HTML5 APIs. Now that you’ve upgraded, the import has nowhere to resolve from hence the sudden failure.
Yep, I ran into the same headache during an upgrade last month.
Just to add on to what @ian-partridge mentioned the “class file for org.openqa.selenium.html5.locationcontext not found” error is expected once you’re on Appium 9.5.0. The fix depends on what you need:
-
Best option: Move away from LocationContext entirely and switch to Appium’s W3C geolocation APIs, which are the supported path moving forward.
-
Fallback option: If your project really depends on LocationContext, you’d need to downgrade back to Appium + Selenium 3, but that’s not ideal since Selenium 3 is effectively legacy now.
Jumping in I’ve handled mobile automation migrations recently, and there’s one more detail worth pointing out.
In Selenium 4, geolocation APIs were redesigned, so Appium exposes them differently now. Instead of depending on LocationContext (which triggers the “class file for org.openqa.selenium.html5.locationcontext not found” error), you can directly use:
driver.setLocation(new Location(latitude, longitude, altitude));
This works consistently across both Android and iOS and doesn’t rely on any deprecated packages. It’s the cleanest way to handle location mocking without pulling in outdated Selenium classes.