Request Ability to have ID, ClassName as Selector Types


#1

Hi Team,

We are able to create elements with types such as CSS, XPath and Linked Text.

It would be great to have types like ID & Class Names as well.

If we write elements manually, we are able to write with id and Class Names.

We need this feature in elements tab which currently has only CSS, XPath and Linked Text.

Thanks,
Saravanan


Add ID and ClassName to Elements editor
Selocity shall support name and id strategies too
#2

Hi @saravanan_palanivel,

most browsers (not sure for IE) and as such their WebDriver implementations are tweaked for best performance when using By.ByCss.

With that ByCss you can actually express ByClassname same as ById.

driver.findElement(By.cssSelector(".myclass"));
driver.findElement(By.className("myclass"));

driver.findElement(By.cssSelector("#myid"));
driver.findElement(By.id("myid"));

As such a best practice would be to always prefer CSS selectors, even before XPaths as those tend to be the slowest, but certainly XPath offers other features not available with CSS.


#3

Hi @vsoftic,

Thanks for the clarification, we have one more query on this.

While exporting the cssSelector and rxpath using Ranorex Selocity, the element is getting generated in the code, but it is expressed using the text from webpage instead of ClassName or ID.

Since we are testing in multiple languages, the generated elements can’t be used in Non-English environments because the text varies for each language. So, it would be really helpful if it picks ID or ClassName instead of text.

Thanks,
Saravanan


#4

I see, so that seems to be more of a different topic related to the Extension itself. Could you give us an example page where you’ve been trying to do so and the exact element you’ve been expecting (screenshot would help).

We are currently heavily focused on the app but for sure want to add features for the Extension as well as soon as we are approaching the end of the Beta.


#5

Hi @vsoftic,

Please find the attached screenshot for reference.

This is some of the cases which we saw.

Thanks,
Saravanan


#6

Hi @saravanan_palanivel,

alright, so lets focus on the first screenshot. Ranorex Selocity tries to build the most performant and minimal selector out of the box. Given first example, it’s sufficient to only take the add-device class. Now I agree that the software can’t always 100% know what your use case is. This is why we added the playground to the extension. With this you can manually create selectors and evaluate them. Please take a look at the following video:

So a feature we’d like to introduce that you can, after creating the selector inside the playground, send it directly to the app from there. Meanwhile you’d have to copy the selector manually and override the element in Webtestit.

We’re also evaluating other features like generating multiple variants of CSS selectors, like you described, one always preferring IDs, another one always classes and so on.

With regards to the second screenshot. RxPaths aren’t currently supported with Webtestit. Please fall back to using XPaths instead.


#7

Hi @vsoftic,

Thanks for the clarification. We will let you know if we face any issues.

Thanks,
Saravanan


closed #8