selenium icon indicating copy to clipboard operation
selenium copied to clipboard

Safari element.getLocation throws a nullPointerException

Open techanon opened this issue 8 years ago • 9 comments

Meta -

OS: MacOS High Sierra 10.13.6

Selenium Version: 3.141.0

Browser: Safari 12.0 (64bit)

Expected Behavior -

To be able to retrieve the location of a given element as a Point instance.

Actual Behavior -

NullPointerException thrown.

Steps to reproduce -

I attempt to call driver.findElement(By.cssSelector(customSelector)).getLocation() and it throws a null pointer exception in the getLocation() method, specifically on rawPoint.get("y").intValue();

There wasn't much of a stack trace, but here's what I had (app name redacted due to NDA):

java.lang.NullPointerException
	at org.openqa.selenium.remote.RemoteWebElement.getLocation(RemoteWebElement.java:340)
	at com.REDACTED.automation.HomePageSteps.verifyTheLocationOf(HomePageSteps.java:36)
	at ✽.And I verify the location of "headerElement"(/projects/REDACTED/src/test/resources/features/PrimarySmokeTest.feature:6)

Please let me know if there are any other steps I should take on my end.

techanon avatar Nov 08 '18 22:11 techanon

This has been fixed in Safari Technology Preview 69.

burg avatar Nov 14 '18 18:11 burg

@burg , are you a Safari developer? I reported the same issue more 2-3 weeks later and nobody reacted on it: https://bugreport.apple.com/web/?problemID=45451114

Is it possible to find you here or in slack next time and report directly to you?

KroArtem avatar Nov 15 '18 21:11 KroArtem

Yes, I maintain safaridriver. I don’t regularly look through Selenium issues but feel free to ping me if you would like to bring my attention to something.

BTW, I directly used your bug report to discover and fix the issue. However, we don’t do a great job notifying the originator when a bug has been fixed in Safari Technology Preview but not yet released as a system update.

burg avatar Nov 15 '18 22:11 burg

Ok, thanks for the info! I'll know whom to ping next time :)

KroArtem avatar Nov 19 '18 13:11 KroArtem

I confirm this issue is fixed at least in Safari Tech Preview 70.

KroArtem avatar Nov 19 '18 14:11 KroArtem

Closing the issue after the last comment. Thank you for the information!

barancev avatar Dec 10 '18 13:12 barancev

Hi! Is it possible to know when the fix will be integrated also in Safari (and not technology preview)? Many thanks

blanco2005 avatar Jan 04 '19 10:01 blanco2005

        /* Safari Hack */
        int x;
        int y;
        try
        {
            x = element.Location.X;
        }
        catch (Exception)
        {
            x = ((OpenQA.Selenium.Remote.RemoteWebElement)element).LocationOnScreenOnceScrolledIntoView.X;
        }
        try
        {
            y = element.Location.Y;
        }
        catch (Exception)
        {
            y = ((OpenQA.Selenium.Remote.RemoteWebElement)element).LocationOnScreenOnceScrolledIntoView.Y;
        }

AndreasKarz avatar Mar 26 '19 06:03 AndreasKarz

Hi,

I'm testing through Saucelabs and still have the issue with macOS 10.14 and Safari 12. Testing on a technology preview version is not possible.

When is the fix going to be released ?

Thanks,

dickmelancon avatar Jul 17 '19 19:07 dickmelancon