0

Safari Version: 11.0.2 MAC Version: 10.12.6 Mac OS Sierra selenium-java Version: 3.5.3 Language: JAVA

Whenever I am running a selenium test on Safari Driver it hangs after running few steps (could not find specific pattern). Same test run file on IOS/Safari, Android/Chrome, MAC/Chrome.

Works fine you run test in debug/step by step. What could be the reason Safari not responding?

Shiv
  • 11
  • 1
  • Your code trials and the relevant `HTML` please. – undetected Selenium Dec 21 '17 at 07:56
  • I would resurrect this old topic - have the same issue here, long Safari tests are passing when you have the VNC session open in remote machine or if you have screen connected, otherwise just hang until you open remote VNC screen. It is only happening after long time passed after you have the screen open (night tests in my case), so looks like some resource saving mode, even power saving is off. – Vladimir T Nov 04 '19 at 07:48

2 Answers2

0

Here is code to simulate the issue. Safari hangs and could not click 'Continue Shopping'

public static void main(String[] args) {
    SafariOptions safariOptions = new SafariOptions();
    safariOptions.setUseCleanSession(true);
    // safariOptions.setUseTechnologyPreview(true);
    DesiredCapabilities safariCapabilities = DesiredCapabilities.safari();
    safariCapabilities.setJavascriptEnabled(true);
    safariCapabilities.setAcceptInsecureCerts(true);
    safariCapabilities.setPlatform(Platform.MAC);
    safariCapabilities.setCapability("platformName", Platform.MAC);
    safariCapabilities.setVersion("11.2");
    safariCapabilities.setBrowserName("safari");
    safariCapabilities.setCapability(SafariOptions.CAPABILITY, safariOptions);
    WebDriver safariDriver = new SafariDriver(safariCapabilities);
    safariDriver.manage().window().maximize();
    safariDriver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

    safariDriver.get("https://www.shoppersstop.com/");
    waitFor(safariDriver, ExpectedConditions.elementToBeClickable(By.xpath("//a[@href='cart']")));
    safariDriver.findElement(By.xpath("//a[@href='cart']")).click();
    waitFor(safariDriver, ExpectedConditions.elementToBeClickable(By.xpath("//a[text()='Continue Shopping']")));
    safariDriver.findElement(By.xpath("//a[text()='Continue Shopping']")).click();
}

public static <T> T waitFor(WebDriver safariDriver, ExpectedCondition<T> condition) {
    return new FluentWait<WebDriver>(safariDriver).withTimeout(30, TimeUnit.SECONDS)
            .pollingEvery(500, TimeUnit.MILLISECONDS).until(condition);
}
Shiv
  • 11
  • 1
0

Even the subj is dead I had the similar issue and the solution was to set

"Turn off display after" setting to "Never"

in "Apple" > "Preferences" > "Energy Saver" enter image description here

Vladimir T
  • 340
  • 3
  • 8