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);
这是我的测试
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);
这里的部分
在count为1之后,表示我只选择了一个产品(md-checbox),这意味着选择了产品,以便按钮现在处于活动状态。禁用之前
disabled="disabled"
它有。当我选择时,这已经消失了。
但是一旦它进入我的测试或我的课程页面,就会出错。它不会运行代码,因为它不会等待。
它失败了。
我使用isvisible ispresentof但仍然相同
错误是针对此代码,“失败:无法读取未定义的属性'isPresent'”
但我没有ispresent
在我只有2个类之前,现在我根据对话框和制表符分隔了类,现在就开始了这个错误。
我可以看到“ss”作为输出但是
browser.sleep(6222);console.log("ss");
睡了6秒钟。 İt不去那里。它检查我认为之前的所有变量。
更新
ınsteadproductdialog.confirmdialog
我把真正的价值
element.all(by.buttonText('Görev Oluştur')).first()element.all(by.buttonText('Görev Oluştur')).first()
它有效。
为什么?
它在这里,仍在这里,但现在没有使用
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();
};
答案 0 :(得分:1)
您的public void downloadFile(String uRl) {
File direct = new File(Environment.getExternalStorageDirectory()
+ "/" + "MyFolder");
if (!direct.exists()) {
direct.mkdirs();
}
DownloadManager mgr = (DownloadManager) getSystemService(this.DOWNLOAD_SERVICE);
Uri downloadUri = Uri.parse(uRl);
DownloadManager.Request request = new DownloadManager.Request(downloadUri);
request.setAllowedNetworkTypes(
DownloadManager.Request.NETWORK_WIFI
| DownloadManager.Request.NETWORK_MOBILE)
.setAllowedOverRoaming(false)
.setTitle("AppNameAsTitle")
.setDescription("Downloaded using My app")
.setDestinationInExternalPublicDir("/MyFolder", "filename.jpg")
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
mgr.enqueue(request);
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
downloadFile(url);
} else {
Toast.makeText(this, "Permission not granted", Toast.LENGTH_SHORT).show();
}
}
页面对象中未定义createTaskButton
字段。
您遇到此类错误,因为elementToBeClickable
expected condition函数会检查某个元素是否可见,显示并已启用在元素上调用productDialogPage
和isPresent()
。这是related code,最终会抛出错误:
isEnabled()
您正在将presenceOf(elementFinder: ElementFinder): Function {
return elementFinder.isPresent.bind(elementFinder);
};
变量传递给预期的条件:
elm
其中browser.wait(EC.elementToBeClickable(elm, 6222));
定义为:
elm
并且,根据症状判断,var elm = productDialogPage.createTaskButton;
获得elm
值,这意味着undefined
页面对象中没有createTaskButton
字段。