Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/412.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我想获取md自动完成的内部标记值,但无法获取文本值,请查找下面的代码_Javascript_Angularjs_Testing_Protractor_Angular Material - Fatal编程技术网

Javascript 我想获取md自动完成的内部标记值,但无法获取文本值,请查找下面的代码

Javascript 我想获取md自动完成的内部标记值,但无法获取文本值,请查找下面的代码,javascript,angularjs,testing,protractor,angular-material,Javascript,Angularjs,Testing,Protractor,Angular Material,HTML: 我试过上面的代码,但没有成功 是否有任何方法可以在span标记中查找/选择文本字段。好的,您必须在span标记处添加id es: 如果你不想只得到nizamper 你可以用这个 $( "#Spansearch" ).html(); 在量角器中,getText()返回需要解析的承诺。因此,当您使用expect时,您需要在您已解决承诺的情况下发布该帖子 我想你可以这样做 $( "#Spansearch" ).html().split(",")[1]; 您希望在md AutoCompl

HTML:

我试过上面的代码,但没有成功


是否有任何方法可以在span标记中查找/选择文本字段。

好的,您必须在span标记处添加id

es:

如果你不想只得到
nizamper

你可以用这个

$( "#Spansearch" ).html();

在量角器中,
getText()
返回需要解析的承诺。因此,当您使用
expect
时,您需要在您已解决承诺的情况下发布该帖子

我想你可以这样做

$( "#Spansearch" ).html().split(",")[1];

您希望在md AutoComplete中使用html是的,我希望在span标记value”下选择值,nizamper“我得到的输出类似于“Expected['110081','110081']以等于'drish.”但我需要预期drish。您需要选择第二个span,而不是第一个span。在执行上述代码时,正在填充以下错误。错误:失败:$(…).getText(…).split不是我用$(foo).text()尝试过的函数,但对我无效。
 <span id="Spansearch" md-highlight-text="searchText1"><span class="highlight">110081</span>,Delhi</span>
$( "#Spansearch" ).html();
$( "#Spansearch" ).html().split(",")[1];
     let foo = $$('.md-autocomplete-suggestions').$$('.highlight>span[1]');
      foo.getText().then(function(text){
       expect(text).toEqual('Delhi');

       })