WebDriver wait is not waiting for given condition for Safari.

I have script to login to a site and then waiting for home button to get loaded. I have put fluentwait and ExplicitWait to wait for element to be visible. But WebDriver is not waiting and failing immediately as the home button is not loaded.

I have tried with fluentwait and webdriverwait but none of them are working.

Here is code I am trying.

By usernameInput = By.name("User”); 
By passwordInput = By.name("Password”);
By loginButton = By.xpath("//input[@value='Sign In']”);
String URL = “https://demotest.mytest.com/"
WebDriver driver = new SafariDriver();
driver.get(URL); driver.manage().window().maximize();
setText(usernameInput,”User1");
setText(passwordInput,”User1");
clickOnElement(loginButton);
WebDriverWait wait = new WebDriverWait(driver, 15, 100);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@title='Home']")));

Throws below error -

org.openqa.selenium.WebDriverException:

Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'

System info: host: 'cnparmar-mac', ip: '10.168.104.60', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '1.8.0_211'

Driver info: org.openqa.selenium.safari.SafariDriver

Capabilities {acceptInsecureCerts: false, browserName: Safari, browserVersion: 12.1.1, javascriptEnabled: true, platform: MAC, platformName: MAC, safari:automaticInspection: false, safari:automaticProfiling: false, safari:diagnose: false, setWindowRect: true, strictFileInteractability: false, webkit:WebRTC: {DisableICECandidateFiltering: false, DisableInsecureMediaCapture: false}}

Session ID: 1257BF8B-335E-4E80-8B08-CB15A77AD648

*** Element info: {Using=xpath, value=//div[@title='Home']}

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructo rAccessorImpl.java:62)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingCo nstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException( W3CHttpResponseCodec.java:187)

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpRes ponseCodec.java:122)

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpRes ponseCodec.java:49)

at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExec utor.java:158)

at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(Drive rCommandExecutor.java:83)

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.jav a:552)

at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver .java:323)

at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWe bDriver.java:428)

at org.openqa.selenium.By$ByXPath.findElement(By.java:353)

at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver .java:315)

at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedCond itions.java:205)

at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedCond itions.java:201)

at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:249)

at sample.Sample.loginAs(Sample.java:64)

at sample.Sample.test1(Sample.java:28)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.j ava:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccess orImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:498)

at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocati onHelper.java:124)

at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)

at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)

at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:989)

at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorke r.java:125)

at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)

at org.testng.TestRunner.privateRun(TestRunner.java:648)

at org.testng.TestRunner.run(TestRunner.java:505)

at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)

at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)

at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)

at org.testng.SuiteRunner.run(SuiteRunner.java:364)

at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)

at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)

at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)

at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)

at org.testng.TestNG.runSuites(TestNG.java:1049)

at org.testng.TestNG.run(TestNG.java:1017)

at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)

at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)

at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

Ideally it should wait for Home button to get visible. but it is failing. This works on Chrome,Firefox, IE, Edge on Windows but only failing for Safari on mac.
Anyone has any idea why this is happening?

Replies

I'd recommend you try again with Safari Technology Preview or a beta of macOS Catalina. The code to find and click on things has been rewritten and many bugs like this should be addressed.


If that doesn't work, please file a bug. See the safaridriver(1) man page for more information on what to include in the bug report.