我正在尝试优化代码:
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)
我的目标是不计算其深度将高于已知的分支的分支.
我有一个想法让我的配置更灵活.例如,我有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)
或者可能存在另一种有趣的方法来解决这个问题?
我尝试扩展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) 我尝试使用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)
但我总是有同样的错误.我做错了什么?
我尝试用量角器开始测试,现在我遇到了一个问题,我无法解决.
我有这个测试:
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) 我的目标是返回元素的下拉列表。我试图用量角器的方法做到这一点,但是我没有找到简单的方法来搜索跨距元素。因此,我想使用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)
但这不起作用。而且我不确定是否可以使用此方法返回元素。是真的吗 也许有人知道我该怎么做?
angularjs ×5
protractor ×5
asynchronous ×1
cycle ×1
e2e-testing ×1
filtering ×1
haskell ×1
jasmine ×1
javascript ×1
overloading ×1
testing ×1
timeout ×1