# Selenideium Element Inspector v1.2 has been released

**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.

<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1645246656960/m4-LpwlDV.png" style="text-align: center;" alt="Selenideium Element Inspector v1.2 Refactored Source Code"/>

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:

<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1645121747615/FhDmCvJyC.png" style="text-align: center;" alt="Selenideium Element Inspector v1.2 Find Selenium and Selenide Elements Based on Unique Attributes Source Code"/>

Now move to the next feature:

### Generate CSS selector based on unique class name

<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1645122088033/1_cOQaQCY.png" style="text-align: center;" alt="Selenideium Element Inspector v1.2 Find Selenium and Selenide Elements Based on Unique Class Source Code"/>

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

### Generate relative XPath selector

<img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1645122264601/krF_Kg8AR.png" style="text-align: center;" alt="Selenideium Element Inspector v1.2 Find Selenium and Selenide Elements Based on Relative XPath Source Code"/>

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/)! ✌






