Selenideium Element Inspector v1.2 has been released
Tags: selenide, selenium, selenideiumelementinspector, testautomation
Published: 2022-02-22 10:03:15

---
title: Selenideium Element Inspector v1.2 has been released
published: true
date: 2022-02-21 14:58:34 UTC
tags: selenide, selenium, selenideiumelementinspector, testautomation
canonical_url: https://mszeles.com/selenideium-element-inspector-v12-has-been-released
---
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ljikmkywihdcjpsyleoj.png)
 **Great news!**

The new version of Selenideium Element Inspector can be downloaded from the [Chrome web store](https://chrome.google.com/webstore/detail/selenideium-element-inspe/mgfhljklijclnfeglclagdeoiknnmnda).

So let's have a look, what are the new features

- Relative XPath Selector
- CSS selectors based on any unique attribute are automatically generated for the web elements (except id, name, class as they are covered a different way).
- In case one of the classes of the element is unique, CSS selector is also generated based on that
- Automatically add ";" to the end of the selector, so you really only have to copy-paste the code.
- Marking the start and end of the logs belonging to Selenideium Element Inspector 

[**Download Selenideium Element Inspector v1.2**](https://chrome.google.com/webstore/detail/selenideium-element-inspe/mgfhljklijclnfeglclagdeoiknnmnda), and have fun.

Please [leave a review](https://chrome.google.com/webstore/detail/selenideium-element-inspe/mgfhljklijclnfeglclagdeoiknnmnda) in case you find the plugin useful!

[**Buy me a coffee in case you save time by using Selenideium Element Inspector!**](https://buymeacoffee.com/mikiszeles) 😊

In case you are interested in the implementation details, then keep on reading.

## Implementing Selenideium Element Inspector v1.2

However, my code did what it had to I have to admit it was ugly. There were many duplications in it. I have only started learning JavaScript now, but that cannot be an excuse, as clean code is independent of the language. So before we introduce new functionality

### Let's refactor

I have removed the duplication by collecting Selenide and Selenium selectors into 2 lists, and also added 2 utility methods, to create the complete copy-pastable selector.

![Selenideium Element Inspector v1.2 Refactored Source Code](https://cdn.hashnode.com/res/hashnode/image/upload/v1645246656960/m4-LpwlDV.png)

Looks nice. Don't you think?

Let's start implementing the first feature!

### CSS selectors based on any unique attribute

Usually, there are many attributes of a web element, so it would be quite handy if could generate the selectors based on those attributes. Here is the code:

![Selenideium Element Inspector v1.2 Find Selenium and Selenide Elements Based on Unique Attributes Source Code](https://cdn.hashnode.com/res/hashnode/image/upload/v1645121747615/FhDmCvJyC.png)

Now move to the next feature:

### Generate CSS selector based on unique class name

![Selenideium Element Inspector v1.2 Find Selenium and Selenide Elements Based on Unique Class Source Code](https://cdn.hashnode.com/res/hashnode/image/upload/v1645122088033/1_cOQaQCY.png)

It was simple, don't you think? The last feature for today:

### Generate relative XPath selector

![Selenideium Element Inspector v1.2 Find Selenium and Selenide Elements Based on Relative XPath Source Code](https://cdn.hashnode.com/res/hashnode/image/upload/v1645122264601/krF_Kg8AR.png)

And we are ready. You can find the source code at my [GitHub account](https://github.com/mszeles/selenideium-element-inspector).

But there is a known bug. I tried to solve it for several hours but I was not able to do that, so I asked my second question on [StackOverflow](https://stackoverflow.com/questions/71159446/element-parentnode-returns-null-while-traversing-through-the-dom-using-javascrip) and also asked it on [Twitter](https://twitter.com/mszeles/status/1494651420234108929). Up till now, no answer has arrived. **In case you have any idea how to solve the issue, please do not hesitate to contact me. I will buy a beer for you.** 🍺

[**Buy me a coffee in case you save time by using this plugin!**](https://buymeacoffee.com/mikiszeles) 😊

P.S.: **Support me by sharing this article in case you found it useful.**

📚 **Join the Selenide community** on [LinkedIn](https://www.linkedin.com/groups/9154550/)! ✌