Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select NOT element with specific string in colon attributed name

Tags:

I have couple of elements like this:

<g transform="matrix">
   <image xlink:href="data:image/png" width="48">
</g>
<g transform="matrix">
   <image xlink:href="specyfic" width="48">
</g>
<g transform="matrix">
   <image xlink:href="specyfic" width="48">
</g>

I want to select element which would NOT have 'specifyc' in name. The problem is that sometimes there are couple of that NOT elements and sometimes there are none. The NON specyfic image count is always one.

I cannot accomplish that because of ':' in attribute name.

I tried this:

  public static getEventIconOnMap: ElementFinder = 
   element.all(by.css('image[width="48"]:not(image[xlink\\:href*="specyfic"'))).last();
like image 838
Jerzy Gruszka Avatar asked May 07 '18 14:05

Jerzy Gruszka


1 Answers

Your code does not make much sense to me and have no idea how to test it, but I think the following code will work. Try escaping the character like this:

public static getEventIconOnMap: ElementFinder = 
   element.all(by.css('image:not([xlink\:href*=specyfic]')).last();

Here is a CSS selector that works, so adjust this to your code:

image:not([xlink\:href*=specyfic]) {
  // your code
}

Here is a working fiddle - it's not the exact code you are using, but I wrote it as a css selector: https://jsfiddle.net/x4gsr658/

like image 125
scooterlord Avatar answered Sep 28 '22 06:09

scooterlord