小编Anu*_*apu的帖子

量角器 - 描述未定义

我正在使用量角器js进行测试.当我尝试使用测试用例时

量角器e2e/main/test.spec.js

我的conf.js

// An example configuration file.
 exports.config = {
// The address of a running selenium server.
 seleniumAddress: 'http://localhost:4444/wd/hub',

// Capabilities to be passed to the webdriver instance.

baseUrl: 'http://localhost:4000',

capabilities: {
  'browserName': 'chrome',
  'chromeOptions': {
  args: ['--test-type']
  }
},

// Spec patterns are relative to the current working directly when
// protractor is called.
 specs: ['*_spec.js'],

// Options to be passed to Jasmine-node.
jasmineNodeOpts: {
 showColors: true,
 defaultTimeoutInterval: 30000
}
};
Run Code Online (Sandbox Code Playgroud)

我有参考错误

> D:\cronj\gxp\10-09-2014\e2e\main\test.spec.js:3
describe('Login page', function() …
Run Code Online (Sandbox Code Playgroud)

testing angularjs protractor

10
推荐指数
1
解决办法
1万
查看次数

如何在路由处理程序中使用`pre` - hapi.js

我必须在路线中使用pre来调用方法.我正在使用hapi-request.我试图在路由声明中使用pre,但是我收到了一个错误.我错过了什么?

我原来的路线:

server.route({ 
    method: 'POST', 
    path: '/searchUser',  
    config: User.searchUser
})
Run Code Online (Sandbox Code Playgroud)

使用Pre

server.route({ 
    method: 'POST', 
    path: '/searchUser',  
    pre: validateUser, 
    config: User.searchUser
})
Run Code Online (Sandbox Code Playgroud)

错误

Error: Invalid route options (/searchUser) {
  "method": "POST",
  "path": "/searchUser",
  "config": {}
}
?[31m
[1] "pre" is not allowed?[0m   
Run Code Online (Sandbox Code Playgroud)

routes node.js hapijs

6
推荐指数
1
解决办法
7687
查看次数

量角器 - 如何在不更改代码的情况下在测试用例中使用 ng-file-upload 上传文件?

我正在使用https://github.com/danialfarid/ng-file-upload进行文件上传。我必须测试它,所以我写了量角器测试用例,但它不起作用。

代码

<div class="col-lg-12 up-buttons">
     <div ng-file-select="" ng-model="files" ng-model-rejected="rejFiles" class="btn btn-default" ng-multiple="false" ng-accept="'text/csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'"  ng-model-rejected="rejFiles" tabindex="0">Choose file</div>
</div>
Run Code Online (Sandbox Code Playgroud)

测试用例

it('upload file', function(){   
  var fileToUpload = 'C:/Users/Anusha/Desktop/demo.csv';
  var absolutePath = path.resolve(fileToUpload);
  $('input[type="file"]').sendKeys(absolutePath);
  browser.sleep(1500);
})
Run Code Online (Sandbox Code Playgroud)

测试结果

我可以上传文件,但它是在rejFiles模型而不是文件模型中接收的,尽管文件格式是正确的。有人可以建议我如何做到这一点吗?

file-upload angularjs protractor

5
推荐指数
1
解决办法
8201
查看次数

我如何验证角度多选?

我正在使用http://isteven.github.io/angular-multi-select/中的 angular-multi-select .它根据我的需要工作.我正在使用模式形式的多选,我想验证它,但它不验证我何时使用所需的选项.任何人都可以建议我如何验证形式的角度多选.

<div class="form-group" ng-class="{'has-error' :batch_form.end_time.required || batch_form.start_time.required || batch_form.days.$invalid && (!batch_form.days.$pristine || submitted) }">
    <label for="">Timings</label>
    <div ng-repeat="batch_timing in batch_timings" >
        <div class="row" ng-hide="batch_timing._destroy == 1">
             <div class="col-md-10">
                 <div class="row new-timings">
                    <div class="col-md-1">
                      <span class="text-style pull-left">Days</span>
                    </div>
                    <div class="timings-row" >
                      <div class="col-md-11">
                          {{batch_form.start_time.$error.required}}
                          <div 
                            multi-select
                            input-model="batch_timing.days"
                            output-model="resultData"
                            button-label="acronym"
                            item-label="acronym symbol name"
                            tick-property="ticked"
                            helper-elements="all none reset"
                            required name="days">
                          </div>  
                      </div>
                    </div>
                  </div>
                  <div class="row col-md-offset-1 new-timings">
                    <div class="col-md-1">
                      <span class="text-style">from</span>
                    </div>
                    <div class="col-md-4">
                      <select 
                        class="form-control"
                        data-ng-model="batch_timing.start_time" 
                        ng-options="timing …
Run Code Online (Sandbox Code Playgroud)

angularjs bootstrap-modal angular-directive

4
推荐指数
1
解决办法
1万
查看次数

如何使用量角器测试角度多选下拉菜单?

我正在使用https://github.com/isteven/angular-multi-select 中的angular-multi-select 下拉列表。现在我想在量角器中编写测试用例。

<div ng-show="!attribute.isMultivalued && page != 'view'" 
     class="select-group" 
     multi-select 
     input-model="typesDataDup"
     output-model="attribute.types"
     button-label="typeName"         
     item-label="typeName" 
     tick-property="ticked" 
     selection-mode="single"
     helper-elements="filter"
     is-disabled = "page == 'view'">
</div>
Run Code Online (Sandbox Code Playgroud)

我无法使用模型发送数据,因为这里我们没有提到 ng-model。

有人可以帮我写测试用例吗?

javascript testing multi-select angularjs protractor

2
推荐指数
1
解决办法
4289
查看次数

量角器:错误 - 无法启动WebDriver会话

我在三个月前编写了测试用例,当时他们工作正常,我想在另一个系统中运行这些测试用例,所以我做了基本设置.当我尝试运行量角器测试用例时,他们失败了"无法启动WebDriver会话".我尝试了很多解决方案,但它们对我不起作用.这里我附加了我的protractor.conf.js文件和错误详细信息.

protractor.conf.js

'use strict';

exports.config = {

seleniumAddress: 'http://127.0.0.1:4444/wd/hub',

baseUrl: 'http://localhost:' + (process.env.PORT || '3036'),

chromeOnly: true,

// To get the maximimum test screen size
onPrepare: function() {
    browser.driver.manage().window().maximize();
},

// list of files / patterns to load in the browser
specs: [
'e2e/attributeSection/search_spec.js', 'e2e/attributeSection/create_spec.js', 
'e2e/attributeSection/edit_spec.js', 'e2e/attribute/search_spec.js', 
'e2e/attribute/create_spec.js', 'e2e/attribute/edit_spec.js',
'e2e/classification/search_spec.js', 'e2e/classification/create_spec.js', 
'e2e/classification/edit_spec.js', 'e2e/classificationGroup/create_spec.js', 
'e2e/classificationGroup/edit_spec.js'
],

exclude: [],

capabilities: {
'browserName': 'chrome',
'chromeOptions': {
    binary: 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe',
    args: [],
    extensions: [],
}
},

framework: 'jasmine',
jasmineNodeOpts: {
  defaultTimeoutInterval: 60000
} …
Run Code Online (Sandbox Code Playgroud)

selenium webdriver testcasesource protractor

2
推荐指数
1
解决办法
3346
查看次数

如何停止JavaScript中的事件捕获?

我们可以使用event.stopPropagation()来停止事件冒泡。我们也可以使用相同的方法来停止事件捕获吗?

如果没有,我们怎么能做到呢?

javascript jquery stoppropagation

2
推荐指数
1
解决办法
2976
查看次数

如何在角度js中为ng-show添加超时?

我正在研究测验应用程序.即使用户尝试了问题,我也会为每个问题添加时间.

我的代码在视图中:

<p ng-repeat="opt in question.answer">      
    <label ng-show="opt._correct" for="">
    <input type="radio" name="questionAnswer" id="opt.id" value="" 
        ng-click="checkAnswer(1)" />
    {{opt.__text}}
    </label>
    <label ng-hide="opt._correct" for="">
    <input type="radio" name="questionAnswer" id="opt.id" value="" 
        ng-click="checkAnswer(0)" />
    {{opt}}
   </label>
</p>
Run Code Online (Sandbox Code Playgroud)

我在控制器中的代码:

$scope.randomQuestions = function(questionslist){

    $scope.randomQuestion = questionslist
            [Math.floor(Math.random() * questionslist.
                length)];
            console.log($scope.quiz);
            var item = $scope.quiz.splice($scope.randomQuestion,1)[0];
        $scope.questions = new Array();
        $scope.questions.push($scope.randomQuestion);
                    $scope.counter = $scope.counter + 1;
        return $scope.questions;

}

$scope.checkAnswer = function(option){
        console.log('check answer');

        if(option == 1){
            console.log($scope.score);
            $scope.score = $scope.score + parseInt($scope.level._points_per_question);
             console.log($scope.score);
        } else{

        }
        console.log($scope.counter);
        if …
Run Code Online (Sandbox Code Playgroud)

timeout angularjs ng-show

1
推荐指数
1
解决办法
1万
查看次数

Moment.js添加月份不起作用

我想X个月添加到给定date.I已经使用了点。

moment(date).add(2,'m')。format(“ DD / MM / YYYY”);

通过使用像这样的月份没有添加。

建议增加月数的正确方法。

momentjs

1
推荐指数
2
解决办法
1万
查看次数

如何在React中呈现嵌套数组元素?

我想渲染嵌套的数组元素.要渲染我使用.map的元素,但它不适用于第二个数组.

使用list = [{value:'One',list:[{value:'abc',selected:false},{value:'efg',selected:false}]},{value:'Two',list:[ {value:'psr',selected:false}]}];

   list.map((item, index) => {
        return (
          <div key={index}>
            <ul >{item.value}</ul>
            item.list.map((subitem, i) => {
              return (
                 <ul >{subitem.value}</ul>
              )
            })
          </div>
        )
      })
Run Code Online (Sandbox Code Playgroud)

我在这里错过了什么吗?

谢谢

rendering reactjs array.prototype.map

1
推荐指数
1
解决办法
1万
查看次数

如何使用量角器js单击表格中的行按钮

我正在写量角器测试用例.我想点击编辑按钮.当我检查id它时,找不到它.

码:

<table class="table table-bordered table-hover">
   <thead>
       <tr>
          <th>Code</th>
          <th>Start Date</th>
          <th></th>
      </tr>
  </thead>
  <tbody>
      <tr ng-repeat="batch in batches.list">
         <td><a ui-sref="root.courses.detail.batches.assessments({ batch_id: batch.id,assessment_status: 'published'})">BID00{{batch.id}}</a></td>
         <td>{{batch.start_date}}</td>
         <td> 
             <button id="edit" type="button" class="btn btn-default btn-sm" tooltip-placement="top" tooltip="Edit" ng-controller="batchesCtrl" ng-click="edit_batch(batch.id)"><i class="glyphicon glyphicon-edit"></i></button> 
             <button type="button" id="delete(batch.id)" class="btn btn-danger btn-sm" tooltip-placement="top" tooltip="Delete" ng-click="remove_batch(1, batch.id)" confirmation-needed="Do you really want to delete this batch?"><i class="glyphicon glyphicon-trash" ></i></button>
         </td>
      </tr>
   </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

我怎样才能使它工作?

testing jasmine protractor

0
推荐指数
1
解决办法
3862
查看次数