用于 Gradle 测试的 Selenide 远程浏览器配置

问题描述

我正在准备我的项目,以便能够在 Bitbucket + Jenkins 下启动。 我需要使用远程 Selenium 服务器(如 Selenoid)运行 Selenide 解决方

如果我在 TestBase 类中对配置进行基本设置,例如:

    public void beforetest(){    
        Configuration.remote = "http://localhost:4444/wd/hub";     
    }

它可以工作,但仅在从 IntelliJ IDEA 运行时才有效,而不是从控制台运行。

如果我运行 Gradle test,它将在本地启动 - 而不是在网格/selenoid 上。

我尝试将该属性添加gradle.properties 文件中,例如: systemProp.selenide.remote=http://localhost:4444/wd/hub 但这不起作用。

与 build.gradle 文件相同。我尝试了很多选择:

systemProperty("selenide.remote","http://localhost:4444/wd/hub")
systemProperties['selenide.remote'] = 'http://localhost:4444/wd/hub'
System.setProperty("selenide.remote","http://localhost:4444/wd/hub")

所有这些都不适合我。

我使用了从控制台添加到 Gradle 的属性

gradle clean test -Dselenide.remote=http://localhost:4444/wd/hub

仍然没有按预期工作...... :(

您对什么可能出错有什么想法吗? 什么是正确的解决方案?

解决方法

工作解决方案是:

systemProperty("selenide.remote","http://0.0.0.0:4444/wd/hub")

IntelliJ IDEA 可能存在其他问题。几次重启后+无效/重启选项,这工作正常。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...