selenium icon indicating copy to clipboard operation
selenium copied to clipboard

Class cast exception in RemoteLocationContext.location()

Open AJ-72 opened this issue 8 years ago • 2 comments

Meta -

OS:
Windows 8.1, 10 Selenium Version:
3.2 Browser:
Chrome Browser Version:
62

Expected Behavior -

org.openqa.selenium.remote.html5.RemoteLocation.location() should provide the physical location of the browser.

Actual Behavior -

org.openqa.selenium.remote.html5.RemoteLocation.location() throws class cast exception - java.lang.Long cannot be cast to java.lang.Double

Steps to reproduce -

public static void main(String args[]) throws MalformedURLException {
		RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"),DesiredCapabilities.chrome());
		LocationContext lContext = (LocationContext)new Augmenter().augment(driver);
		Double latitude,longitude;
		latitude=43.1231;
		longitude=4.234;
		lContext.setLocation(new Location(latitude, longitude, 2));
		System.out.println(lContext.location().getLatitude());				
	}

Changing the class member variables in Location class from Double to Long should fix the issue, I think. I can provide a PR if that should be enough.

AJ-72 avatar Jul 18 '18 04:07 AJ-72

@AJ-72,@barancev I've tested the changes by placing the selenium jar which was generated by the build as external dependency, have raised a PR for the same. The change is supposed to be in RemoteLocationContext.java. You can use the demo file for reference to see it working. Please let me know if you see any issues. Thanks, Santhosh

Output: Starting ChromeDriver 2.40.565498 (ea082db3280dd6843ebfb08a625e3eb905c4f5ab) on port 25919 Only local connections are allowed. Aug 20, 2018 5:49:54 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS Aug 20, 2018 5:49:54 PM org.openqa.selenium.remote.Augmenter extractRemoteWebDriver WARNING: Augmenter should be applied to the instances of @Augmentable classes or previously augmented instances only (instance class was: class org.openqa.selenium.chrome.ChromeDriver) 43.1231

seleniumdemo.zip

santhoshprem29 avatar Aug 20 '18 13:08 santhoshprem29

Fixed by 8e308c57954f94692171d4381035bab8c872c5a4

barancev avatar Sep 04 '18 19:09 barancev