cancel
Showing results for 
Search instead for 
Did you mean: 

CSS Seletor does not select class properly

mplich
Level 3

Hi, CSS selector seems to give different results than Web Class Attribute in Application Modeler.
Here's an example:
Trying to select highlighted element of a page:

mplich_0-1740397169552.png

This works fine when I'm using Web Class and Match Index Attributes:

mplich_1-1740397397345.png
(there are multiple elements with this class on this page, but above gives me a match),
but using the same as CSS Selector returns no founds:

mplich_2-1740397520984.png

Same story when I'm using CSS selector without Match Index:

mplich_3-1740397599679.png

When I use just this CSS Selector: 

mplich_4-1740397659019.png

I'll get a match (sth is found, it's not highlighted though). Above returns no error message (which would indicate that just 1 element with .rnvToggle.radIcon class exists in this page).

Am I missing something? Are CSS selectors only partially supported, or it's some bug I'm facing?
I'm using BP 7.2.0.5997 x64
Here's the reference to page I'm using, you can switch to English in this button:
Statistics Poland - Local Data Bank

mplich_5-1740398074806.png

 

4 REPLIES 4

mplich
Level 3

Apologies for first screen - I've selected different element, than I'm referring to later on, but I hope my question is clear (can't edit it now).

@mplich 

Hello,

You can use the xpath in this scenario.

for example this expression will choose the Metadata list

//span[@class='rnvText' and text()='METADATA']

 

in addition to this, with xpath you can use the indexing method for example if you have 19 element in the browser (see below)  with this xpath expression //div[@role='listitem']

Mohamad_747_0-1740401875342.png

you can use the first one with this expression (//div[@role='listitem'])[1]

Mohamad_747_1-1740401944139.png

With Xpath you can also choose an element with the text name example : 

Mohamad_747_2-1740402042789.png

to choose xpath inside blue prism in application modeller tick this 

Mohamad_747_3-1740402137842.png

 

@mplich 

With CSS i have 4 elements 

Mohamad_747_0-1740402755821.png

With xpath i can filter by indexing 

Mohamad_747_1-1740402809021.png

or easiest like this //span[@class="rnvText" and text()='METADANE']

Mohamad_747_2-1740402859309.png

 

MichealCharron
Level 8

@mplich 

Adding to @Mohamad_747, XPath is really the best solution for what you are looking for. One of the advantages over CSS Selectors is that you can traverse backwards (which comes in handy more than you would believe). For your element, you can use the text of it's child to select the element:

//span[text()='METADANE']/parent::span

 

MichealCharron_0-1740405427922.png

 

Micheal Charron
RBC
Toronto, Ontario
Canada