Код, не содержащийся в блоке it, будет поднят наверх и запущен до начала любого блока it, что означает, что ваш тест, вероятно, не будет в ожидаемом состоянии в это время. Попробуйте написать свой код еще раз, но с вашим блоком подсчета внутри него.
require('..\\waitAbsent.js');
require("../node_modules/jasmine-expect/index.js");
var EC = protractor.ExpectedConditions;
describe('Demo_Test For count', function () {
beforeAll(function () {
browser.driver.manage().window().maximize();
browser.get(globalVariables.loginMain);
globalVariables.Email_Input_box.sendKeys(globalVariables.Demo_User);
globalVariables.Password_Input_Box.sendKeys(globalVariables.Demo_PWD);
globalVariables.Submit_Button.click();
browser.wait(EC.invisibilityOf(globalVariables.Submit_Button), 25000, 'submit button is not disappearing yet');
});
it('Dashboard Title Validation', function () {
expect(globalVariables.ESY_DB_Label.isDisplayed());
expect(globalVariables.ESY_DB_Label.getText()).toEqual('HomePage')
});
it("1+1", function () {
//count block
globalVariables.tableData_Dashboard.all(by.tagName("tr")).count().then(function (Count) {
console.log('\n the count of the rows are ' + Count + '\n');
});
//count block end
let i = 1;
let j = i + i;
expect(j).toBe(2);
})
});
Ваш прекрасен на самом деле - Вы могли упростить его до
for k in d1:
if d2.get(k, 0) < l:
print k, d2.get(k, 0)
который является (мне) pythonic и является в значительной степени прямым "переводом" в код Вашего описания.
Если Вы хотите избежать двойного поиска, Вы могли бы сделать
for k in d1:
val = d2.get(k, 0)
if val < l:
print k, val
Можно упростить это при помощи defaultdict. Вызов __ getitem __ на defaultdict возвратит значение "по умолчанию".
from collections import defaultdict
d = defaultdict(int)
print d['this key does not exist'] # will print 0
Другой бит, который Вы могли изменить, не к кнопкам вызова. Словарь реализует проход. Было бы предпочтительно просто записать:
for k in d1:
Вот компактная версия, но Ваш совершенно в порядке:
from collections import defaultdict
d1 = {'a': 1, 'b': 1, 'c': 1, 'd': 1}
d2 = {'a': 90, 'b': 89, 'x': 45, 'd': 90}
l = 90
# The default (==0) is a substitute for the condition "not in d2"
# As daniel suggested, it would be better if d2 itself was a defaultdict
d3 = defaultdict(int, d2)
print [ (k, d3[k]) for k in d1 if d3[k] < l ]
Вывод:
[('c', 0), ('b', 89)]