SeleniumHQ/selenium

Safari element.getLocation throws a nullPointerException

techanon opened this issue · 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.

burg commented

This has been fixed in Safari Technology Preview 69.

@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?

burg commented

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.

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

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

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

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

        /* 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;
        }

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,