Protractor &引用;失败:无法读取属性';iPresent';“未定义”的定义;
这是我的测试Protractor &引用;失败:无法读取属性';iPresent';“未定义”的定义;,protractor,Protractor,这是我的测试 it('should be able to create a task for a product as a CTA', function () { browser.sleep(6222);browser.sleep(6222);console.log("ss"); productPage.productsTab.click(); expect(productPage.myProductsTab.isDisplayed()).toBeTruthy(); //sel
it('should be able to create a task for a product as a CTA', function () {
browser.sleep(6222);browser.sleep(6222);console.log("ss");
productPage.productsTab.click();
expect(productPage.myProductsTab.isDisplayed()).toBeTruthy();
//select checkbox
productPage.selectProduct.click();
browser.sleep(2222);
var elm = productDialogPage.createTaskButton;
var EC = protractor.ExpectedConditions;
//get count of checked checkboxes, count must 1 be because it selected one product
var checkedCount = productPage.selectedProducts.count();
expect(checkedCount).toBe(1);
browser.sleep(2222);
browser.wait(EC.elementToBeClickable(elm, 6222));
//click task create and expect confirm dialog to be displyed
productDialogPage.createTaskButton.click();
expect(ProductDialogPage.confirmDialog.isDisplayed()).toBe(true);
browser.sleep(2222);
//click yes to confirm creating task and expext dialog to displayed
productDialogPage.yesBtnForConfirmDialog.click();
//expect(taskPageObject.taskDialog.isDisplayed()).toBe(true);
browser.sleep(6222);
//put input areas to task create dialog
this.createTask();
browser.sleep(2222);
这部分
计数为1后,表示我只选择了一个产品(md checbox),表示选择了该产品,所以按钮现在处于活动状态。在它被禁用之前
var elm = productDialogPage.createTaskButton;
var EC = protractor.ExpectedConditions;
//get count of checked checkboxes, count must 1 be because it selected one product
var checkedCount = productPage.selectedProducts.count();
expect(checkedCount).toBe(1);
browser.sleep(2222);
browser.wait(EC.elementToBeClickable(elm, 6222));
//click task create and expect confirm dialog to be displyed
productDialogPage.createTaskButton.click();
expect(ProductDialogPage.confirmDialog.isDisplayed()).toBe(true);
browser.sleep(2222);
它有。当我选择时,它就消失了
但一旦它进入我的测试或我的类页面,它就会给出错误。它不运行代码,因为它不等待
它会导致失败
我用的是isvisible ispresentof,但还是一样
此代码的错误为“失败:无法读取未定义的属性'isPresent'”
但是我现在还没有
以前我只有2个类,现在我根据对话框和选项卡分隔类,这个错误现在开始了
我可以将“ss”视为输出,但
disabled="disabled"
有6秒钟的睡眠时间。İt不去那里。它检查我认为所有变量之前
更新
ınstead productdialog.confirmdialog
我把真正的价值
browser.sleep(6222);console.log("ss");
它是有效的
为什么?
它在这儿,还在这儿,但现在没有用了
element.all(by.buttonText('Görev Oluştur')).first()element.all(by.buttonText('Görev Oluştur')).first()
在productDialogPage
page对象中没有定义createTaskButton
字段
更多信息
之所以会出现这种错误,是因为函数会检查元素是否可见、存在和启用,并调用元素上的isPresent()
和isEnabled()
。这就是最终抛出错误的地方:
var ProductDialogPage = function () {
//confirm dialog for task creating, use with isDisplayed
this.confirmDialog = element.all(by.css('._md.md-default-theme._md-transition-in')).first();
this.yesBtnForConfirmDialog = element.all(by.buttonText('Evet')).first();
};
您正在将elm
变量传递到预期条件:
presenceOf(elementFinder: ElementFinder): Function {
return elementFinder.isPresent.bind(elementFinder);
};
其中elm
定义为:
browser.wait(EC.elementToBeClickable(elm, 6222));
而且,根据症状判断,
elm
获得一个undefined
值,这意味着productDialogPage
Page对象中没有createTaskButton
字段。如果我的元素位于不同的pageObject类中,例如code
Wait commonPage.waitForElementVisible,该怎么办(saveReportsConfiguration按钮元素);code
其中saveReportsConfiguration按钮元素在commonPage中不存在?
var elm = productDialogPage.createTaskButton;