小编Лил*_*ина的帖子

树的最小高度

我正在尝试优化代码:

data Tree = Empty | Node Integer Tree Tree
minHeight Empty = -1
minHeight (Node _ Empty Empty) = 0
minHeight (Node _ l     r    ) = (min (minHeight l) (minHeight r)) + 1
Run Code Online (Sandbox Code Playgroud)

我的目标是不计算其深度将高于已知的分支的分支.

haskell functional-programming

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

量角器:如何使配置文件更灵活?

我有一个想法让我的配置更灵活.例如,我有10000个具有相同参数的配置文件:

seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['C:/Users/Lilia.Sapurina/Desktop/Protractor Tests/Scenarios/ps-grid-column-filter-range_spec.js'],
params: {'url_filter': 'http://wks-15103:8010/ps/ng-components/examples/ps-grid-column-filter-range.html'}
Run Code Online (Sandbox Code Playgroud)

一旦我想改变规格,html或更改selenium地址的路径.我可以在另一个文件中为我的所有配置执行此操作吗?

例如,在我的配置中写:

seleniumAddress: '../Variables/seleniumAdress.txt'
Run Code Online (Sandbox Code Playgroud)

或者可能存在另一种有趣的方法来解决这个问题?

configuration-files angularjs protractor

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

量角器:函数重载

我尝试扩展ElementFinder库.我想知道如何才能要求使用相同名称的不同方法?我想做一些像:

 // spec.js
 var ef1 = require('./ef_extend1.js');
 var ef2 = require('./ef_extend2.js');

 expect(column_resizer.ef1.getWidth()).toEqual(18);
 expect(column_resizer.ef2.getWidth()).toEqual(18);
Run Code Online (Sandbox Code Playgroud)

现在我有一个错误:

TypeError: Cannot read property 'getWidth' of undefined
Run Code Online (Sandbox Code Playgroud)

我需要的图书馆:

// ef_extend1.js
var ElementFinder = $('').constructor;
ElementFinder.prototype.getWidth = function() {
    return this.getSize().then(function(size) {
                                  return size.width + 1;
                               });
};
Run Code Online (Sandbox Code Playgroud)

第二个:

// ef_extend2.js
var ElementFinder = $('').constructor;
ElementFinder.prototype.getWidth = function() {
    return this.getSize().then(function(size) {
                                  return size.width;
                               });
};
Run Code Online (Sandbox Code Playgroud)

overloading angularjs angularjs-e2e protractor e2e-testing

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

量角器:等待方法不起作用

我尝试使用wait()方法而不是sleep(),但它不起作用.我有代码:

 browser.actions().click(filter_field).perform();
 browser.sleep(3000);
 if (baloon_info.isPresent()) { //some expections }
 else { expect(true).toBe(false); }
Run Code Online (Sandbox Code Playgroud)

现在我想做点什么:

 var present_pri = browser.wait(function () {
   return balloon_info.isPresent();
 }, 3000);
 if (present_pri) { //some expections }
 else { expect(true).toBe(false); }
Run Code Online (Sandbox Code Playgroud)

但如果气球不存在,我有错误信息:Wait timed out after 3117ms而不是expected true to be false(present_pri == false)

我试着写:

var EC = protractor.ExpectedConditions;
browser.wait(EC.presenceOf(balloon_warning), 3000);
expect(balloon_warning.isPresent()).toBeTruthy();
Run Code Online (Sandbox Code Playgroud)

但我总是有同样的错误.我做错了什么?

asynchronous timeout jasmine angularjs protractor

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

量角器:我如何在Protractor中正确使用过滤?

我尝试用量角器开始测试,现在我遇到了一个问题,我无法解决.

我有这个测试:

 describe('Test_3', function() {
    var my_url = 'http://wks-15103:8010/ps/ng-components/examples/ps-checkbox.html'
    var main_checkbox = element(by.xpath("//div[@ng-model='My_Group']/div[1]/span/span[1]"));
    var checkbox_list = element.all(by.xpath("//div[@ng-model='My_Group']/div[2]/div/span/span[1]")); 
    var title_checkbox_list = element.all(by.xpath("//div[@ng-model='My_Group']/div[2]/div/span"));   
    var disabled_pri = 'n-check-checkbox';
    var enabled_pri = 'n-check-checkbox n-check-checkbox_checked';


    beforeEach(function() {
        browser.get(my_url);
    });

    it('schould be chosen',function(){
        main_checkbox.click(); 

        checkbox_list.filter(function(elem, index) {
            return elem.getAttribute('class').then(function(text) {
                return text != 'n-check-checkbox n-check-checkbox_disabled' & text!='n-check-checkbox n-check-checkbox_disabled n-check-checkbox_checked';
            });
        }).then(function(filteredElements) {
            filteredElements.each(function(element, index) {
                expect(element.getAttribute('class')).toEqual(disabled_pri); 
            });
        });
    });
}); 
Run Code Online (Sandbox Code Playgroud)

它不起作用.但后来我尝试使用过滤而没有循环.each它工作正常.

 describe('Test_3', function() {
    var my_url = 'http://wks-15103:8010/ps/ng-components/examples/ps-checkbox.html'
    var main_checkbox = element(by.xpath("//div[@ng-model='My_Group']/div[1]/span/span[1]"));
    var checkbox_list …
Run Code Online (Sandbox Code Playgroud)

testing filtering cycle angularjs protractor

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

量角器:如何通过执行js脚本返回元素?

我的目标是返回元素的下拉列表。我试图用量角器的方法做到这一点,但是我没有找到简单的方法来搜索跨距元素。因此,我想使用javasript代码:

var my_js_element = browser.executeScript(jQuery("td.ng-binding>div.b-combobox.ps-list-drop-single-autocomplete.ng-isolate-scope.ng-pristine.ng-required.ng-invalid.ng-invalid-required").isolateScope().psListDrop.toggleVisible(true).element);
Run Code Online (Sandbox Code Playgroud)

但这不起作用。而且我不确定是否可以使用此方法返回元素。是真的吗 也许有人知道我该怎么做?

javascript angularjs selenium-webdriver protractor

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