selenium - Selenide 中的 System.setProperty 和 Configuration.browser 有什么区别?

标签 selenium testing selenide

这是对原始讨论的引用:Link

关于在使用 Selenide 执行测试时如何更改浏览器,基本上有两个提议。

一个是:

System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
System.setProperty("selenide.browser", "Chrome");
open("http://google.com");

另一个是:

Configuration.browser = "chrome";
open("http://google.com");

两者似乎都在做同样的事情。有什么区别?

最佳答案

Paul Nelson Baker 原帖中的评论解释了这一点:

While this is true for a starting a general ChromeDriver, this is specifically asking for Selenide which wraps Selenium.

这意味着以下代码用于启动使用 Selenium 的驱动程序:

System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
System.setProperty("selenide.browser", "Chrome");
open("http://google.com");

虽然以下代码只能与 Selenide 一起使用:

Configuration.browser = "chrome";
open("http://google.com");

请注意,对于 Selenide,这两种方法都有效,因为 Selenide 是围绕 Selenium 构建的。


如果您需要更多信息,请查看 Selenide在 GitHub 上。

基本上,Selenide.open 执行对 SelenideDriver.open 的调用,其中创建了一个新的 StaticConfig 实例。 StaticConfig 类中是对静态字段browser 所在的调用。

关于selenium - Selenide 中的 System.setProperty 和 Configuration.browser 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58094130/

相关文章:

在 Idris 中测试证明是否可靠

python - 在 Selenium 中提取隐藏元素

python - 获取与 DOM 元素关联的事件列表

performance - 有人可以建议我如何测试或基准测试 apache Storm 吗?

testing - 使用 IBM Rational 对 "Finacle - Infosys"核心银行系统进行功能和性能测试

java - 过滤 ElementsCollection

selenium - Selenium Grid总是执行我的测试的多余实例

java - selenium:如果用户关闭浏览器或网络驱动程序怎么办?如何检测浏览器是否关闭?

java - 长时间运行的 Selenium 测试 - 浏览器死掉

JQuery 全局 isAnimating 检查与 Selenium 一起使用 (2)