简体   繁体   English

量角器无法使用具有不同字符的按钮

[英]Protractor doesn't work with my button which has a different character

I'm trying to get a button element which has the text " Salvar & Fechar", but using 我正在尝试获取带有文本“ Salvar&Fechar”的按钮元素,但是使用

element(by.buttonText('Salvar & Fechar');

protractor just can't find the element. 量角器只是找不到元素。 Why? 为什么?

I can't use element(by.partialButtonText('Salvar') because there is other element with this text and protractor always selecte the first one. 我不能使用element(by.partialButtonText('Salvar')因为此文本中还有其他元素,量角器总是选择第一个。

i guess the problem is that the text present on the button need to be trimmed because it has an extra whitespace at the beginning.try the below xpath and check whether it works, 我想问题是按钮上的文本需要修剪,因为它的开头有多余的空格。请尝试以下xpath并检查其是否有效,

element(by.xpath(".//button[normalize-space(text())='Salvar & Fechar']")) element(by.xpath(“ .// button [normalize-space(text())='Salvar&Fechar']”)))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM