1月23日 selenium 4.8的正式版本发布了,

We’re very happy to announce the release of Selenium 4.8.0 for Java, .NET, Ruby, Python, and Javascript as well as the Grid and Internet Explorer Driver. Links to everything can be found on our downloads page.

一些改动如下

  • Chrome DevTools support is now: v107, v108, and v109 (Firefox still uses v85 for all versions)
  • Large JS executions have the name as a comment to help understand what payload being sent to/from server/driver.
  • Deprecation of headless convenience method. Read more about in the headless blog post.
  • Ruby overhauls Options classes (again)
  • Initial BiDi support in JavaScript, Ruby, and improvements in Java.
  • We’re continuing to remove Legacy Protocol classes in Java and Grid.
  • Accommodate ability to specify sub-paths in Grid.
  • Plus various language specific bug fixes; see the full list of changes in the Changelogs

简单翻译一下

  • 现在Chrome DevTools支持:v107、v108和v109(Firefox仍然使用v85的所有版本)
  • 大型JS的执行有名称作为注释,以帮助理解被发送到/来自服务器/驱动程序的有效payload。
  • 废弃启动headless浏览器的简便方法。
  • Ruby大修了Options类(再次)。
  • 在JavaScript、Ruby中初步支持BiDi,并在Java中进行了改进。
  • 我们正在继续删除Java和Grid中的遗留协议类。
  • 适应grid中指定子路径的能力。
  • 加上各种特定语言的bug修复;请看Changelogs中的完整变化列表

值得注意的变化

headless启动方式变了,因为headless有2个版本,新版本和旧版本,一般来说新版本比旧版本要好,不过默认的headless启动的是老版本,简单起见就去掉了对于旧版本直接启动的支持。用代码来说话就直观多了。

之前的启动driver方式

//之前的启动方式
options = ChromeOptions()
options.headless = True
driver = webdriver.Chrome(options=options)
driver.get('http://selenium.dev')
driver.quit()

新的启动方式

ChromeOptions options = new ChromeOptions();
options.addArguments("--headless=new");
WebDriver driver = new ChromeDriver(options);
driver.get("https://selenium.dev);
driver.quit();

新增了一些原始的对BIDI的支持。

关于BIDI,项目主页是这么说的

WebDriver BiDi is a proposed bidirectional protocol for browser automation, building on and extending WebDriver

看起来像是新一代的双向协议,之前的webdriver协议主要是客户端向driver端发请求,driver给出回应就好了,跟访问网页服务器给出响应差不多,就像是答记者问;新的协议更像是聊天,客户端跟浏览器直接唠嗑,是对之前场景的扩展,因为是双向的所以应该有长链接,对于性能和稳定性以及实时性上估计会有显著提升。

不过现在bidi还是处于非常早期阶段,se也只是开始进行支持,什么时候可以正式发布这点还不得而知。

其他的更新就是一些代码重构,比如ruby语言的Option类重构,做减法,比如去掉之前的一些旧的协议支持,再就是日常更新,支持更新的devtool和永远不会缺席的bugfix。

总结

总的来说这次的更新对于selenium的终端用户来说变化不大,大家可以放心升级。