Em button Visibility active class requires a white space

Ask general questions here.
mtkilic
Posts: 4
Joined: Tue Jan 15, 2019 4:12 pm

Em button Visibility active class requires a white space

Post by mtkilic » Wed Jan 23, 2019 12:25 am

I have xpath

Code: Select all

button/em[@class~'ico-visibility']
, but when button is clicked it will change to

Code: Select all

button/em[@class~'ico-visibility active']
So what I did was create variable name "Visibility" and set to empty, so my xpath now looks like this

Code: Select all

button/em[@class~'ico-visibility'+$Visibility+'']
This is almost working, I want to click when button is only 'ico-visibility'', but when its 'icon-visibility active' it doesnt work , because its requiring me to pass Visibility value with space front of it like this Visibility= " active";

I honestly dont want to variable value to have white space in front , because in future it will create confusion. What is the best way to over come this issue?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4421
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Em button Visibility active class requires a white space

Post by odklizec » Wed Jan 23, 2019 9:12 am

Hi,

Maybe I'm missing something from your description, but I would rather use xpath like this...

Code: Select all

button/em[@class~'ico-visibility' and @class!~'active']
Hope this helps?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

mtkilic
Posts: 4
Joined: Tue Jan 15, 2019 4:12 pm

Re: Em button Visibility active class requires a white space

Post by mtkilic » Wed Jan 23, 2019 3:28 pm

Do you mind explaining this little bit? Without testing, this seems to make xpath clickable either way. If thats the case, I dont want that because I want to pass variable in xpath so I know if I am clicking on "active" or just "ico-visibility".

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4421
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Em button Visibility active class requires a white space

Post by odklizec » Wed Jan 23, 2019 3:37 pm

Hi,

Basically, the xpath is considered valid, only if class attribute contains'ico-visibility' and does not contain (notice !~ operator) 'active' string. So if the button is already clicked and its class contains both 'ico-visibility' and 'active' strings, the above path is not valid.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

mtkilic
Posts: 4
Joined: Tue Jan 15, 2019 4:12 pm

Re: Em button Visibility active class requires a white space

Post by mtkilic » Wed Jan 23, 2019 4:15 pm

Sounds good but this only make button clickable when only class attribute contains'ico-visibility' , but I want to click same button when class attribute contains both 'ico-visibility' and 'active'. But I want to pass variable in my test when I am clicking button has 'active' so I know, what I am trying to do. If you look at my first post, I kinda almost able to do that, but had trouble with white space requirement.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4421
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Em button Visibility active class requires a white space

Post by odklizec » Wed Jan 23, 2019 11:25 pm

Hi,

I understand now. I think this is what you want...
button/em[@class='ico-visibility' or @class='ico-visibility '+$visibility]
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration