CasperJS断言
特征
CasperJS具有一系列特征。 它具有一些列功能与断言,都是你期望一个好的测试API所具有的,包括:
* assertTextExists (文本存在断言)
* assertTitle (标题断言)
* assertHttpStatus (HTTP状态断言)
* assertDoesntExist (不存在断言)
* assertUrlMatch (Url匹配断言)
this.test.assertExists( {type: 'xpath', path: '//input[@id="FullName"]' }, 'the element exists' ); this.test.assertExists( {type: 'xpath', path: '//input[@id="Company"]' }, 'the element exists' ); this.test.assertExists( {type: 'xpath', path: '//input[@id="Email"]' }, 'the element exists' ); this.test.assertExists( {type: 'xpath', path: '//input[@id="Password"]' }, 'the element exists' ); this.test.assertExists( {type: 'xpath', path: '//input[@id="PromoCode"]' }, 'the element exists' );
在上面的五个断言中,我查找了五个输入域控件,它们的ID分别是‘FullName’, ‘Company’, ‘Email’, ‘Password’ 和‘PromoCode’。用XPath查找选择列表控件元素同样容易。