gpt4 book ai didi

html - 如何在冒号属性名称中选择具有特定字符串的 NOT 元素

转载 作者:太空狗 更新时间:2023-10-29 15:58:48 24 4
gpt4 key购买 nike

我有几个这样的元素:

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

我想选择名称中没有“specifyc”的元素。问题是有时有几个 NOT 元素,有时没有。非特定图像计数始终为一个。

由于属性名称中有“:”,我无法完成。

我试过这个:

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

最佳答案

你的代码对我来说没有多大意义,也不知道如何测试它,但我认为下面的代码会起作用。尝试像这样转义字符:

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

这是一个有效的 CSS 选择器,因此请根据您的代码进行调整:

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

这是一个有效的 fiddle - 它不是您使用的确切代码,但我将它写成一个 css 选择器:https://jsfiddle.net/x4gsr658/

关于html - 如何在冒号属性名称中选择具有特定字符串的 NOT 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50216771/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com