0

Safari 版本:11.0.2 MAC 版本:10.12.6 Mac OS Sierra selenium-java 版本:3.5.3 语言:JAVA

每当我在 Safari 驱动程序上运行硒测试时,它在运行几个步骤后就会挂起(找不到特定的模式)。在 IOS/Safari、Android/Chrome、MAC/Chrome 上运行相同的测试文件。

工作正常,您在调试/逐步运行测试。Safari 没有响应的原因可能是什么?

4

2 回答 2

0

这是模拟问题的代码。Safari 挂起,无法点击“继续购物”

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);
}
于 2017-12-22T18:05:44.050 回答
0

即使主题已死,我也遇到了类似的问题,解决方案是设置

"设置为 "从不"后关闭显示

在“Apple”>“首选项”>“节能器”中 在此处输入图像描述

于 2019-11-06T08:49:13.647 回答