我们可以把正则表达式放在 seleniumServerJar 的 export.config 的量角器中吗?

Can we put regex in seleniumServerJar of exports.config of protractor

本文关键字:config export 量角器 seleniumServerJar 正则表达式 我们      更新时间:2023-09-26

Selenium服务器独立jar版本不断更新,webdriver-manager update命令选择最新的jar。每次硒罐更新时,我都需要在 export.config 中更改硒服务器罐。

有什么方法可以放一些正则表达式吗?

喜欢这个:-

seleniumServerJar: "../node_modules/protractor/selenium/selenium-server-standalone-*.jar",

简短的回答 - 不,你不能。根据量角器配置解析器的实现,seleniumServerJar属性仅接受string作为其值。这是其实现的链接。如您所见,在typeof - seleniumServerJar 的值string之前,量角器不会解析 jar 文件的路径。如果该值是未解析为目录中特定路径的字符串,则量角器将引发错误。

编辑:即使您不提供optional seleniumServerJar路径,量角器测试也会运行,因为如果您将 jar 文件存储在默认位置以外的其他位置,则可以提供该属性。此处的默认位置是安装量角器的路径或配置文件的相对路径。这意味着无论您是在本地还是全局安装量角器,硒服务器jar量角器都会执行您的脚本。

希望对您有所帮助。

正如另一个答案所提到的,如果您只是从配置文件中删除seleniumServerJar,它将查找protractor/selenium文件夹中的 jar 文件,这是webdriver-manager update下载到的位置。然后,当您升级量角器时,您不必担心在配置文件中增加版本,因为webdriver-managerprotractor/config.json获取版本号。

相关源文档: Priority 1) if directConnect is true, use that 2) if seleniumAddress is given, use that 3) if a Sauce Labs account is given, use that 4) if a seleniumServerJar is specified, use that 5) try to find the seleniumServerJar in protractor/selenium