So, I am accessing an application. There are multiple employee records. However, there are no duplicate records. I am deleting an employee record and then trying to verify that the employee record has actually deleted. I am trying to find the employee name using xpath and using isPresent function. The problem is that though the employee record is deleted the output is always returning

Employee present: true

Here is the piece of code that I am using:

it('Delete Employee', function() {
        var employeelist_page = login_page.clickLoginButton();
        var greetings = employeelist_page.greetingText();
        var empName = employeelist_page.getEmployeeName('Master Shifu');
        empName.getText().then(function(text) {
            console.log('Empoyee record to be deleted, found: ' + text);
        employeelist_page.getEmployee('Master Shifu').click();
        var EC = protractor.ExpectedConditions;
        browser.wait(EC.alertIsPresent(), 5000, "Alert is not getting present :(")
                    var employeelist_page1 = require('../page/employeelist_page.js');
                    employeelist_page1.getEmployee('Master Shifu').isPresent().then(function(isPresent){
                            console.log('Employee present: true');
                        } else {
                            console.log('Employee present: false');


Here is the output:

*Empoyee record to be deleted, found: Master Shifu

Employee present: true

Here is the list of functions in employee page:

var employeelist_page=function(){
        return element('greetings')).getText();
        return require('./create_page.js');
        return require('./edit_page.js');
        //return element(by.cssContainingText("#employee-list > li", empname));
        return element(by.xpath("//ul[@id='employee-list']/li[contains(text(),'" + empname + "')]"));

        //return element(by.cssContainingText("#employee-list > li", empname));
        return element(by.xpath("//ul[@id='employee-list']/li[contains(text(),'" + empname + "')]")).getText();

        //element(by.xpath('//ul[@id="employee-list"]/li[contains(text(),"Vladimir Putin")]')).click();
    //  getEmployee().click();

module.exports=new employeelist_page();
  • Do you mean: Master Shifu or 'Master Shifu' ? – Vishal Aggarwal May 15 at 22:44
  • Yes Vishal, it's 'Master Shifu'. While writing the question I replaced the variable value with this constant and at that time, I forgot the quotes. – Aalok May 16 at 6:03
  • Ok.Please share the 'getEmployee' method code as it is central to this problem. – Vishal Aggarwal May 16 at 20:27
  • Hi Vishal, updated the question to include the functions on Employee page – Aalok May 18 at 0:23
  • Check for 'isDisplayed' instead of 'isPresent'. – Vishal Aggarwal May 18 at 11:21
up vote 1 down vote accepted

Put a expected Condition to wait for page re-load after confirmation of delete pop-up. Basically as I understand ,you need to give sometime to get the element removed from the DOM.

Example Code:

var EC =protractor.ExpectedConditions; 
// Waits for the element with id 'abc' to be no longer present on the dom. 

browser.wait(EC.stalenessOf($('#abc')), 5000,"Element still exists");

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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