[英]I want to get inner tag value for the md-autocomplete but I am not able to get text valu , Find code below
HTML: HTML:
<md-virtual-repeat-container role="presentation" ng-class="{ 'md-not-found': $mdAutocompleteCtrl.notFoundVisible() }" class="md-autocomplete-suggestions-container md-whiteframe-z1 md-virtual-repeat-container md-orient-vertical ng-hide" ng-hide="$mdAutocompleteCtrl.hidden" ng-mouseup="$mdAutocompleteCtrl.mouseUp()" ng-mouseleave="$mdAutocompleteCtrl.listLeave()" ng-mouseenter="$mdAutocompleteCtrl.listEnter()" md-auto-shrink-min="1" md-auto-shrink="" aria-hidden="true" style="left: 676.483px; min-width: 270.717px; max-width: 941.2px; top: auto; bottom: -147.917px; max-height: 240px; height: 96px;">
<div class="md-virtual-repeat-scroller">
<div class="md-virtual-repeat-sizer" style="height: 96px;"></div>
<div class="md-virtual-repeat-offsetter">
<ul id="ul-3" ng-class="::menuClass" class="md-autocomplete-suggestions">
<!-- mdVirtualRepeat: item in $mdAutocompleteCtrl.matches -->
<li md-extra-name="$mdAutocompleteCtrl.itemName" ng-click="$mdAutocompleteCtrl.select($index)" ng-class="{ selected: $index === $mdAutocompleteCtrl.index }" md-virtual-repeat="item in $mdAutocompleteCtrl.matches" class="ng-scope" role="button" tabindex="0">
<!-- mdAutocompleteParentScope: -->
<md-autocomplete-parent-scope md-autocomplete-replace="" class="ng-scope">
<span md-highlight-text="searchText1" id="pincodeCity"><span class="highlight">110081</span>,Delhi</span>
</md-autocomplete-parent-scope>
</li>
<li md-extra-name="$mdAutocompleteCtrl.itemName" ng-click="$mdAutocompleteCtrl.select($index)" ng-class="{ selected: $index === $mdAutocompleteCtrl.index }" md-virtual-repeat="item in $mdAutocompleteCtrl.matches" class="ng-scope" role="button" tabindex="0">
<!-- mdAutocompleteParentScope: -->
<md-autocomplete-parent-scope md-autocomplete-replace="" class="ng-scope">
<span md-highlight-text="searchText1" id="pincodeCity"><span class="highlight">110081</span>,Nizampur</span>
</md-autocomplete-parent-scope>
</li>
<!-- ngIf: $mdAutocompleteCtrl.notFoundVisible() -->
</ul>
</div>
</div>
Protractor code: 量角器代码:
let foo = $$('.md-autocomplete-suggestions').$$('.highlight');
expect(foo.getText()).toEqual([',Delhi', ',Nizampur']);
I have tried with above code, but it didn't work. 我已经尝试了上面的代码,但是没有用。
Is there any way I can find/Select text field in a span tag. 有什么方法可以在span标签中查找/选择文本字段。
Ok you have to put id at the span 好的,您必须在跨度上输入id
es: ES:
<span id="Spansearch" md-highlight-text="searchText1"><span class="highlight">110081</span>,Delhi</span>
after whit this you can get all html with this 在这之后,你可以得到所有的HTML
$( "#Spansearch" ).html();
if you wont tu get only Nizampur
如果你Nizampur
得到Nizampur
you can use this 你可以用这个
$( "#Spansearch" ).html().split(",")[1];
In Protractor, getText()
returns a promise that you need to resolve. 在量角器中, getText()
返回您需要解决的承诺。 So when you're using your expect
, you need to do that post you've resolved the promise. 因此,当您使用expect
,您需要执行已完成诺言的那篇文章。
I suppose you can do something like 我想你可以做类似的事情
let foo = $$('.md-autocomplete-suggestions').$$('.highlight>span[1]');
foo.getText().then(function(text){
expect(text).toEqual('Delhi');
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.