以下是HTML代码:
<div class="ijd-card" ng-click="selectThisJD()" style="cursor: pointer">
<div class="item-counter clearfix ng-binding" style="text-align: left; padding-left: 40px; padding-right: 40px;">#2
<!-- ngIf: eachRecommendedJD.like_count -->
<!-- ngIf: eachRecommendedJD.dislike_count -->
</div><!--<p >{{eachRecommendedJD[1]}}</p>-->
<p ng-bind-html="get_jd(eachRecommendedJD.job_desc)" class="ng-binding"><p class="padding-top-10">Proficiency in AngularJS, Javascript, Grunt, Protractor<br>Knowledge in Python, Ming Database ORM, MongoDB will be a pulse<br>Proficiency in Object Oriented design.<br>Experience in REST API.<br>Experience with Amazon web services.<br>Exposure to GIT software<br>Basic Qualifications<br>Bachelor degree in Computer Science or Computer Engineering (B. Tech / B. E. / B. Sc. Comp Science)<br>Experience: 7+ years <br> </p><p class="padding-top-10 padding-xs-15" itemprop="skills">
<span class="pull-left padding-bottom-10">
<a class="label label-info margin-right-5">
AngularJS
</a>
</span>
<span class="pull-left padding-bottom-10">
<a class="label label-info margin-right-5">
Javascript
</a>
</span>
<span class="pull-left padding-bottom-10">
<a class="label label-info margin-right-5">
Grunt
</a>
</span>
<span class="pull-left padding-bottom-10">
<a class="label label-info margin-right-5">
Protractor
</a>
</span>
</p><p class="padding-top-10 padding-xs-15"> </p></p>
</div>
在上面的段落 7 + 年经验是数字。
问题:我提供的经验范围是 1到10 年,我得到了上述结果(HTML代码)。现在我想验证体验范围是否按照范围显示天气。
如何验证范围?
答案 0 :(得分:1)
首先提取体验值,然后您可以应用toBeWithinRange
matcher from jasmine-matchers
:
var elm = $(".padding-top-10"); // TODO: bad locator - have not enough information to provide a better one
elm.getText().then(function (text) {
var pattern = /Experience: (\d+)\+ years/gi;
var match = pattern.exec(text);
var value = parseInt(match[1]);
expect(value).toBeWithinRange(1, 10); // borders included
});
另见:Checking two boundaries with Jasmine (between matcher),表明您也可以进行简单的布尔检查:
expect(value >= 1 && value <= 10).toBeTruthy();
答案 1 :(得分:0)
您可以使用expect(experience).toBeGreaterThan(0)
和expect(experience).toBeLessThan(11)
来验证范围。