What’s new in Selenium 4?

Selenium 4 Features

In this article, we will look at the new exciting features and improvements introduced in the latest version of Selenium WebDriver i.e. Selenium 4. Selenium WebDriver has now adopted W3C standard web driver protocol. So, instead of JSON Wire Protocol, native support of W3C standard is provided.

Let’s have a look at Features of Selenium 4

 1. Switching windows or tabs

Selenium 4 provides a new api NewWindow which creates a new tab or new window and automatically switches to it. Using this feature, a user can open a URL in a new tab along with the existing tab.

2. Minimize window

Minimizes the window of current browsing context. Minimize window hides the window in the system tray.

3. Relative locators

This feature help you locate elements that are nearby other elements.

  • Relative locators are as follows:
    • above
    • below
    • toLeftOf
    • toRightOf
    • near

findElement method now accepts a new method withTagName() which returns a RelativeLocator.

NOTE: Java bindings now support with(By) instead of withTagName() allowing users to pick locator of their choice like By.idBy.cssSelector etc. This feature landed in Selenium4 – beta3

Let us consider the below example for understanding the relative locators.

above()

This method returns the WebElement, which is present above to the specified element.

This method returns the WebElement, which is present below to the specified element.

below()

toLeftOf()

This method returns the WebElement, which is present to the left of specified element.

toRightOf()

This method returns the WebElement, which is present to the right of specified element.

near()

This method returns the WebElement, which is at most 50px away from specified element.

4. Optimized Selenium Grid

In selenium 4, a new architecture for selenium grid is introduced to remove issues which occurred during installation and configuration, also during the connection between the hub and node machine.

  • Node / Client:   It is used to execute tests on individual computer systems. There can be multiple nodes in a grid.
  • Hub / Server: It is the central point from where it controls all the machines present in the network. It contains only one hub which helps in allocating test execution to different nodes.     

However, in selenium 4, there is no need for a setup to start hub and nodes individually once the user starts the server, the Grid automatically works as both nodes and hub.

It also supports advanced tools like Azure, Docker, AWS etc.

5. Deprecation of Desired Capabilities

Desired capabilities were used in test automation scripts to specify the test environment such as browser name, version, operating system) for execution on the Selenium Grid.

In Selenium 4, capabilities objects are replaced with Options. Now we just need to create an Options object, set test requirements, and pass the object to the driver constructor.

In order to define browser specific capabilities, below are the Options objects:

  • Chrome : ChromeOptions
  • Internet Explorer : InternetExplorerOptions
  • Firefox : FirefoxOptions
  • Microsoft Edge : EdgeOptions
  • Safari : SafariOptions

6. Modifications in the Actions Class

To simulate input actions from mouse and keyboard on specific web elements, we used Actions class in selenium.

In Selenium 4, several new methods have been added in Actions class.

click(WebElement)

This newly added method in Actions class replaces moveToElement(onElement).click()

It is used to click on a certain web element.

clickAndHold(WebElement)

This newly added method in the Actions class replaces moveToElement(onElement).clickAndHold().

It is used to click on an element without releasing the click.

contextClick(WebElement)

This method will replace moveToElement(onElement).contextClick(). It will perform the right click operation.

doubleClick(WebElement)

This method is added to replace moveToElement(element).doubleClick(). It will perform a double click on an element.

release()

This method used for releasing the pressed mouse button was initially a part of org.openqa.selenium.interactions.ButtonReleaseAction class. Selenium 4 onwards has been moved to Actions class.

7. Selenium 4 IDE

New version of IDE is available with below features:

  • Browser support has been improved in the new version. Now with a new version, any browser vendor can easily plug into the latest Selenium IDE.
  • CLI Runner will be based on NodeJS, not the HTML-based runner, and it supports the parallel execution from which it provides the report with the total number of test cases passed/failed along with execution time taken.

8. Enhanced Documentation

The enhanced selenium documentation helps understand how new features in Selenium 4 can be used in real time automation testing. Selenium 4 documentation describes all the aspects of Selenium Grid 4, Selenium IDE, and WebDriver W3C protocol.

Is protractor going to get deprecated??

Protractor is an end-to-end test framework for Angular and AngularJS applications. Protractor is a Node.js program built on top of WebDriverJS.

The last big release was Protractor 7.0 in which there was just a security improvement and few dependencies were updated. Although they switched to recent NodeJS, no significant improvements, no new methods were added at all.

The Angular team plans to end development of Protractor at the end of 2022. Why?

What alternatives to Protractor do we have?

  • WebdriverIO: As of today, WebdriverIO is the best WebDriver implementation in JavaScript. It provides features like react selectors, shadow ‘dom’ support. Unlike Protractor, WebdriverIO receive constant updates, it has a very active community of developers.
  • Selenium WebDriver: Selenium is an umbrella project for a range of tools and libraries that enable and support the automation of web browsers. Learn more about Selenium WebDriver at Dezlearn’s Selenium WebDriver course.

