Advertisement
Guest User

oil

a guest
Oct 20th, 2016
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.99 KB | None | 0 0
  1. dashboardPage
  2.  
  3. const commonHelper = require('./helpers/common.helper');
  4.  
  5. class DashboardPage {
  6. constructor() {
  7. this.menu = $('[role="navigation"]');
  8. this.pageTittle = $('h1');
  9. this.btnPlus = $('#btn-add');
  10. this.btnAddCompany = $('[href="/companies/add/"]');
  11. this.companyTitle = $('h3');
  12. this.txtCompanyName = $('[ng-model="company.name"]');
  13. this.txtCompanySite = $('[ng-model="company.website"]');
  14. this.txtCompanyNote = $('[ng-model="company.notes"]');
  15. this.txtCompanyType = $('[ng-model="company.kind"]');
  16. this.btnSaveCompany = $('[aria-label="Save"]');
  17. this.btnAddContacts = $('[href="/contacts/add/"]');
  18. this.txtSeachCompany = $('[ng-change="getCompanies()"]');
  19. this.imageCompany = $('[src="company.icon_path"]');
  20. this.btnDetails = $('[aria-label="Details"]');
  21. this.txtContactName = $('[ng-model="contact.first_name"]');
  22. this.txtContactLastName = $('[ng-model="contact.last_name"]');
  23. this.txtContactTitte = $('[ng-model="contact.title"]');
  24. this.txtContactNumber = $('[ng-model="contact.phone_number"]');
  25. this.txtContactEmail = $('[ng-model="contact.email"]');
  26. this.txtContactsCompany = $('[ng-model="contact.company"]');
  27. this.txtContactsOffices = $('[ng-model="contact.offices"]');
  28. this.txtSeachContacts = $('[ng-change="getCallers()"]');
  29.  
  30. }
  31.  
  32. selectContactOffices(name){
  33. browser.waitForAngular();
  34. commonHelper.waitUntilElementVisible(this.txtContactsOffices);
  35. browser.sleep(1000);
  36. this.txtContactsOffices.click();
  37. browser.sleep(2000);
  38. element(by.xpath('//div[contains(@class, "md-select-menu-container")]//div[contains(.,"'+ name +'")]')).click();
  39. }
  40.  
  41. selectContactCompany(name){
  42. browser.waitForAngular();
  43. commonHelper.waitUntilElementVisible(this.txtContactsCompany);
  44. browser.sleep(1000);
  45. this.txtContactsCompany.click();
  46. browser.sleep(2000);
  47. element(by.xpath('//div[contains(@class, "md-select-menu-container")]//div[contains(.,"'+ name +'")]')).click();
  48. }
  49.  
  50. searchCompany(name){
  51. return element(by.xpath('//*[contains(@class, "md-cell ng-binding")][contains(.,"'+ name +'")]'));
  52. }
  53.  
  54. selectCompanyType(type){
  55. browser.waitForAngular();
  56. commonHelper.waitUntilElementVisible(this.txtCompanyType);
  57. browser.sleep(1000);
  58. this.txtCompanyType.click();
  59. browser.sleep(2000);
  60. element(by.xpath('//div[contains(@class, "md-select-menu-container")]//div[contains(.,"'+ type +'")]')).click();
  61. }
  62. ----------------------------------
  63. dashboard.spec
  64.  
  65. 'use strict';
  66.  
  67. const pageObject = require('./../../services').container.PageObject;
  68. const signInPage = pageObject.getSignInPage();
  69. const dashboardPage = pageObject.getDashboardPage();
  70. const ticketsPage = pageObject.getTicketsPage();
  71. const editTicketPage = pageObject.getEditTicketPage();
  72. const signInData = require('./../../data/sign_in');
  73. const dashboardData = require('./../../data/dashboard');
  74. const ticketsData = require('./../../data/tickets');
  75. const commonHelper = require('./../../services/helpers/common.helper');
  76. var strftime = require('strftime');
  77.  
  78. describe('Dashboard', () => {
  79.  
  80. var username = signInData.testAccount.username;
  81. var password = signInData.testAccount.password;
  82.  
  83. beforeAll(() => {
  84. browser.ignoreSynchronization = false;
  85. browser.driver.manage().window().setSize(1440, 900);
  86. });
  87.  
  88. afterAll(() => {
  89. commonHelper.clearAllData();
  90. });
  91.  
  92. describe('checking for add company', () => {
  93.  
  94. var time = commonHelper.uniqueValue();
  95.  
  96. beforeAll(() => {
  97. browser.get(signInData.link);
  98. });
  99.  
  100. afterAll(() => {
  101. commonHelper.clearAllData();
  102. });
  103.  
  104. it('should open login page', () => {
  105. expect(signInPage.btnLogin.isDisplayed()).toBe(true);
  106. });
  107.  
  108. it('should redirect on dashboard page after login', () => {
  109. signInPage.login(username, password);
  110. commonHelper.waitUntilElementPresent(dashboardPage.menu);
  111.  
  112. expect(dashboardPage.pageTittle.getText()).toEqual(dashboardData.title);
  113. });
  114.  
  115. it('should click on add company', () => {
  116. dashboardPage.btnAddCompany.click();
  117. expect(dashboardPage.companyTitle.getText()).toEqual('Add Company');
  118. });
  119.  
  120. it('should add company', () => {
  121. dashboardPage.txtCompanyName.sendKeys('name' + time);
  122. dashboardPage.txtCompanySite.sendKeys('site'+ time);
  123. dashboardPage.selectCompanyType('Service');
  124. dashboardPage.txtCompanyNote.sendKeys('note' + time);
  125. });
  126.  
  127. it('should add icon company',() => {
  128. editTicketPage.uploadAttachment('index.jpg');
  129. dashboardPage.btnSaveCompany.click();
  130. expect(dashboardPage.imageCompany.isDisplayed()).toBe(true);
  131. });
  132.  
  133. it('should redirect to dashboard',() => {
  134. dashboardPage.openMenu('Dashboard');
  135. expect(dashboardPage.pageTittle.getText()).toEqual(dashboardData.title);
  136. });
  137.  
  138. it('should search company',() => {
  139. dashboardPage.txtSeachCompany.sendKeys('name' + time);
  140. commonHelper.waitUntilElementVisible(dashboardPage.searchCompany('name' + time));
  141. });
  142.  
  143. it('should see company details',() => {
  144. dashboardPage.btnDetails.click();
  145. expect(dashboardPage.pageTittle.getText()).toEqual('Name' + time);
  146. });
  147.  
  148. });
  149.  
  150. describe('checking for add contacts', () => {
  151.  
  152. var time = commonHelper.uniqueValue();
  153.  
  154. beforeAll(() => {
  155. browser.get(signInData.link);
  156. });
  157.  
  158. afterAll(() => {
  159. commonHelper.clearAllData();
  160. });
  161.  
  162. it('should open login page', () => {
  163. expect(signInPage.btnLogin.isDisplayed()).toBe(true);
  164. });
  165.  
  166. it('should redirect on dashboard page after login', () => {
  167. signInPage.login(username, password);
  168. commonHelper.waitUntilElementPresent(dashboardPage.menu);
  169.  
  170. expect(dashboardPage.pageTittle.getText()).toEqual(dashboardData.title);
  171. });
  172.  
  173. it('should click on add contacts', () => {
  174. dashboardPage.btnAddContacts.click();
  175. // expect(dashboardPage.companyTitle.getText()).toEqual('Add Contact');
  176. });
  177.  
  178. it('should add contacts', () => {
  179. dashboardPage.txtContactName.sendKeys('name' + time);
  180. dashboardPage.txtContactLastName.sendKeys('lastname'+ time);
  181. dashboardPage.txtContactTitte.sendKeys('tittle' + time);
  182. dashboardPage.selectContactCompany('Chevron');
  183. dashboardPage.selectContactOffices('Chevron Corporate Offices');
  184. dashboardPage.txtContactNumber.sendKeys('number' + time);
  185. dashboardPage.txtContactEmail.sendKeys('email'+time);
  186. });
  187.  
  188. it('should save contacts', () => {
  189. dashboardPage.btnSaveCompany.click();
  190. });
  191.  
  192. it('should redirect to dashboard',() => {
  193. dashboardPage.openMenu('Dashboard');
  194. expect(dashboardPage.pageTittle.getText()).toEqual(dashboardData.title);
  195. });
  196.  
  197. it('should search contacts',() => {
  198. dashboardPage.txtSeachContacts.sendKeys('name' + time);
  199. commonHelper.waitUntilElementVisible(dashboardPage.searchCompany('name' + time));
  200. });
  201.  
  202. it('should see contacts details',() => {
  203. dashboardPage.btnDetails.click();
  204. expect(dashboardPage.pageTittle.getText()).toEqual('Name' + time);
  205. });
  206. });
  207. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement