グリッドに値が追加されているかどうかを確認するコード(クレジット@kishanpatel)Traverse-through-each-row-for-a-column-textがあります。私はこれを私のページオブジェクトに入れたいと思う。私はページオブジェクトに要素を追加することを考えていましたが、セレンに似た別のヘルパーファイルにif条件を入れましたが、私は正しいappraochであるかどうかはわかりません。以下の詳細を参照してください。分度器でpageobjectモデルに検証を入れる方法
mo.helperをspec.tsで呼び出すと、gridcheck.ispresent()
は機能ではないというメッセージが表示されます。このシナリオをどのように処理するのですか?
コード:
it('verify the grid that master obligation is added', function() { var testvar = "'test_protractor'"; var row_check = element(by.xpath("//div[contains(text()," + testvar + ")]")); if (row_check.isPresent()) { row_check.getText().then(function (msg) { if (row_check.isPresent()) { console.log("Grid contains========== " + msg); } }); } });
iはmo.tsに以下の方法(ページオブジェクトのページ)を有する:
this.grid = function (value) {
// var testvar = "'test_protractor'";
var row_check = element(by.xpath("//div[contains(text()," + value + ")]"));
return require('./mohelper.ts')
}
}
mohelper.ts:
require('../page/mo.ts')
var mohelper = function() {
this.gridvaluepresent = function() {
require('../page/mo.ts')
var gridcheck = mo.grid();
if(gridcheck.isPresent()) {
gridcheck.getText().then(function (msg) {
if (gridcheck.isPresent()) {
console.log("Grid contains========== " + msg);
}
})
}
}
}
module.exports = new mohelper();
spec.ts:考慮すべきここで、物事の
it('go to corresponding module and verify whether the master obligation is added ', function() {
browser.sleep(10000);
taxhome.selectmodule;
taxhome.selectmoduledropdown(1);
mo.grid("test_protractor");
mohelper.gridvaluepresent();
});
に上記を理解するためにあなたの参照のためのリンクをご覧くださいエッシー。私に「taxhome」を見せてください。選択モジュール。 taxhome.selectmoduledropdown(1); 'ヘルパーファイル。また、 'var row_check = element(by.xpath(" // div [(text()、 "+ value +")] ")); return require( './mohhelper.ts') 'は、' 'var row_check = element(by.xpath(" //(div)を含む "+ value +")] ")でなければなりません。 return row_check ' –
tax.selectmoduleは、モジュールがロードされていることを確認するもう1つのステップです。私は質問にヘルパーファイルを添付しています。参照mohelper.ts参照してください。 this.module = function(){ var elem =要素(by.linkText( 'FATCA(201) - 07')) var EC = protractor.ExpectedConditions; browser.wait(EC.visibilityOf(elem)); } this.selectmodule = function(){ 要素(by.id( 's2id_TaxProcessMod'))。 } – kavitha
もし私がreturn row_checkとして更新するなら、それはrowentriesを返していて、ヘルパーファイルで述べたように検証しません。 conf.tsで渡された値さえもmo.grid関数に渡されません。私は "test_protractor"に合格しましたが、出力では未定義に対して検証されました – kavitha