Advertisement
Guest User

login

a guest
Nov 4th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.25 KB | None | 0 0
  1. contacts.spec
  2.  
  3. 'use strict';
  4.  
  5. const pageObject = require('./../../services').container.PageObject;
  6. const signInPage = pageObject.getSignInPage();
  7. const dashboardPage = pageObject.getDashboardPage();
  8. const editTicketPage = pageObject.getEditTicketPage();
  9. const addCompanyPage = pageObject.getAddCompanyPage();
  10. const addContactsPage = pageObject.getAddContactPage();
  11. const contactsPage = pageObject.getContactsPage();
  12. const jobCodePage = pageObject.getJobCodePage();
  13. const signInData = require('./../../data/sign_in');
  14. const dashboardData = require('./../../data/dashboard');
  15. const commonHelper = require('./../../services/helpers/common.helper');
  16. var strftime = require('strftime');
  17.  
  18. describe('Dashboard', () => {
  19.  
  20. var username = signInData.testAccount.username;
  21. var password = signInData.testAccount.password;
  22.  
  23. beforeAll(() => {
  24. browser.ignoreSynchronization = false;
  25. browser.driver.manage().window().setSize(1440, 900);
  26. });
  27.  
  28. afterAll(() => {
  29. commonHelper.clearAllData();
  30. });
  31.  
  32. /*describe('checking for add contacts from menu', () => {
  33.  
  34. var time = commonHelper.uniqueValue();
  35.  
  36. beforeAll(() => {
  37. browser.get(signInData.link);
  38. });
  39.  
  40. afterAll(() => {
  41. commonHelper.clearAllData();
  42. });
  43.  
  44. it('should open login page', () => {
  45. expect(signInPage.btnLogin.isDisplayed()).toBe(true);
  46. });
  47.  
  48. it('should redirect on dashboard page after login', () => {
  49. signInPage.login(username, password);
  50. commonHelper.waitUntilElementPresent(dashboardPage.menu);
  51.  
  52. expect(dashboardPage.pageTittle.getText()).toEqual(dashboardData.title);
  53. });
  54.  
  55. it('should click on contacts from menu', () => {
  56. dashboardPage.openMenu('Contacts');
  57.  
  58. expect(dashboardPage.pageTittle.getText()).toEqual('Contacts');
  59. });
  60.  
  61. it('should click on add contacts', () => {
  62. contactsPage.btnAddContacts.click();
  63.  
  64. commonHelper.waitUntilElementVisible(addContactsPage.txtContactName);
  65. });
  66.  
  67. it('should add contacts', () => {
  68. addContactsPage.txtContactName.sendKeys('Gabe' + time);
  69. addContactsPage.txtContactLastName.sendKeys('Malcovich'+ time);
  70. addContactsPage.txtContactTitte.sendKeys('QA' + time);
  71. addContactsPage.selectContactCompany('Chevron');
  72. contactsPage.selectContactOffices('Chevron Corporate Offices');
  73. addContactsPage.txtContactNumber.sendKeys(time);
  74. addContactsPage.txtContactEmail.sendKeys(time + '@mailinator.com');
  75. });
  76.  
  77. it('should save contacts', () => {
  78. addContactsPage.saveCompany();
  79. });
  80.  
  81. it('should search contacts', () => {
  82. jobCodePage.txtSearchCode.sendKeys(time);
  83.  
  84. commonHelper.waitUntilElementVisible(jobCodePage.searchCode(time));
  85. });
  86.  
  87. it('should see contacts details',()=>{
  88. jobCodePage.btnDetailsJobe.click();
  89.  
  90. expect(contactsPage.getTable('QA' + time));
  91. expect(addContactsPage.getTable(time + '@mailinator.com'));
  92. expect(addContactsPage.getTable(time));
  93. expect(contactsPage.getTable('Gabe' + time + ' Malcovich'+ time));
  94. });
  95. });*/
  96.  
  97. describe('checking for add company from menu', () => {
  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 contacts from menu', () => {
  121. dashboardPage.openMenu('Contacts');
  122.  
  123. expect(dashboardPage.pageTittle.getText()).toEqual('Contacts');
  124. });
  125.  
  126. it('should click on companies tab', () => {
  127. browser.sleep(5000);
  128. contactsPage.tabCompanies.click();
  129.  
  130. commonHelper.waitUntilElementVisible(contactsPage.btnAddOffice);
  131. });
  132.  
  133. it('should click on add office', () => {
  134. contactsPage.btnAddOffice.click();
  135.  
  136. //commonHelper.waitUntilElementVisible(addContactsPage.txtOfficeName);
  137. browser.sleep(5000);
  138. });
  139.  
  140. it('should add company', () => {
  141. // contactsPage.selectContactOffices('Chevron');
  142. contactsPage.txtOfficeName.sendKeys('Batcave' + time);
  143. contactsPage.selectRegion('Roosevelt');
  144. contactsPage.txtOfficePhone.sendKeys(time);
  145. contactsPage.txtOfficeATTN.sendKeys('Inc.' + time);
  146. contactsPage.txtOfficeLine1.sendKeys(time);
  147. contactsPage.txtOfficeLine2.sendKeys(time);
  148. contactsPage.txtOfficeCity.sendKeys('Lyon' + time);
  149. contactsPage.txtOfficeState.sendKeys('Minnesota' + time);
  150. contactsPage.txtOfficeZipcode.sendKeys(time);
  151. contactsPage.txtOfficeCountry.sendKeys('Country' + time);
  152. });
  153.  
  154. it('should save contacts', () => {
  155. addContactsPage.saveCompany();
  156. });
  157.  
  158. it('should search contacts', () => {
  159. jobCodePage.txtSearchCode.sendKeys(time);
  160.  
  161. commonHelper.waitUntilElementVisible(jobCodePage.searchCode(time));
  162. });
  163.  
  164. it('should see contacts details',()=>{
  165. jobCodePage.btnDetailsJobe.click();
  166. });
  167. });
  168. });
  169.  
  170. ----------------------------------------------------
  171. contact.po
  172.  
  173. 'use strict';
  174.  
  175. const commonHelper = require('./helpers/common.helper');
  176.  
  177. class ContactsPage {
  178. constructor() {
  179. this.btnAddContacts = $('[aria-label="Add Contact"]');
  180. this.btnAddOffice = $('[aria-label="Add Office"]');
  181. this.txtContactsOffices = $('[aria-label="Company"]');
  182. this.txtOfficeCompany = $('[aria-label="Offices"]');
  183. this.txtOfficeName = element(by.model('office.name'));
  184. this.txtOfficeRegion = element(by.model('office.region'));
  185. this.txtOfficePhone = element(by.model('office.phone_number'));
  186. this.txtOfficeATTN = element(by.model('office.address.attn_line'));
  187. this.txtOfficeLine1 = element(by.model('office.address.line1'));
  188. this.txtOfficeLine2 = element(by.model('office.address.line2'));
  189. this.txtOfficeCity = element(by.model('office.address.city'));
  190. this.txtOfficeState = element(by.model('office.address.state'));
  191. this.txtOfficeZipcode = element(by.model('office.address.zipcode'));
  192. this.txtOfficeCountry = element(by.model('office.address.country'));
  193. this.tabCompanies = element(by.cssContainingText("md-tab-item span", "Companies"));
  194. }
  195.  
  196. getTable(name){
  197. return element(by.xpath('//div[containd(@class, "md-list-item-text")]/*[contains(,."'+ name +'")]'));
  198. }
  199.  
  200. selectContactOffices(name){
  201. browser.waitForAngular();
  202. commonHelper.waitUntilElementVisible(this.txtOfficeCompany);
  203. browser.sleep(1000);
  204. this.txtOfficeCompany.click();
  205. browser.sleep(2000);
  206. element(by.xpath('//div[contains(@class, "md-select-menu-container md-oc-theme md-active md-clickable")]//*[contains(@class,"ng-scope md-checkbox-enabled md-ink-ripple")]//*[contains(.,"'+ name +'")]')).click();
  207. browser.executeScript('document.getElementsByClassName("md-select-menu-container md-oc-theme md-active md-clickable")[0].style.display = "none"')
  208. }
  209.  
  210. selectCompanyType(type){
  211. browser.waitForAngular();
  212. commonHelper.waitUntilElementVisible(this.txtCompanyType);
  213. browser.sleep(1000);
  214. this.txtCompanyType.click();
  215. browser.sleep(2000);
  216. element(by.xpath('//div[contains(@class, "md-select-menu-container")]//div[contains(.,"'+ type +'")]')).click();
  217. }
  218.  
  219. selectRegion(type){
  220. browser.waitForAngular();
  221. commonHelper.waitUntilElementVisible(this.txtOfficeRegion);
  222. browser.sleep(1000);
  223. this.txtOfficeRegion.click();
  224. browser.sleep(2000);
  225. element(by.xpath('//div[contains(@class, "md-select-menu-container")]//div[contains(.,"'+ type +'")]')).click();
  226. }
  227. }
  228.  
  229. module.exports = ContactsPage;
  230. -------------------------------------------------------------------------------------
  231. dashboard.po
  232.  
  233. 'use strict';
  234.  
  235. class DashboardPage {
  236. constructor() {
  237. this.menu = $('[role="navigation"]');
  238. this.pageTittle = $('h1');
  239. this.btnPlus = $('#btn-add');
  240. this.btnJobCode = $('[href="/job_codes/"]');
  241. this.btnAddCompany = $('[href="/companies/add/"]');
  242. this.btnDetails = $('[aria-label="Details"]');
  243. this.btnAddContacts = $('[href="/contacts/add/"]');
  244. this.btnSku = $('[href="/oil_field/sku"]');
  245. this.btnWells = $('[href="/oil_field/wells"]');
  246. this.btnEdit = $('[aria-label="Edit"]');
  247. this.btnUser = $('[ng-show="user"]');
  248. this.btnLogout = $('[ng-click="logout()"]');
  249. }
  250.  
  251. openMenu(menuItem) {
  252. element(by.xpath('//*[@class="nav-label ng-binding"][text()="' + menuItem + '"]')).click()
  253. }
  254.  
  255. selectItem(item) {
  256. element(by.xpath('//a[text()="' + item + '"]')).click()
  257. }
  258. }
  259. module.exports = DashboardPage;
  260. --------------------------------------------------------------------
  261. sing_in.spec
  262.  
  263. 'use strict';
  264.  
  265. const pageObject = require('./../../services').container.PageObject;
  266. const signInPage = pageObject.getSignInPage();
  267. const dashboardPage = pageObject.getDashboardPage();
  268. const signInData = require('./../../data/sign_in');
  269. const dashboardData = require('./../../data/dashboard');
  270. const commonHelper = require('./../../services/helpers/common.helper');
  271.  
  272. describe('Sign In', () => {
  273.  
  274. var username = signInData.testAccount.username;
  275. var password = signInData.testAccount.password;
  276. var incorrectUser = signInData.incorrectAccount.username;
  277. var incorrectPass = signInData.incorrectAccount.password;
  278. var incorrectMessage = signInData.incorrectMessage;
  279.  
  280. beforeAll(() => {
  281. browser.ignoreSynchronization = false;
  282. browser.driver.manage().window().setSize(1440, 900);
  283. });
  284.  
  285. afterAll(() => {
  286. commonHelper.clearAllData();
  287. });
  288.  
  289. describe('checking for logout', () => {
  290.  
  291. beforeAll(() => {
  292. browser.get(signInData.link);
  293. });
  294.  
  295. afterAll(() => {
  296. commonHelper.clearAllData();
  297. });
  298.  
  299. it('should open login page', () => {
  300. expect(signInPage.btnLogin.isDisplayed()).toBe(true);
  301. });
  302.  
  303. it('should redirect on dashboard page after login', () => {
  304. signInPage.login(username, password);
  305. commonHelper.waitUntilElementPresent(dashboardPage.menu);
  306.  
  307. expect(dashboardPage.pageTittle.getText()).toEqual(dashboardData.title);
  308. });
  309.  
  310. it('should logout', () => {
  311. dashboardPage.btnUser.click();
  312. dashboardPage.btnLogout.click();
  313.  
  314. commonHelper.waitUntilElementVisible(signInPage.btnLogin);
  315. });
  316. });
  317.  
  318. describe('checking for login as valid user', () => {
  319.  
  320. beforeAll(() => {
  321. browser.get(signInData.link);
  322. });
  323.  
  324. afterAll(() => {
  325. commonHelper.clearAllData();
  326. });
  327.  
  328. it('should open login page', () => {
  329. expect(signInPage.btnLogin.isDisplayed()).toBe(true);
  330. });
  331.  
  332. it('should redirect on dashboard page after login', () => {
  333. signInPage.login(username, password);
  334. commonHelper.waitUntilElementPresent(dashboardPage.menu);
  335.  
  336. expect(dashboardPage.pageTittle.getText()).toEqual(dashboardData.title);
  337. });
  338. });
  339.  
  340. describe('checking for login as invalid user', () => {
  341.  
  342. beforeAll(() => {
  343. browser.get(signInData.link);
  344. });
  345.  
  346. afterAll(() => {
  347. commonHelper.clearAllData();
  348. });
  349.  
  350. it('should open login page', () => {
  351. expect(signInPage.btnLogin.isDisplayed()).toBe(true);
  352. });
  353.  
  354. it('should click login', () => {
  355. signInPage.btnLogin.click();
  356.  
  357. expect(dashboardPage.menu.isPresent()).toBe(false);
  358. expect(signInPage.btnLogin.isDisplayed()).toBe(true);
  359. });
  360.  
  361. it('should redirect on dashboard page after login', () => {
  362. signInPage.login(incorrectUser, incorrectPass);
  363.  
  364. expect(signInPage.errorLogin(incorrectMessage));
  365. });
  366. });
  367. });
  368. --------------------------------------------------------
  369. sing_in.po
  370.  
  371. 'use strict';
  372.  
  373. class SignInPage {
  374.  
  375. constructor() {
  376. this.txtUsername = element(by.model('credentials.username'));
  377. this.txtPassword = element(by.model('credentials.password'));
  378. this.btnLogin = $('[type="submit"]');
  379. }
  380.  
  381. errorLogin(name){
  382. return element(by.xpath('//p[contains(.,"'+name+'")]'));
  383. }
  384.  
  385. login(email, password) {
  386. this.fillEmailField(email);
  387. this.fillPasswordField(password);
  388. this.btnLogin.click();
  389. }
  390.  
  391. fillEmailField(email) {
  392. this.txtUsername.clear();
  393. this.txtUsername.sendKeys(email);
  394. }
  395.  
  396. fillPasswordField(password) {
  397. this.txtPassword.clear();
  398. this.txtPassword.sendKeys(password);
  399. }
  400. }
  401.  
  402. module.exports = SignInPage;
  403. -------------------------------------------------------------
  404. data/sing_in/index
  405.  
  406. 'use strict';
  407.  
  408. module.exports = {
  409. link: browser.baseUrl + '/login/',
  410. testAccount: {
  411. username: 'Testing',
  412. password: 'testtest'
  413. },
  414. incorrectAccount: {
  415. username: 'username',
  416. password: 'password'
  417. },
  418. incorrectMessage: 'Unable to log in with provided credentials'
  419. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement