2
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);

This is my test:

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);

After count is 1, it means I selected only one product (md-checbox), it means product is selected so that button is active now. Earlier it was disabled.

 disabled="disabled">

When I select, this is gone.

But as soon as it enters my test or my class page, it gives error. it doesn't run code because it doesn't wait.

It gives failure.

I used isvisible ispresentof but still I get the same error for this code:

Failed: Cannot read property 'isPresent' of undefined

But I don't have ispresent.

Before I had 2 classes only, now I separated classes according to dialog and tabs, this error started now. I can see ss as output:

browser.sleep(6222);
console.log("ss");

but there is sleeping 6 seconds. It doesn't go there. It checks I think all variables before.

1
  • 1
    The function isPresent is called by EC.elementToBeClickable. It looks like productDialogPage.createTaskButton is undefined or null. Make sure that elm is an ElementFinder.
    – Florent B.
    Commented Dec 1, 2016 at 19:34

1 Answer 1

1

Can you write the selector of productDialogPage.createTaskButton to see what's really happening? May be you should use another selector after clicking it by the first time.

Also, I recommend you to make some helper functions for wait for actions to happen using the protractor.ExpectedConditions, I have some functions like "waitForElementVibility" or "waitForTextOnElement", etc... this will help you waiting more that what you really need on those browser.sleep() and sometimes the time for something to appear takes more time that the one you specify on sleeps and that would make your test fail.

And for last, this part should be failing due to the capital letter on the expect(ProductDialogPage...), is declared as productDialogPage or ProductDialogPage?

productDialogPage.createTaskButton.click();
expect(ProductDialogPage.confirmDialog.isDisplayed()).toBe(true);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.