Quality Products Quality Products - 15 days ago 6
AngularJS Question

Protractor fails to identify locators in different divs in the the same web page

I'm writing a protractor test script to the following web page.

page

I was trying to reach every field by their own locator. Here is my test script.

describe('Protractor Demo App', function() {
it('should have a title', function() {
browser.get('http://');

//Maximize browser window
var width = 1900;
var height = 1500;
browser.driver.manage().window().setSize(width, height);
browser.driver.sleep(2000);

//Enter username and password
element(by.model('login.user_name')).sendKeys('ooo');
element(by.model('login.password')).sendKeys('1236');
browser.driver.sleep(2000);

//Click login buton
element(by.css('.btn')).click();
browser.driver.sleep(2000);

//Click on image
element(by.css('div.col-lg-2:nth-child(2) > div:nth-child(1) > a:nth-child(1) > i:nth-child(1)')).click();
browser.driver.sleep(5000);

// Click Employee button
element(by.css('body > nav > div.collapse.navbar-collapse > ul:nth-child(1) > li:nth-child(1) > a')).click();
browser.driver.sleep(2000);

// Click Employee Add
element(by.css('body > nav > div.collapse.navbar-collapse > ul:nth-child(1) > li.open > ul > li:nth-child(1) > a')).click();
browser.driver.sleep(2000);

// Employee Details
element.all(by.model('user_master.salutation_id')).each(function (eachElement, index)
{
eachElement.click();
browser.driver.sleep(500);
element(by.css('body > div.container-fluid > div > div > div > div > div > form > div:nth-child(1) > div:nth-child(1) > div.panel-body > div:nth-child(1) > select > option:nth-child(3)')).click();
browser.driver.sleep(500);
}); // Select Salutation

element(by.model('user_master.first_name')).sendKeys('Manuli'); browser.driver.sleep(200);// Enter First Name
element(by.model('user_master.second_name')).sendKeys('Piyalka'); browser.driver.sleep(200);// Enter Second Name
element(by.model('user_master.full_name')).sendKeys('M.P. Manawadu'); browser.driver.sleep(200);// Enter Name with Initials
element(by.model('user_master.dob')).sendKeys('1991-01-26'); browser.driver.sleep(200);// Enter Date of Birth
element(by.model('user_master.nic')).sendKeys('915260489V'); browser.driver.sleep(200);// Enter NIC
browser.driver.sleep(2000);

// Contact Details
element(by.model('user_master.phone_mobile')).sendKeys('0767037512'); browser.driver.sleep(200);// Enter Phone-mobile
element(by.model('user_master.phone_land')).sendKeys('0112277582'); browser.driver.sleep(200);// Enter phone-land
element(by.model('user_master.user_address')).sendKeys('Kurusagoda,Gonapinuwala'); browser.driver.sleep(200);// Enter Address
element(by.model('user_master.email_address')).sendKeys('mpiaylka@et.lk'); browser.driver.sleep(200);// Enter Email
element(by.model('user_master.emer_name')).sendKeys('Manuli'); browser.driver.sleep(200);// Enter Name
element(by.model('user_master.emer_phone')).sendKeys('0767037512'); browser.driver.sleep(200);// Enter Phone Number
browser.driver.sleep(2000);

});
});


But, when I run this app, only the Employee details part is running. Following error occurs.


Message:
Error: Timeout - Async callback was not invoked within timeout specified by
jasmine.DEFAULT_TIMEOUT_INTERVAL.


But, when I comment Employee details part and run, the contact details part runs. What should I do?

Regards.

Answer

Tried using xpath. by.xpath('//button[contains(., "Select None")]') :)