SHARE
TWEET

Untitled

a guest Jul 19th, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const assert = require('assert');
  2. const chai = require('chai');
  3. const chaiWebdriver = require('chai-webdriverio').default;
  4. chai.use(chaiWebdriver(browser));
  5. global.assert = chai.assert;
  6. expect = chai.expect;
  7. let retailLogin = 'test123' + Math.floor(Math.random() * 99999999) + '@test.com';
  8. let retailPassword = 'passwd';
  9. let wholesaleLogin = 'test123' + Math.floor(Math.random() * 99999999) + 'test.com';
  10. let wholesalePassword = 'passwd';
  11. let elemFio = [
  12.   'ROZNITSA TEST TEST',
  13.   'OPT TEST TEST'
  14. ];
  15. let linkToFollow = [
  16.   'https://gepur.com/',
  17. ];
  18. let elemRadio;
  19. let elemRadioId = [
  20.   '//*[@id="customerform-type"]/div[2]/label/input',
  21.   '//*[@id="customerform-type"]/div[1]/label/input'
  22. ];
  23. let finalUrl;
  24. let referenceUrl = [
  25.   'https://gepur.com/account/show/main',
  26.   'https://en.gepur.com/account/show/main',
  27.   'https://ua.gepur.com/account/show/main'
  28. ];
  29. let accountBtn;
  30. let accountBtnId = [
  31.   '/html/body/header/div/div[1]/noindex/a',
  32.   '/html/body/header/div/div[1]/a'
  33. ]
  34. let registerBtn;
  35. let registerBtn2;
  36. let registerBtn2Id = '//*[@id="w0"]/div[5]/button';
  37.  
  38. async function performReg(link, fio, login, password, radio){
  39.   await browser.url(link);
  40.   accountBtn = await $(accountBtnId[0]);
  41.   await accountBtn.click();
  42.   registerBtn = await $('/html/body/main/div/div[2]/div[2]/div[2]/div/a/button');
  43.   await registerBtn.click();
  44.   elemFio = await $('#customerform-fio');
  45.   let elemEmail = await $('#customerform-email');
  46.   let elemPassword = await $('#customerform-password');
  47.   await elemFio.click();
  48.   await elemFio.setValue(fio);
  49.   await elemEmail.click();
  50.   await elemEmail.setValue(login);
  51.   await elemPassword.click();
  52.   await elemPassword.setValue(password);
  53.   elemRadio = await $(radio);
  54.   await elemRadio.click();
  55.   registerBtn2 = await $(registerBtn2Id);
  56.   await registerBtn2.scrollIntoView();
  57.   // await browser.debug();
  58.   await registerBtn2.click();
  59.   await browser.pause(1000);
  60.   accountBtn = await $(accountBtnId[1]);
  61.   await accountBtn.click();
  62.   await browser.pause(500);
  63.   finalUrl = await browser.getUrl();
  64. }
  65. // async function performRegWholesale(link, fio, login, password, radio){
  66. //   await browser.url(link);
  67. //   accountBtn = await $(accountBtnId[0]);
  68. //   await accountBtn.click();
  69. //   registerBtn = await $('/html/body/main/div/div[2]/div[2]/div[2]/div/a/button');
  70. //   await registerBtn.click();
  71. //   elemFio = await $('#customerform-fio');
  72. //   let elemEmail = await $('#customerform-email');
  73. //   let elemPassword = await $('#customerform-password');
  74. //   await elemFio.setValue(fio);
  75. //   await elemEmail.setValue(login);
  76. //   await elemPassword.setValue(password);
  77. //   elemRadio = await $(radio);
  78. //   await elemRadio.click();
  79. //   registerBtn2 = await $(registerBtn2Id);
  80. //   await registerBtn2.scrollIntoView();
  81. //   await browser.debug();
  82. //   await registerBtn2.click();
  83. //   await browser.pause(1000);
  84. //   accountBtn = await $(accountBtnId[1]);
  85. //   await accountBtn.click();
  86. //   await browser.pause(500);
  87. //   finalUrl = await browser.getUrl();
  88. // }
  89.  
  90. describe('Десктоп. Регистрация', () => {
  91.  
  92.   beforeEach(async () => {
  93.     await browser.reloadSession();
  94.     await browser.setWindowSize(1024, 768);
  95.   });
  96.  
  97.   it('RU. Розница', async () => {
  98.     await performReg(linkToFollow[0], elemFio[0], retailLogin, retailPassword, elemRadioId[0]);
  99.     await browser.pause(500);
  100.     await assert.equal(finalUrl, referenceUrl[0]);
  101.   });
  102.  
  103.   it('RU. Опт', async () => {
  104.     await performReg(linkToFollow[0], elemFio[1], wholesaleLogin, wholesalePassword, elemRadioId[1]);
  105.     await browser.pause(500);
  106.     await assert.equal(finalUrl, referenceUrl[0]);
  107.   });
  108. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top