私の目標は特定の要素のcss width
を引っ張ることです。分度器のロケータの問題
私はクロームコンソールで使用し、実際のjQueryコマンドがうまく機能:
Message:
Failed: element(...).first is not a function
:
$('div-grid-directive[grid-name="SAT"] .qMinus1_resize_expand').first().css('width');
"0px"
しかし、勝利7に分度器を実行すると、私は次のエラーを取得しています、プロンプトを表示CMDエラーが私のオブジェクトのページに表示されますtopNav.icons.page.js、this.getQMinus1Column
:
module.exports = function(){
this.clickExpandRowsIcon = function(){
$('.resize-btns > .glyphicon.glyphicon-resize-horizontal').click();
browser.driver.sleep(2000);
};
this.getQMinus1Column = function(){
return element(by.css('div-grid-directive[grid-name="SAT"] .qMinus1_resize_expand')).first();
};
};
と私のSAT.spec.jsファイル:
var IndexPage = require('./pageObjects/index.page.js');
var TopNavBar = require('./pageObjects/topNav.icons.page.js');
describe('Testing the Sales & Trading Top Nav grid icons', function(){
var indexPage = new IndexPage();
var topNavBar = new TopNavBar();
beforeEach(function() {
indexPage.get(); // Launches app !!
});
describe('Clicking on the Expand Rows icon', function() {
it('Should horizontally expand previous quarters qMinus1 thru qMinus6', function() {
topNavBar.clickExpandRowsIcon();
var elem = topNavBar.getQMinus1Column();
expect(elem).getCssValue().indexOf('width: 5px;').not.toBe('-1');
\t });
});
});
だから私もcss width
属性を取得しようとする前に、私はfirst()
を返すために苦労しています、この形式を使用して:
return element(by.css('MY-CSS')).first();
この行ではあまりにも多くのことが起こっているのでしょうか、あるいは分度器の構文が間違っているのでしょうか?
return element(by.css('div-grid-directive[grid-name="SAT"] .qMinus1_resize_expand')).first();
この場合も、コンソールツールでjQueryを使用して同じ構文が働くため、CSSの選択は正しいです。アドバイスが大幅にここでは高く評価され
...
に関して、 ボブthisあたりとして
使用する場合がありますコード):https://github.com/alecxe/eslint-plugin-protractor/issues/55。 – alecxe