Advertisement
Guest User

all

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