75 thoughts on “What’s new in Selenium 4?”

  1. Good information. Lucky me I recently found your site by chance (stumbleupon). I have book marked it for later!

  2. karandeep singh

    Having read this I believed it was rather enlightening. I appreciate you spending some time and energy to put this short article together. I once again find myself spending a significant amount of time both reading and posting comments. But so what, it was still worthwhile!

  3. karandeep singh

    I’m amazed, I must say. Seldom do I come across a blog that’s both educative and interesting, and without a doubt, you have hit the nail on the head. The problem is something not enough folks are speaking intelligently about. Now i’m very happy I stumbled across this during my hunt for something concerning this.

  4. 웹툰 미리보기

    I’d like to thank you for the efforts you’ve put in penning this website. I really hope to see the same high-grade content by you in the future as well. In fact, your creative writing abilities has encouraged me to get my own blog now 😉

  5. 무료 다시보기

    Good web site you have got here.. It’s difficult to find high-quality writing like yours nowadays. I truly appreciate individuals like you! Take care!!

  6. 스포츠토토사이트

    Greetings! Very helpful advice within this article! It is the little changes which will make the most important changes. Thanks a lot for sharing!

  7. Arnaud Rebotini

    The very next time I read a blog, I hope that it won’t disappoint me as much as this one. After all, Yes, it was my choice to read, however I genuinely thought you’d have something useful to say. All I hear is a bunch of whining about something you can fix if you were not too busy looking for attention.

  8. Laurie Anderson

    Hi! I could have sworn I’ve been to your blog before but after browsing through a few of the posts I realized it’s new to me. Anyhow, I’m certainly pleased I found it and I’ll be bookmarking it and checking back frequently.

  9. 먹튀폴리스

    Hi, I do think this is a great blog. I stumbledupon it 😉 I’m going to return once again since i have book-marked it. Money and freedom is the best way to change, may you be rich and continue to help others.

  10. Howdy, I believe your site could possibly be having internet browser compatibility issues. Whenever I look at your website in Safari, it looks fine however, when opening in Internet Explorer, it’s got some overlapping issues. I merely wanted to provide you with a quick heads up! Apart from that, wonderful blog!

  11. What an informative and meticulously-researched article! The author’s meticulousness and aptitude to present complex ideas in a comprehensible manner is truly praiseworthy. I’m thoroughly impressed by the depth of knowledge showcased in this piece. Thank you, author, for providing your knowledge with us. This article has been a real game-changer!

  12. zoritoler imol

    Having read this I thought it was very informative. I appreciate you taking the time and effort to put this article together. I once again find myself spending way to much time both reading and commenting. But so what, it was still worth it!

  13. It?s really a nice and useful piece of info. I?m glad that you shared this useful info with us. Please keep us informed like this. Thanks for sharing.

  14. Another issue is that video games usually are serious as the name indicated with the main focus on mastering rather than fun. Although, there’s an entertainment feature to keep your children engaged, each one game is normally designed to focus on a specific skill set or curriculum, such as numbers or scientific research. Thanks for your write-up.

  15. Excellent post. I was checking constantly this blog and I’m inspired! Extremely helpful information particularly the closing section 🙂 I deal with such info a lot. I used to be looking for this particular info for a long time. Thank you and good luck.

  16. You really make it appear really easy with your presentation however I to find this topic to be really one thing that I believe I would never understand. It sort of feels too complicated and extremely large for me. I am having a look forward in your subsequent put up, I will try to get the hold of it!

  17. Zwarte Komijn

    I?d need to examine with you here. Which isn’t one thing I usually do! I enjoy reading a put up that will make folks think. Additionally, thanks for permitting me to remark!

  18. I have been absent for some time, but now I remember why I used to love this website. Thank you, I?ll try and check back more often. How frequently you update your site?

  19. Heya i?m for the primary time here. I came across this board and I find It really useful & it helped me out a lot. I’m hoping to present one thing again and aid others such as you aided me.

  20. Thank you for your post. I liked reading it because it addressed my issue. It helped me a lot and I hope it will help others too.

  21. Thank you for your post. I really enjoyed reading it, especially because it addressed my issue. It helped me a lot and I hope it will also help others.

  22. Thank you for your post. I liked reading it because it addressed my issue. It helped me a lot and I hope it will help others too.

  23. מחפש דירות דיסקרטיות בחיפה?

    Very nice blog post. I absolutely love this website. Keep writing!

  24. You actually make it appear really easy with your presentation but I to find this matter to be really something that I think I would never
    understand. It kind of feels too complicated and extremely wide for me.
    I am looking forward in your next submit, I will attempt to get the hang of it!

  25. If some one wants to be updated with hottest technologies then he must be go to see this web page and be up to date every
    day.

  26. I always used to study piece of writing in news papers but
    now as I am a user of internet therefore from now I am using net for articles or reviews, thanks to web.

  27. hey there and thank you for your info – I have definitely picked up anything new
    from right here. I did however expertise some technical points using this site, as I
    experienced to reload the site lots of times previous
    to I could get it to load properly. I had been wondering if
    your web hosting is OK? Not that I am complaining, but
    sluggish loading instances times will often affect your placement in google and
    could damage your high quality score if ads and marketing with Adwords.
    Anyway I’m adding this RSS to my e-mail and could look out for a lot more
    of your respective interesting content. Ensure that you update this again soon.

  28. Wonderful beat ! I wish to apprentice at the same time as you amend your site, how can i subscribe for a blog
    website? The account helped me a acceptable deal. I have been tiny bit acquainted of this
    your broadcast offered shiny transparent idea

  29. Magnificent beat ! I wish to apprentice while you amend your website, how could i subscribe for a blog website?
    The account helped me a acceptable deal. I
    had been a little bit acquainted of this your
    broadcast provided bright clear concept

  30. Undeniably imagine that which you stated. Your favourite justification appeared to be at the internet
    the simplest factor to keep in mind of. I say to you, I certainly get annoyed whilst folks think about worries that they plainly don’t understand
    about. You managed to hit the nail upon the top as smartly as outlined
    out the whole thing with no need side effect , people could take a signal.
    Will likely be back to get more. Thanks

  31. When some one searches for his required thing, therefore he/she needs to be available that
    in detail, so that thing is maintained over here.

  32. Greetings! Quick question that’s completely off
    topic. Do you know how to make your site mobile
    friendly? My blog looks weird when viewing from my iphone 4.
    I’m trying to find a template or plugin that might be able to resolve this problem.
    If you have any recommendations, please share. Cheers!

Leave a Comment

Your email address will not be published. Required fields are marked *