Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dashboardPage
- const commonHelper = require('./helpers/common.helper');
- class DashboardPage {
- constructor() {
- this.menu = $('[role="navigation"]');
- this.pageTittle = $('h1');
- this.btnPlus = $('#btn-add');
- this.btnAddCompany = $('[href="/companies/add/"]');
- this.companyTitle = $('h3');
- this.txtCompanyName = $('[ng-model="company.name"]');
- this.txtCompanySite = $('[ng-model="company.website"]');
- this.txtCompanyNote = $('[ng-model="company.notes"]');
- this.txtCompanyType = $('[ng-model="company.kind"]');
- this.btnSaveCompany = $('[aria-label="Save"]');
- this.btnAddContacts = $('[href="/contacts/add/"]');
- this.txtSeachCompany = $('[ng-change="getCompanies()"]');
- this.imageCompany = $('[src="company.icon_path"]');
- this.btnDetails = $('[aria-label="Details"]');
- this.txtContactName = $('[ng-model="contact.first_name"]');
- this.txtContactLastName = $('[ng-model="contact.last_name"]');
- this.txtContactTitte = $('[ng-model="contact.title"]');
- this.txtContactNumber = $('[ng-model="contact.phone_number"]');
- this.txtContactEmail = $('[ng-model="contact.email"]');
- this.txtContactsCompany = $('[ng-model="contact.company"]');
- this.txtContactsOffices = $('[ng-model="contact.offices"]');
- this.txtSeachContacts = $('[ng-change="getCallers()"]');
- }
- selectContactOffices(name){
- browser.waitForAngular();
- commonHelper.waitUntilElementVisible(this.txtContactsOffices);
- browser.sleep(1000);
- this.txtContactsOffices.click();
- browser.sleep(2000);
- element(by.xpath('//div[contains(@class, "md-select-menu-container")]//div[contains(.,"'+ name +'")]')).click();
- }
- selectContactCompany(name){
- browser.waitForAngular();
- commonHelper.waitUntilElementVisible(this.txtContactsCompany);
- browser.sleep(1000);
- this.txtContactsCompany.click();
- browser.sleep(2000);
- element(by.xpath('//div[contains(@class, "md-select-menu-container")]//div[contains(.,"'+ name +'")]')).click();
- }
- searchCompany(name){
- return element(by.xpath('//*[contains(@class, "md-cell ng-binding")][contains(.,"'+ name +'")]'));
- }
- selectCompanyType(type){
- browser.waitForAngular();
- commonHelper.waitUntilElementVisible(this.txtCompanyType);
- browser.sleep(1000);
- this.txtCompanyType.click();
- browser.sleep(2000);
- element(by.xpath('//div[contains(@class, "md-select-menu-container")]//div[contains(.,"'+ type +'")]')).click();
- }
- ----------------------------------
- dashboard.spec
- 'use strict';
- const pageObject = require('./../../services').container.PageObject;
- const signInPage = pageObject.getSignInPage();
- const dashboardPage = pageObject.getDashboardPage();
- const ticketsPage = pageObject.getTicketsPage();
- const editTicketPage = pageObject.getEditTicketPage();
- const signInData = require('./../../data/sign_in');
- const dashboardData = require('./../../data/dashboard');
- const ticketsData = require('./../../data/tickets');
- const commonHelper = require('./../../services/helpers/common.helper');
- var strftime = require('strftime');
- describe('Dashboard', () => {
- var username = signInData.testAccount.username;
- var password = signInData.testAccount.password;
- beforeAll(() => {
- browser.ignoreSynchronization = false;
- browser.driver.manage().window().setSize(1440, 900);
- });
- afterAll(() => {
- commonHelper.clearAllData();
- });
- describe('checking for add company', () => {
- var time = commonHelper.uniqueValue();
- beforeAll(() => {
- browser.get(signInData.link);
- });
- afterAll(() => {
- commonHelper.clearAllData();
- });
- it('should open login page', () => {
- expect(signInPage.btnLogin.isDisplayed()).toBe(true);
- });
- it('should redirect on dashboard page after login', () => {
- signInPage.login(username, password);
- commonHelper.waitUntilElementPresent(dashboardPage.menu);
- expect(dashboardPage.pageTittle.getText()).toEqual(dashboardData.title);
- });
- it('should click on add company', () => {
- dashboardPage.btnAddCompany.click();
- expect(dashboardPage.companyTitle.getText()).toEqual('Add Company');
- });
- it('should add company', () => {
- dashboardPage.txtCompanyName.sendKeys('name' + time);
- dashboardPage.txtCompanySite.sendKeys('site'+ time);
- dashboardPage.selectCompanyType('Service');
- dashboardPage.txtCompanyNote.sendKeys('note' + time);
- });
- it('should add icon company',() => {
- editTicketPage.uploadAttachment('index.jpg');
- dashboardPage.btnSaveCompany.click();
- expect(dashboardPage.imageCompany.isDisplayed()).toBe(true);
- });
- it('should redirect to dashboard',() => {
- dashboardPage.openMenu('Dashboard');
- expect(dashboardPage.pageTittle.getText()).toEqual(dashboardData.title);
- });
- it('should search company',() => {
- dashboardPage.txtSeachCompany.sendKeys('name' + time);
- commonHelper.waitUntilElementVisible(dashboardPage.searchCompany('name' + time));
- });
- it('should see company details',() => {
- dashboardPage.btnDetails.click();
- expect(dashboardPage.pageTittle.getText()).toEqual('Name' + time);
- });
- });
- describe('checking for add contacts', () => {
- var time = commonHelper.uniqueValue();
- beforeAll(() => {
- browser.get(signInData.link);
- });
- afterAll(() => {
- commonHelper.clearAllData();
- });
- it('should open login page', () => {
- expect(signInPage.btnLogin.isDisplayed()).toBe(true);
- });
- it('should redirect on dashboard page after login', () => {
- signInPage.login(username, password);
- commonHelper.waitUntilElementPresent(dashboardPage.menu);
- expect(dashboardPage.pageTittle.getText()).toEqual(dashboardData.title);
- });
- it('should click on add contacts', () => {
- dashboardPage.btnAddContacts.click();
- // expect(dashboardPage.companyTitle.getText()).toEqual('Add Contact');
- });
- it('should add contacts', () => {
- dashboardPage.txtContactName.sendKeys('name' + time);
- dashboardPage.txtContactLastName.sendKeys('lastname'+ time);
- dashboardPage.txtContactTitte.sendKeys('tittle' + time);
- dashboardPage.selectContactCompany('Chevron');
- dashboardPage.selectContactOffices('Chevron Corporate Offices');
- dashboardPage.txtContactNumber.sendKeys('number' + time);
- dashboardPage.txtContactEmail.sendKeys('email'+time);
- });
- it('should save contacts', () => {
- dashboardPage.btnSaveCompany.click();
- });
- it('should redirect to dashboard',() => {
- dashboardPage.openMenu('Dashboard');
- expect(dashboardPage.pageTittle.getText()).toEqual(dashboardData.title);
- });
- it('should search contacts',() => {
- dashboardPage.txtSeachContacts.sendKeys('name' + time);
- commonHelper.waitUntilElementVisible(dashboardPage.searchCompany('name' + time));
- });
- it('should see contacts details',() => {
- dashboardPage.btnDetails.click();
- expect(dashboardPage.pageTittle.getText()).toEqual('Name' + time);
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement