selenium 4 что нового
Selenium 4 Beta 1 Released
Categories:
This has been the culmination of a lot of work by so many people, not only the project TLC, but also of literally hundreds of people: 205 since we released Selenium 3.141.59, at the last count. A big thank you to everybody who’s helped make this possible!
So, what’s changed since Selenium 3? The answer is both “not much” and also “almost everything”.
By “not much”, I mean that if your tests are working with Selenium 3 right now, you should be able to just upgrade your dependency to Selenium 4. You will find that things that were marked “deprecated” are now gone, but the advantage of the long time between the last Selenium 3 release and this is that you’ve had plenty of time to try and find alternatives.
If this doesn’t work, please let us know! We’ve worked hard to ensure compatibility between the releases, but it’s possible we may have missed some things.
One thing you may want to do to get ready for the update (which you can do before updating the dependency itself!) is to update the drivers you need. In particular, please update geckodriver to 0.29.0 or later.
By “almost everything”, I mean that under the covers there have been substantial changes. We’ve rewritten the Selenium server to allow it to work not only in the familiar “standalone” and “hub and node” modes, but also in a new “distributed” mode, which makes it signifcantly easier to deploy to something such as Kubernetes in a way that scales well.
The new server is also wired up with support for OpenTelemetry and exposes a GraphQL endpoint, so that figuring what’s going on in the Grid, and tracking down what’s gone wrong if something happens, is easier than ever.
Not all the changes are server-side. We recently wrote about the new features in Selenium 4 that you can use in your tests, but some of the main highlights are:
We’ll be telling you more about these features in later blog posts, and as we improve our documentation.
If this sounds interesting, please download the beta from your favourite package manager (maven, nuget, npm, pip, or the gem), or directly from the Selenium site.
Announcing Selenium 4
If you’re already a Selenium user, this update should be as easy as just changing your dependency from 3.x to 4.0.0. We’ve worked hard to ensure that this is a “drop-in” upgrade, having focused on keeping the public APIs as stable as possible.
Of course, we’ve made changes, so if you relied on code that was marked as internal to Selenium, or that was deprecated, you might experience some hiccups. Please check our documentation for advice on how to deal with each of the common problems we’re aware of.
But there’s more to Selenium 4 than just being a stable release of what was there before! It brings a whole host of new and exciting features that we hope will make your tests more fun to write, and more stable when you run them. Let’s take a look at some of them!
We’ve introduced “relative locators”. These allow you to specify where on the page an element can be found using language that people use too; things like “above that element”, or “to the right of this other element”. This will hopefully provide you all with a tool to fight against incredibly complex locators, making your tests read a little more clearly, and being more resilient to changes in the page’s DOM. We’re not the first ones to come up with this idea – that honour belongs to Sahi – but if you’ve not used them before, we hope you like them!
If you’re using Firefox or a browser that is derived from Chromium, we’ve added a slew of new capabilities too. These include ways of handling “basic” and “digest” authentication, Network Interception (Are you an HTTP 418?), and also performing commonly requested tasks, like waiting for a change in the DOM, or providing a way to look at Javascript errors.
We’ve added these new features in a way that fits in with our existing APIs. There’s no need to rewrite your tests: just use the new features when it feels right to you.
We have also rebuilt the Selenium Grid, taking lessons from successful projects such as Zalenium and Selenoid to enhance the capabilities. This new Grid runs just as well as a single process, running on a single machine, as it does in the traditional “hub and node” configuration, but it also supports a fully-distributed mode, for use in modern infrastructure running Kubernetes. It has better security baked-in, because we know that securing a Grid can be a difficult task. And at all of these scales and sizes, all the new features we’ve added to the language bindings will work as expected.
The Grid can also manage Docker containers on your local machine, pulling images such as the standalone firefox server so your infrastructure maintenance becomes just a little bit less taxing.
Finally, the Grid is easier to manage. We’ve revamped the UI, placing it on top of a GraphQL model that anyone is free to query and make use of to create their own visualisations or monitors of the Grid. If you’d like to peek into a running session, there are live VNC previews you can open and interact with, providing even better insight into what’s been going on. And if you want even more information, we’ve integrated support for OpenTelemetry into the Grid, so now you can find out exactly what’s happening, where, and when.
I know it’s a cliche to say that it’s a “very great pleasure”, but, being honest with you, it genuinely is. Working on this new version of Selenium has been a chance to work with some amazing engineers, and to be part of a vibrant and energetic community. It’s been a lot of fun to write this code, with these people, and it feels right to say “thank you” to as many of them as possible here. So, without waiting any longer….
We would like to thank all of our users who have helped Selenium be successful over the years. Without you we wouldn’t be where we are today. We would also like to thank all the contributors who have submitted Pull Requests, your contributions make Selenium better. For everyone who’s taken the time to file an issue, and to let us know where there’s been a problem: thank you. We only have a chance to improve when we know that there’s something that needs work!
And finally, thank you to all the Selenium Committers, BrowserStack, Sauce Labs, and our Selenium-Level sponsors for getting this release ready for our users.
We hope you enjoy Selenium 4, and we can’t wait to see what you do with it!
New Tricks in Selenium 4
Categories:
In the third post in his series, Simon Stewart continues talking about what’s coming in Selenium 4 and reviews some of the tricks in the new release.
In my last posts, we talked about how to contribute to Selenium, and why we’re bumping the version number to 4. That’s enough preamble! Today, we’ll cover some details about the new tricks and capabilities that Selenium 4 offers.
Finding Elements, and Relative Locators
You know, finding elements on a page can be really difficult. I’ve seen loads of people using very complicated XPATH expressions, and trying to figure out complex CSS selectors and things like that. There have been whole talks about the subject at SeleniumConf. Surely there must be a better way to do this?
Think about how we describe where an element is on the page. Think about how you’d do this over the phone. You’d never talk about the raw DOM, “Ah, find the fifth DIV element nested inside the SPAN with an ‘id’ of ‘foo’”. You’d just never say that! Instead, you’d say something like, “just find that thing above that image, and to the right of that link,” when talking about where things are located on the page.
A long time ago, a project called Sahi started to locate elements like this. Sahi had Relation APIs, which are a lovely way of finding elements, and it was very, very fluent and pleasant to use. When I was starting WebDriver years ago, I was talking with Narayan (creator of Sahi) and I promised him that I was going to hold off implementing this flagship feature of Sahi. It was something that was lovely, but it was also something Sahi was rightly proud of. However, there are now other tools, such as Tyco, that are implementing this style of API, so it seems like the time is right to do the same in Selenium. In Selenium 4 we call them “relative locators.” You may sometimes see us refer to them as “friendly locators,” since the initial implementation called them that, but “relative” better describes how they work. We have a handful of them: near, above, below, left of, right of. They allow you to talk in human language about where an element is on a page.
Looking at the future, we are also planning to enable users to add new types of locators, not only on the, on the client side, but also to the Selenium Server. For example, although JS UI frameworks come and go (anyone else remember using jquery?), it’d be nice to be able to add a custom locator for the current tools people like, such as React.
Authenticating to Web Sites
One feature that people have been asking for since we started the project has been the ability to authenticate to a web site. Previously, you could do this by crafting the URL the browser went to properly, but this leaks credentials to any man-in-the-middle and leaves them in server logs, so browsers have slowly removed this piece of functionality. That’s unfortunate, since it’s something that we know people frequently need to do in their tests. In Selenium 4, we now offer a mechanism to register a username and password that can be used to authenticate against these sites.
Intercepting Network Traffic
A common complaint of Selenium tests is that they’re slow and flaky. While the bindings to the browser are excellent, and fully described by the W3C WebDriver spec, it is true that any end-to-end test is likely to suffer more flakiness than a simple unit test—there are just more moving parts, and more possibilities for things to go wrong.
One way to resolve this issue is to stub out the backend of the application, intercepting network traffic in the test and returning pre-canned responses. Tools such as mountebank make this easy for API testing. Wouldn’t it be nice if there was a similar tool for Selenium?
With Selenium 4, we now provide a mechanism to do this, using the NetworkInterceptor (well, that’s what we call it in the Java bindings). Pass it your WebDriver instance, and it’ll be called every time the browser is about to make an HTTP request, allowing you to return almost anything you want
The Chrome Debugging Protocol
As I mentioned previously, one of the nice things about Selenium 4 is our work to ensure a stable and modern user-facing API. What does this mean? To start, we need to acknowledge that after a long time there’s now competition back in the browser automation space. Notably in the form of Puppeteer and Cypress, and taking a step back, what do they offer? They build upon the Chrome DevTools Protocol (CDP)>, which is a protocol developed to enable a debugger inside Chromium-based browsers.
Because of what it was designed to do, it is a chatty protocol, and not a user-facing API that allows you to introspect into the browser. Worse, introduce a network hop between the test and the browser, this chattiness leads to slower tests as the network latency increases. That is why tools such as Puppeteer want you to run on the local machine. That’s great for the speed of an individual test, but makes parallelisation harder, as you can’t use services such as Sauce Labs easily.
To complicate matters, because the CDP is designed as a debugging protocol, it can change with no notice between versions. That’s why Puppeteer and Cypress are tied to specific versions of browsers, and that causes a dilemma for you as a test author: how do you test on multiple versions of a browser? Updating the test API to get a different browser can lead to you no longer making valid API calls. Not doing so ties you to a potentially outdated version of a browser.
Despite this, using the CDP opens up a host of possibilities, and that’s why we’ve added support for it in Selenium 4. In fact, some of our new features are built on top of it (though we hide the details!)
But we’ve also gone further that just adding basic support. Selenium 4 can support multiple versions of the CDP at the same time, meaning you can test with both the current and beta versions of Chromium-based browsers without needing to rewrite tests. We do this by providing an “idealised CDP”, which is stable and covers the features we feel tests need. If that idealised view of the world isn’t enough for you, we also expose the raw CDP APIs too, giving you flexibility to choose what’s best for your tests.
We’re feeding this experience into the new W3C WebDriver Bidi specification, which is helping make that a better fit for testers.
I am leaving out of this post all the details related to another important trick in Selenium 4, the new Selenium Grid, which I will cover in the next post. Stay tuned!
Что должен знать каждый QA-инженер о Selenium 4?
Привет, друзья. Май богат новыми курсами, и прямо сейчас, в преддверии запуска курса «Java QA Engineer», мы продолжаем публиковать полезный материал для QA-специалистов.
Вернемся в август 2018 года, когда сообщество тестировщиков потрясла новость о том, что Саймон Стюарт, один из основателей Selenium, официально утвердил дату релиза и афишировал некоторые основные обновления Selenium 4 на Selenium Conference в Бангалоре. Четвертая версия всеми любимого фреймворка для автоматизации веб-тестирования должна была быть выпущена к рождеству 2018 года.
Дата релиза Selenium 4
Те, кто уже знаком с историей релиза Selenium 3, который тоже должен был случиться к рождеству, предполагали, что новая версия будет закончена к рождеству, но скорее всего не 2018 года. Ровно также, как это произошло с предыдущей версией, которая была выпущена на три года позже официально объявленной даты.
И они были правы! На сегодняшний день (даже с обновленной информацией о выпуске Selenium 4 в феврале 2019 года), официального релиза все еще не было.
Также не поступало какой-то официальной информации о новых датах выпуска со стороны основателей проекта. Однако как мы видим на официальной странице проекта SeleniumHQ на Github, разработчики закрыли только половину задач, которые было необходимо сделать, поэтому справедливо можно предположить, что официального релиза не случится до рождества 2019 года.
В чем важность Selenium 4?
Если вы считаете, что инженеры по автоматизации тестирования – единственные люди в мире, которые должны заботиться о выходе обновления Selenium, вы ошибаетесь. Конечно же, Selenium стал отраслевым стандартом для проведения автоматизированного тестирования. Он считается первоочередным инструментом для тестирования веб-приложений уже слишком масштабных для проведения ручного тестирования.
Остается без внимания и то, что компании, которые в значительной степени полагаются на Selenium – не просто компании, кто имеют в своем штате QA-инженеров, но еще и те, кто пользуется интегрированными инструментами автоматизированного бескодового тестирования на базе того же Selenium. Тестирование без кода на базе Selenium стало настоящим спасением для компаний, которые осознают необходимость в автоматизации, но не имеют в своем штате QA-экспертов, которые могли бы с этим разобраться. Такие инструменты не только делают возможным развертывание для тех, кто имеет базовое представление о веб-браузерах, но и позволяют запускать регрессионные тесты, выполнять синтетический мониторинг и нагрузочное тестирование без каких-либо знаний фреймворка Selenium.
Основные изменения в Selenium 4
Теперь давайте перейдем к списку вещей, которые SeleniumHQ обещали добавить или изменить в следующей версии.
Стандартизация WebDriver W3C
Во-первых, Selenium 4 WebDriver будет полностью стандартизирован W3C. API WebDriver стало актуальным и за пределами Selenium и теперь используется в различных инструментах для автоматизации. Например, на нем основываются такие мобильные инструменты для тестирования, как Appium и iOS Driver. Стандарт W3C также отвечает за совместимость между различными программными приложениями с WebDriver API.
Вот как Selenium Grid взаимодействует с исполняемыми файлами драйверов на данный момент:
Тест в Selenium 3.x взаимодействует с браузером в конечном узле (end node) по протоколу JSON wire в локальной конечной точке (local end). Такой подход требует кодирования и декодирования запросов API.
Судя по обновлениям, которые мы ожидаем увидеть в Selenium 4, тест будет взаимодействовать напрямую без кодирования и декодирования запросов API через протокол W3C. Несмотря на это, в привязке к Java все еще будет обратная совместимость, но в центре внимания будет протокол консорциума W3C. А вот протокол JSON wire использоваться больше не будет.
Над спецификациями W3C WebDriver работают несколько разработчиков, и весь процесс вы можете увидеть на GitHub.
Selenium 4 IDE TNG
Selenium IDE поддерживает Chrome «из коробки». Как известно, Selenium IDE – это инструмент записи и воспроизведения. Теперь он будет доступен со следующим, более богатым и продвинутым функционалом:
Улучшенный Selenium Grid
Каждый, кто когда-либо работал с Selenium Grid знает как сложно его настраивать. Selenium Grid поддерживает выполнение тестов в разных браузерах, операционных системах и машинах, обеспечивающих параллельное выполнение.
В Selenium Grid есть два основных элемента: Hub и Node.
Хаб (hub) работает как сервер, центральный пункт управления всеми тестируемыми машинами в сети. В Selenium Grid всего один хаб, который выделяет определенный узел на выполнение теста в соответствии с его потенциалом.
Узел (node), простыми словами, — тестируемая машина, на которой запущены тесты.
Чтобы узнать больше, советуем вам прочитать полное официальное руководство по Selenium Grid.
До настоящего времени процесс присоединения узла к хабу в Selenium Grid вызывал у тестировщиков серьезные сложности.
В Selenium 4 работа с Grid обещает быть простой, так как больше не будет необходимости настраивать и запускать хабы и узлы отдельно. После запуска сервера Selenium, Grid будет работать одновременно как узел и как хаб.
Selenium 4 будет поставляться с более стабильной версией Selenium Grid. Будут устранены ошибки потокобезопасности и улучшена поддержка Docker.
Улучшенный пользовательский интерфейс Selenium Grid
Еще одним приоритетом в разработке Selenium 4, который был выделен во время официального анонсирования, оказалось создание более удобного пользовательского интерфейса Selenium Grid, который будет отражать всю соответствующую информацию о сессиях, мощности и т.д.
Улучшенная наблюдаемость (observability)
“Пассивная наблюдаемость – это способность делать описательную трассировку»
— Саймон Стюарт
Наблюдаемость, логи и отладка больше не ограничиваются DevOps. В рамках грядущего релиза, трассировка запросов и запись логов с хуками (hooks) будут улучшены, чтобы обеспечить для инженеров по автоматизации возможность отладки.
Документация играет ключевую роль в успехе любого проекта. Документация Selenium не обновлялась с выпуска Selenium 2.0. Это значит, что каждый, кто пытался изучить Selenium в последние несколько лет, пользовался старыми туториалами.
Таким образом, естественно, обновленная и современная документация, которую SeleniumHQ обещает предоставить нам вместе с версией 4.0, стала одним из самых ожидаемых обновлений Selenium в сообществе автоматизации тестирования.
Тем не менее, вы все еще можете получить доступ ко всей существующей документации Selenium.
Selenium 4 в двух словах
Здесь перечислены все основные изменения, которые мы, вероятно, увидим, когда наконец состоится релиз Selenium 4. Если вам интересно узнать больше об истории фреймворка, ее основателях и новых функциях Selenium, мы предлагаем посмотреть это видео с конференции Selenium 2018 года, где был анонсирован релиз.
Пишите комментарии и записывайтесь на день открытых дверей, который пройдет уже 22 мая. До встречи в ОТУС!
What’s New In Selenium 4?
(Editor’s Note: This post has been recently updated for accuracy and completeness. It was originally published in June 2020 by Manoj Kumar.)
There are a lot of cool and new things that just arrived in Selenium 4. If you haven’t heard, the official Selenium 4 release came out yesterday, and we’re excited by all the latest updates. We’ve got a full review of this long-awaited release ready for you, but first here’s a quick refresher on a few of the most interesting updates for Selenium 4.
What’s New in Selenium 4?
After an extensive alpha and beta period to get everything right, Selenium 4 has now been officially released!
🎉🎉 Selenium 4.0 is here! 🎉🎉
Read all about in our blog post:https://t.co/E8ntH7OdaB
We hope you enjoy Selenium 4, and we can’t wait to see what you do with it!#selenium4
In the new release, there have been changes made to the highly anticipated feature, Relative Locators, where the returned elements are now sorted by proximity to make the results more deterministic. By proximity, it means being sorted based on the distance from the midpoints of each element’s bounding client rect. Also new is the ability to use any selector (not just tagname) to find any relative locators.
Also in this release, work for NetworkInterceptor has begun. This functionality, once complete, will be a part of the new ChromeDevTools feature and will allow testers to stub out responses to network requests!
A Refresher: Getting Started with Selenium 4
Here are a few links outlining how you can get started with Selenium 4:
Watch Simon Stewart Break Down the Selenium 4 Updates
Although Selenium 4 is designed as a drop-in replacement for Selenium 3, it has some new tricks to help make your life as a tester easier. These include things like “relative locators,” and new support for intercepting network traffic, changes in how you can create a new Selenium instance, and more! Catch Selenium project lead Simon Stewart as he explains how these new features work, and also demonstrates how to use them. Learn how to take advantage of all that Selenium 4 can offer your tests!
What is your plan to move to Selenium 4.0? If you do not plan to upgrade, why not? What is preventing you from upgrading now that the official release is out?
To recap everything that’s new in the latest version of Selenium, keep reading for a full review of the cool things that have arrived in Selenium 4:
What’s New in Selenium 4
Selenium 4 is now released!
A lot of developments have happened since Selenium 4 was announced during the State of the Union Keynote by Simon Stewart and Manoj Kumar. There has been a significant amount of work done and we’ve released at least six alpha versions and four betas of Selenium 4 for users to try out and report back with any potential bugs so that we can make it right. Now, the official release is here.
It is exciting times for the Selenium community as we have a lot of new features and enhancements that make Selenium WebDriver even more usable and scalable for practical use cases.
Selenium is a suite of tools designed to support different user groups:
Let us dive in and take a look at some of the significant features that were released in each of these tools and share some of the cool upcoming features that are now available in Selenium 4.
Selenium WebDriver
One of the main reasons to release WebDriver as a major version (Selenium 4) is because of the complete W3C protocol adoption. The W3C protocol dialect has been available since the 3.8 version of Selenium WebDriver along with the JSON wire protocol. This change in protocol isn’t going to impact the users in any way, as all major browser drivers (such as geckodriver and chromedriver), and many third party projects, have already fully adopted the W3C protocol.
However, there are some notable new APIs, as well as the removal of deprecated APIs in the WebDriver API, such as:
What’s next in WebDriver beyond Selenium 4?
It would be nice to have users extend the locator strategy like FindByImage or FindbyAI (like in Appium) – right now we have a hardcoded list of element location strategies. Providing a lightweight way of extending this set, particularly when using Selenium Grid, is on the roadmap.
Selenium IDE
The original Selenium IDE reached its end of life in August 2017, when Mozilla released Firefox 55, which switched its add-ons from the Mozilla-specific “XPI” format to the standardised “Web Extension” mechanism. This meant that the original Selenium IDE would no longer work in Firefox versions moving forwards.
Thanks to Applitools, Selenium IDE has been revived! It is one of the significant improvements in Selenium 4 and includes notable changes like:
What’s next in Selenium IDE?
A remarkable milestone for Selenium IDE is that it’s going to be available as a standalone app, re-written to be an Electron app. By binding tightly to the browser, this would allow us to listen out for events from the browser, making test recording more powerful and feature-rich.
Selenium Grid
One of the essential improvements in Selenium 4 is the ability to use Docker to spin up containers instead of users setting up heavy virtual machines. Selenium Grid has been redesigned so that users can deploy it on Kubernetes for excellent scaling and self-healing capabilities.
Let’s look at some of the significant improvements:
What’s next in Selenium Grid?
As you follow, there have been exciting changes and performance improvements. There are a few more that expected to be added like:
More Goodies
We’ve also refreshed our branding, documentation, and the website, so check out Selenium.dev!
Selenium is an Open-Source project, and we do this voluntarily so there are never definite timelines that can be promised, but thanks for sticking with us and we’re excited that the new release is now here.
Please come and give us a hand if you have the energy and time! Happy hacking!
Thanks Simon Stewart in helping review this post!
Manoj Kumar is a Principal Consultant at ThoughtWorks. Manoj is an avid open-source enthusiast and a committer to the Selenium & Appium project. And a member of the project leadership committee for Selenium. Manoj has also contributed to various libraries and frameworks in the automated testing ecosystem like ngWebDriver, Protractor and Serenity to name a few. An avid accessibility practitioner who loves to share knowledge and is a voluntary member of the W3C ACT-R group. In his free time, he contributes to Open-Source projects or research on Accessibility and enjoys spending time with his family. He blogs at AssertSelenium.
Supercharge Selenium with Applitools Visual AI