How to use el.sendKeys method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

timepicker.e2e-spec.js

Source:timepicker.e2e-spec.js Github

copy

Full Screen

1const { browserStackErrorReporter } = requireHelper('browserstack-error-reporter');2const config = requireHelper('e2e-config');3const utils = requireHelper('e2e-utils');4requireHelper('rejection');5jasmine.getEnv().addReporter(browserStackErrorReporter);6const ddSelector = function (dropdown) {7 return `#timepicker-popup select.dropdown.${dropdown} + .dropdown-wrapper div.dropdown`;8};9describe('Timepicker example-index tests', () => {10 beforeEach(async () => {11 await utils.setPage('/components/timepicker/example-index');12 });13 it('Should not have errors', async () => {14 await utils.checkForErrors();15 });16 if (utils.isChrome() && utils.isCI()) {17 it('Should not visual regress on example-index', async () => {18 const timepickerSection = await element(by.id('maincontent'));19 await browser.driver20 .wait(protractor.ExpectedConditions.presenceOf(timepickerSection), config.waitsFor);21 await element(by.css('.timepicker + .icon')).click();22 await browser.driver.sleep(config.sleep);23 expect(await browser.imageComparison.checkElement(timepickerSection, 'timepicker-open')).toEqual(0);24 });25 }26 it('Should open popup on icon click', async () => {27 await element(by.css('.timepicker + .icon')).click();28 expect(await element.all(by.className('is-open')).first().isDisplayed()).toBe(true);29 });30 it('Should open popup on keypress(arrow-down)', async () => {31 const timepickerEl = await element(by.id('timepicker-id-1'));32 await timepickerEl.sendKeys(protractor.Key.ARROW_DOWN);33 expect(await timepickerEl.getAttribute('class')).toContain('is-open');34 });35 it('Should set time from popup to field', async () => {36 const timepickerEl = await element(by.id('timepicker-id-1'));37 await element(by.css('.timepicker + .icon')).click();38 await element(by.css('.set-time')).sendKeys(protractor.Key.SPACE);39 expect(await timepickerEl.getAttribute('value')).toEqual('1:00 AM');40 });41 it('Should be able to set id/automation id', async () => {42 await browser.driver.sleep(config.sleep);43 expect(await element(by.id('timepicker-id-1')).getAttribute('id')).toEqual('timepicker-id-1');44 expect(await element(by.id('timepicker-id-1')).getAttribute('data-automation-id')).toEqual('timepicker-automation-id-1');45 expect(await element(by.id('timepicker-id-1-trigger')).getAttribute('id')).toEqual('timepicker-id-1-trigger');46 expect(await element(by.id('timepicker-id-1-trigger')).getAttribute('data-automation-id')).toEqual('timepicker-automation-id-1-trigger');47 });48 it('Should be able to set id/automation id on hours, minutes, seconds, and button', async () => {49 await element(by.css('.timepicker + .icon')).click();50 expect(await element(by.id('timepicker-id-1-hours')).getAttribute('id')).toEqual('timepicker-id-1-hours');51 expect(await element(by.id('timepicker-id-1-hours')).getAttribute('data-automation-id')).toEqual('timepicker-automation-id-1-hours');52 expect(await element(by.id('timepicker-id-1-minutes')).getAttribute('id')).toEqual('timepicker-id-1-minutes');53 expect(await element(by.id('timepicker-id-1-minutes')).getAttribute('data-automation-id')).toEqual('timepicker-automation-id-1-minutes');54 expect(await element(by.id('timepicker-id-1-btn')).getAttribute('id')).toEqual('timepicker-id-1-btn');55 expect(await element(by.id('timepicker-id-1-btn')).getAttribute('data-automation-id')).toEqual('timepicker-automation-id-1-btn');56 });57 // Test has strange behavior on CI, so isolating this to local58 if (!utils.isCI()) {59 it('Should pick time from picker and set to field', async () => {60 const timepickerEl = await element(by.id('timepicker-id-1'));61 await element(by.css('.timepicker + .icon')).click();62 let dropdownEl = await element(by.css(ddSelector('hours')));63 await dropdownEl.sendKeys(protractor.Key.SPACE);64 await browser.driver.sleep(config.sleep);65 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);66 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);67 await dropdownEl.sendKeys(protractor.Key.SPACE);68 expect(await dropdownEl.getText()).toEqual('3');69 dropdownEl = await element(by.css(ddSelector('minutes')));70 await dropdownEl.sendKeys(protractor.Key.SPACE);71 await browser.driver.sleep(config.sleep);72 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);73 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);74 await dropdownEl.sendKeys(protractor.Key.SPACE);75 expect(await dropdownEl.getText()).toEqual('10');76 dropdownEl = await element(by.css(ddSelector('period')));77 await dropdownEl.sendKeys(protractor.Key.SPACE);78 await browser.driver.sleep(config.sleep);79 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);80 await dropdownEl.sendKeys(protractor.Key.SPACE);81 expect(await dropdownEl.getText()).toEqual('PM');82 await element(by.css('.set-time')).sendKeys(protractor.Key.SPACE);83 expect(await timepickerEl.getAttribute('value')).toEqual('3:10 PM');84 });85 }86 it('Should not pick date from picker', async () => {87 const timepickerEl = await element(by.id('timepicker-id-1'));88 await timepickerEl.sendKeys('2:20 AM');89 await element(by.css('.timepicker + .icon')).click();90 await element(by.css('body')).sendKeys(protractor.Key.ESCAPE);91 expect(await timepickerEl.getAttribute('value')).toEqual('2:20 AM');92 });93});94describe('Timepicker 24 Hour tests', () => {95 beforeEach(async () => {96 await utils.setPage('/components/timepicker/test-24-hour');97 });98 it('Should open popup on icon click for 24 Hour', async () => {99 await element(by.css('.timepicker + .icon')).click();100 expect(await element.all(by.className('is-open')).first().isDisplayed()).toBe(true);101 });102 if (!utils.isBS() && !utils.isCI()) {103 it('Should pick time from picker and set to field for 24 Hour', async () => {104 const timepickerEl = await element(by.id('timepicker-24hrs'));105 await timepickerEl.sendKeys('19:15');106 await element(by.css('.timepicker + .icon')).click();107 let dropdownEl = await element(by.css(ddSelector('hours')));108 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);109 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);110 await dropdownEl.sendKeys(protractor.Key.SPACE);111 dropdownEl = await element(by.css(ddSelector('minutes')));112 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);113 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);114 await dropdownEl.sendKeys(protractor.Key.SPACE);115 await element(by.className('set-time')).click();116 await browser.driver.sleep(config.sleep);117 await element(by.css('.timepicker + .icon')).click();118 await browser.driver.sleep(config.sleep);119 expect(await element(by.id('timepicker-24hrs')).getAttribute('value')).toEqual('21:25');120 });121 }122});123describe('Timepicker with seconds example tests', () => {124 beforeEach(async () => {125 await utils.setPage('/components/timepicker/test-seconds-picker');126 });127 it('Should open popup on icon click with seconds', async () => {128 await element(by.css('.timepicker + .icon')).click();129 expect(await element.all(by.className('is-open')).first().isDisplayed()).toBe(true);130 });131 it('Should set time from popup to field with seconds', async () => {132 const timepickerEl = await element(by.id('time-field'));133 await element(by.css('.timepicker + .icon')).click();134 await element(by.css('.set-time')).sendKeys(protractor.Key.SPACE);135 expect(await timepickerEl.getAttribute('value')).toEqual('01:00:00 AM');136 });137 if (!utils.isBS()) {138 it('Should pick time from picker and set to field with seconds', async () => {139 const timepickerEl = await element(by.id('time-field'));140 await element(by.css('.timepicker + .icon')).click();141 let dropdownEl = await element(by.css(ddSelector('hours')));142 await dropdownEl.sendKeys(protractor.Key.SPACE);143 await browser.driver.sleep(config.sleep);144 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);145 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);146 await dropdownEl.sendKeys(protractor.Key.SPACE);147 await browser.driver.sleep(config.sleep);148 expect(await dropdownEl.getText()).toEqual('03');149 dropdownEl = await element(by.css(ddSelector('minutes')));150 await dropdownEl.sendKeys(protractor.Key.SPACE);151 await browser.driver.sleep(config.sleep);152 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);153 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);154 await dropdownEl.sendKeys(protractor.Key.SPACE);155 await browser.driver.sleep(config.sleep);156 expect(await dropdownEl.getText()).toEqual('10');157 dropdownEl = await element(by.css(ddSelector('seconds')));158 await dropdownEl.sendKeys(protractor.Key.SPACE);159 await browser.driver.sleep(config.sleep);160 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);161 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);162 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);163 await dropdownEl.sendKeys(protractor.Key.SPACE);164 await browser.driver.sleep(config.sleep);165 expect(await dropdownEl.getText()).toEqual('15');166 dropdownEl = await element(by.css(ddSelector('period')));167 await dropdownEl.sendKeys(protractor.Key.SPACE);168 await browser.driver.sleep(config.sleep);169 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);170 await dropdownEl.sendKeys(protractor.Key.SPACE);171 await browser.driver.sleep(config.sleep);172 expect(await dropdownEl.getText()).toEqual('PM');173 await element(by.css('.set-time')).click();174 await browser.driver.sleep(config.sleep);175 expect(await timepickerEl.getAttribute('value')).toEqual('03:10:15 PM');176 });177 }178 it('Should not pick date from picker with seconds', async () => {179 const timepickerEl = await element(by.id('time-field'));180 await timepickerEl.sendKeys('02:20:35 PM');181 await element(by.css('.timepicker + .icon')).click();182 await element(by.css('body')).sendKeys(protractor.Key.ESCAPE);183 expect(await timepickerEl.getAttribute('value')).toEqual('02:20:35 PM');184 });185});186describe('Timepicker Intervals tests', () => {187 beforeEach(async () => {188 await utils.setPage('/components/timepicker/test-intervals');189 });190 it('Should pick time from picker with 10 minute intervals', async () => {191 const timepickerEl = await element(by.id('time-intervals'));192 await element(by.css('.timepicker + .icon')).click();193 let dropdownEl = await element(by.css(ddSelector('hours')));194 await dropdownEl.click();195 await browser.driver.sleep(config.sleep);196 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);197 await dropdownEl.sendKeys(protractor.Key.SPACE);198 expect(await dropdownEl.getText()).toEqual('2');199 dropdownEl = await element(by.css(ddSelector('minutes')));200 await dropdownEl.click();201 await browser.driver.sleep(config.sleep);202 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);203 await dropdownEl.sendKeys(protractor.Key.SPACE);204 expect(await dropdownEl.getText()).toEqual('10');205 dropdownEl = await element(by.css(ddSelector('period')));206 await dropdownEl.click();207 await browser.driver.sleep(config.sleep);208 await dropdownEl.sendKeys(protractor.Key.ARROW_DOWN);209 await dropdownEl.sendKeys(protractor.Key.SPACE);210 expect(await dropdownEl.getText()).toEqual('PM');211 await element(by.css('.set-time')).sendKeys(protractor.Key.SPACE);212 await browser.driver.sleep(config.sleep);213 await browser.driver214 .wait(protractor.ExpectedConditions.invisibilityOf(element(by.id('dropdown-list'))), config.waitsFor);215 expect(await timepickerEl.getAttribute('value')).toEqual('2:10 PM');216 });217 it('Should rounds minutes to the nearest interval', async () => {218 const timepickerEl = await element(by.id('time-intervals'));219 await timepickerEl.sendKeys('2:24 AM');220 await timepickerEl.sendKeys(protractor.Key.TAB);221 expect(await timepickerEl.getAttribute('value')).toEqual('2:20 AM');222 });223});224describe('Timepicker states tests', () => {225 beforeEach(async () => {226 await utils.setPage('/components/timepicker/test-states');227 });228 it('Should check to make readonly', async () => {229 await element(by.id('btn-readonly')).click();230 expect(await element(by.css('.timepicker[readonly]')).isDisplayed()).toBe(true);231 });232 it('Should check to make disable', async () => {233 await element(by.id('btn-disable')).click();234 expect(await element(by.css('.timepicker')).isEnabled()).toBeFalsy();235 });236 it('Should check to make enable', async () => {237 await element(by.id('btn-readonly')).click();238 expect(await element(by.css('.timepicker[readonly]')).isDisplayed()).toBe(true);239 await element(by.id('btn-enable')).click();240 expect(await element(by.css('.timepicker')).getAttribute('readonly')).toEqual(null);241 await element(by.id('btn-disable')).click();242 expect(await element(by.css('.timepicker')).isEnabled()).toBeFalsy();243 await element(by.id('btn-enable')).click();244 expect(await element(by.css('.timepicker')).getAttribute('readonly')).toEqual(null);245 expect(await element(by.css('.timepicker')).getAttribute('disabled')).toEqual(null);246 expect(await element(by.css('.timepicker')).isEnabled()).toBeTruthy();247 });248});249describe('Timepicker Custom Validation Tests', () => {250 beforeEach(async () => {251 await utils.setPage('/components/timepicker/example-validation');252 });253 it('Should be able to do default invalid time validation', async () => {254 const datepickerEl = await element(by.id('timepicker-1'));255 await datepickerEl.clear();256 await datepickerEl.sendKeys('1:');257 await datepickerEl.sendKeys(protractor.Key.TAB);258 await browser.driver.sleep(config.sleep);259 expect(await element.all(by.css('.message-text')).last().getText()).toEqual('Invalid Time');260 expect(await element.all(by.css('.message-text')).last(1).isPresent()).toBe(true);261 });262 it('Should be able to do custom validation', async () => {263 expect(await element(by.css('.message-text')).isPresent()).toBe(false);264 const datepicker2El = await element(by.id('timepicker-2'));265 await datepicker2El.sendKeys(protractor.Key.TAB);266 await browser.driver.sleep(config.sleep);267 expect(await element.all(by.css('.message-text')).last().getText()).toEqual('Test Error - Anything you enter will be wrong');268 expect(await element.all(by.css('.message-text')).last(1).isPresent()).toBe(true);269 });270 it('Should be able to do required and time validation', async () => {271 const datepickerEl = await element(by.id('timepicker-3'));272 await datepickerEl.clear();273 await datepickerEl.sendKeys(protractor.Key.TAB);274 await browser.driver.sleep(config.sleep);275 expect(await element.all(by.css('.message-text')).last().getText()).toEqual('Required');276 expect(await element.all(by.css('.message-text')).last(1).isPresent()).toBe(true);277 await datepickerEl.clear();278 await datepickerEl.sendKeys('1:');279 await datepickerEl.sendKeys(protractor.Key.TAB);280 await browser.driver.sleep(config.sleep);281 expect(await element.all(by.css('.message-text')).last().getText()).toEqual('Invalid Time');282 expect(await element.all(by.css('.message-text')).last(1).isPresent()).toBe(true);283 });284});285describe('Timepicker specific locale/language tests', () => {286 beforeEach(async () => {287 await utils.setPage('/components/timepicker/test-specific-locale');288 });289 it('Should not have errors', async () => {290 await utils.checkForErrors();291 });292 it('Should set time and lanuage independently', async () => {293 let timepickerEl = await element(by.id('timepicker-1'));294 await element(by.css('#timepicker-1 + .icon')).click();295 expect(await element(by.css('.btn-modal-primary')).getText()).toEqual('Indstil tid');296 await element(by.css('.set-time')).sendKeys(protractor.Key.SPACE);297 expect(await timepickerEl.getAttribute('value')).toEqual('01.00');298 timepickerEl = await element(by.id('timepicker-2'));299 await element(by.css('#timepicker-2 + .icon')).click();300 expect(await element(by.css('.btn-modal-primary')).getText()).toEqual('Ange tid');301 await element(by.css('.set-time')).sendKeys(protractor.Key.SPACE);302 expect(await timepickerEl.getAttribute('value')).toEqual('01:00');303 });...

Full Screen

Full Screen

caretware.scenario.js

Source:caretware.scenario.js Github

copy

Full Screen

...29 });30 it('should caret have to be initialized to 0 and not movable', function() {31 el.evaluate(attrVal).then(function(pos) {32 expect(pos).toEqual(0);33 el.sendKeys(protractor.Key.END);34 el.evaluate(attrVal).then(function(pos) {35 expect(pos).toEqual(0);36 el.sendKeys(protractor.Key.UP);37 el.evaluate(attrVal).then(function(pos) {38 expect(pos).toEqual(0);39 });40 });41 });42 });43 describe('should track caret position when movement keys are used', function() {44 var text;45 beforeEach(function() {46 text = param.text;47 el.sendKeys(text);48 });49 it('should move caret to the start when UP KEY is used', function() {50 if (browser.name === 'firefox' && param.type === 'input') {51 // NOTE: skipped // FIXME: what firefox want?52 } else {53 el.sendKeys(UP_KEY);54 el.evaluate(attrVal).then(function(pos) {55 expect(pos).toEqual(0);56 });57 }58 });59 it('should move caret to the end when DOWN KEY is used', function() {60 el.sendKeys(UP_KEY);61 el.sendKeys(DOWN_KEY);62 el.evaluate(attrVal).then(function(pos) {63 expect(pos).toEqual(text.length);64 });65 });66 it('should decrement caret when ARROW LEFT is used', function() {67 el.sendKeys(protractor.Key.ARROW_LEFT);68 el.evaluate(attrVal).then(function(pos) {69 expect(pos).toEqual(text.length - 1);70 });71 });72 it('should decrement caret when LEFT is used', function() {73 el.sendKeys(protractor.Key.LEFT);74 el.evaluate(attrVal).then(function(pos) {75 expect(pos).toEqual(text.length - 1);76 });77 });78 it('should decrement caret when ARROW RIGHT is used', function() {79 el.sendKeys(protractor.Key.ARROW_LEFT);80 el.sendKeys(protractor.Key.ARROW_RIGHT);81 el.evaluate(attrVal).then(function(pos) {82 expect(pos).toEqual(text.length);83 });84 });85 it('should decrement caret when RIGHT is used', function() {86 el.sendKeys(protractor.Key.LEFT);87 el.sendKeys(protractor.Key.RIGHT);88 el.evaluate(attrVal).then(function(pos) {89 expect(pos).toEqual(text.length);90 });91 });92 it('should stop caret when at maximum right position', function() {93 el.sendKeys(DOWN_KEY);94 el.evaluate(attrVal).then(function(pos) {95 expect(pos).toEqual(text.length);96 el.sendKeys(DOWN_KEY);97 el.evaluate(attrVal).then(function(pos) {98 expect(pos).toEqual(text.length);99 });100 });101 });102 it('should stop caret when at minimum left position', function() {103 if (browser.name === 'firefox' && param.type === 'input') {104 // NOTE: skipped // FIXME: what firefox want?105 } else {106 el.sendKeys(UP_KEY);107 el.evaluate(attrVal).then(function(pos) {108 expect(pos).toEqual(0);109 el.sendKeys(UP_KEY);110 el.evaluate(attrVal).then(function(pos) {111 expect(pos).toEqual(0);112 });113 });114 }115 });116 });117 describe('should track caret position when input changes', function() {118 var text;119 beforeEach(function() {120 text = param.text;121 el.sendKeys(text);122 });123 it('should move caret forward when text is inserted', function() {124 el.evaluate(attrVal).then(function(pos) {125 expect(pos).toEqual(text.length);126 });127 });128 it('should move caret backward when text is deleted with backspace', function() {129 var numToCancel = 2,130 i = numToCancel;131 while (i-- > 0) {132 el.sendKeys(protractor.Key.BACK_SPACE);133 }134 el.evaluate(attrVal).then(function(pos) {135 expect(pos).toEqual(text.length - numToCancel);136 });137 });138 it('should keep the caret fixed when text is deleted with canc', function() {139 if (browser.name === 'firefox' && param.type === 'input') {140 // NOTE: skipped // FIXME: what firefox want?141 } else {142 el.sendKeys(UP_KEY);143 el.sendKeys(protractor.Key.DELETE);144 el.evaluate(attrVal).then(function(pos) {145 expect(pos).toEqual(0);146 });147 }148 });149 it('should move caret forwar when text is prepended', function() {150 if (browser.name === 'firefox' && param.type === 'input') {151 // NOTE: skipped // FIXME: what firefox want?152 } else {153 var pre = 'pre';154 el.sendKeys(UP_KEY);155 el.sendKeys(pre);156 el.evaluate(attrVal).then(function(pos) {157 expect(pos).toEqual(pre.length);158 });159 }160 });161 });162 describe('should track caret positions when the text of the element is selected', function() {163 var text,164 selectionBtn,165 selectionRes;166 beforeEach(function() {167 selectionBtn = element(by.buttonText('print selection'));168 selectionRes = element(by.id('selection'));169 text = param.text;170 el.sendKeys(text);171 });172 it('should correctly retrieve selection info when text is selected through SHIFT + ARROW LEFT', function() {173 var arrows = 4,174 resultingStart = text.length - arrows;175 // Cursor is at the end, select RTL: KEYDOWN W/ SHIFT + ARROW_LEFT(s) + KEYUP W/ SHIFT176 browser177 .actions()178 .keyDown(protractor.Key.SHIFT)179 .sendKeys(Array(arrows + 1).join(protractor.Key.ARROW_LEFT))180 .keyUp(protractor.Key.SHIFT)181 .perform();182 // Check resulting start pos183 el.evaluate(attrVal).then(function(pos) {184 expect(pos).toEqual(resultingStart);185 });186 // Check selection info187 browser.actions().click(selectionBtn).perform();188 selectionRes.getText().then(function(content) {189 expect(JSON.parse(content)).toEqual({190 start: resultingStart,191 end: text.length,192 length: arrows,193 text: text.substr(resultingStart, arrows)194 });195 });196 });197 it('should correctly retrieve selection info when text is selected through SHIFT + ARROW RIGHT', function() {198 if (browser.name === 'firefox' && param.type === 'input') {199 // NOTE: skipped // FIXME: what firefox want?200 } else {201 var arrows = 4,202 resultingEnd = arrows;203 el.sendKeys(UP_KEY);204 // Cursor is at the 0, select LTR: KEYDOWN W/ SHIFT + ARROW_RIGHT(s) + KEYUP W/ SHIFT205 browser206 .actions()207 .keyDown(protractor.Key.SHIFT)208 .sendKeys(Array(arrows + 1).join(protractor.Key.ARROW_RIGHT))209 .keyUp(protractor.Key.SHIFT)210 .perform();211 // Check start pos212 el.evaluate(attrVal).then(function(pos) {213 expect(pos).toEqual(0);214 });215 // Check selection info216 browser.actions().click(selectionBtn).perform();217 selectionRes.getText().then(function(content) {218 expect(JSON.parse(content)).toEqual({219 start: 0,220 end: resultingEnd,221 length: arrows,222 text: text.substr(0, resultingEnd)223 });224 });225 }226 });227 it('should correctly handle CTRL + A', function() {228 el.sendKeys(protractor.Key.chord(protractor.Key.CONTROL, 'a'));229 el.evaluate(attrVal).then(function(pos) {230 expect(pos).toEqual(0);231 });232 // Check selection info233 browser.actions().click(selectionBtn).perform();234 selectionRes.getText().then(function(content) {235 expect(JSON.parse(content)).toEqual({236 start: 0,237 end: text.length,238 length: text.length,239 text: text240 });241 });242 });243 it('should allow to click when content is selected and update caret position', function() {244 if (browser.name === 'firefox') {245 // NOTE: skipped // FIXME: what firefox want?246 } else {247 var wantedPos = 1;248 var factor = param.type === 'input' ? 7.5 : 10;249 browser250 .actions()251 .keyDown(protractor.Key.SHIFT)252 .sendKeys(Array(text.length + 1).join(protractor.Key.ARROW_LEFT))253 .keyUp(protractor.Key.SHIFT)254 .perform();255 //256 el.evaluate(attrVal).then(function(pos) {257 expect(pos).toEqual(0);258 // Now click at (factor * wantedPos, 15) pixels offset from top left259 // (i.e., aproximately after third character)260 browser261 .actions()262 .mouseMove(el, { x: factor * wantedPos, y: 15 })263 .click()264 .perform();265 // Verify266 el.evaluate(attrVal).then(function(pos) {267 expect(pos).toEqual(wantedPos);268 });269 browser.actions().click(selectionBtn).perform();270 selectionRes.getText().then(function(content) {271 expect(JSON.parse(content)).toEqual({272 start: wantedPos,273 end: wantedPos,274 length: 0,275 text: ''276 });277 });278 });279 }280 });281 });282 describe('should track caret position when element is clicked', function() {283 var text,284 factor = param.type === 'input' ? 7.5 : 10;285 beforeEach(function() {286 text = param.text;287 el.sendKeys(text);288 });289 it('should work when element is clicked at the start', function() {290 if (browser.name === 'firefox') {291 // NOTE: skipped // FIXME: what firefox want?292 } else {293 var startPos = 0;294 browser295 .actions()296 .mouseMove(el, { x: factor * startPos, y: 15})297 .click()298 .perform();299 el.evaluate(attrVal).then(function(pos) {300 expect(pos).toEqual(0);301 });...

Full Screen

Full Screen

tester.js

Source:tester.js Github

copy

Full Screen

...17 return driver.sleep(0.5*1000);18}).then(function(){19 return driver.findElement(self.By.xpath("//*[@id = 'title']"));20}).then(function(el){21 if(el) el.sendKeys("The Revenant");22 return driver.sleep(0.5*1000);23}).then(function(){24 return driver.findElement(self.By.xpath("//*[@id = 'released']"))25}).then(function(el){26 if(el) el.sendKeys("2015");27 return driver.sleep(0.5*1000);28}).then(function(){29 return driver.findElement(self.By.xpath("//*[@id = 'director']"))30}).then(function(el){31 if(el) el.sendKeys("Alejandro Iniarritu");32 return driver.sleep(0.5*1000)33}).then(function(){34 return driver.findElement(self.By.xpath("//*[@id = 'rating']"));35}).then(function(el){36 if(el) el.sendKeys("R");37 return driver.sleep(0.5*1000);38}).then(function(){39 return driver.findElement(self.By.xpath("//*[@id = 'starring']"));40}).then(function(el){41 if(el) el.sendKeys(" Leonardo DiCaprio, Tom Hardy");42 return driver.sleep(0.5*1000);43}).then(function(){44 return driver.findElement(self.By.xpath("//*[@id = 'duration']"));45}).then(function(el){ if(el) el.sendKeys("154");46 return driver.sleep(0.5*1000)47}).then(function(){48 return driver.findElement(self.By.xpath("//*[@id = 'genre']"));49}).then(function(el){50 if(el) el.sendKeys("adventure, drama");51 return driver.sleep(0.5*1000);52}).then(function(){53 return driver.findElement(self.By.xpath("//*[@id = 'synopsis']"));54}).then(function(el){ if(el) el.sendKeys("Description");55 return driver.sleep(0.5*1000);56}).then(function(){57 return driver.findElement(self.By.xpath("//*[@id = 'trailer']"));58}).then(function(el){59 if(el) el.sendKeys("https://youtu.be/QRfj1VCg16Y");60 return driver.findElement(self.By.xpath("//*[text()='Save Changes']"));61}).then(function(el){62 if(el) el.click();63 return driver.sleep(0.5*1000);64}).then(function(){65 return driver.findElement(self.By.xpath("//*[text()='Splat!']"));66}).then(function(el){67 if(el) el.click();68 return driver.getTitle();69}).then(function(title) {70 // something better? 71 // not sure if we do this:72 // return title === 'Splat' 73 // it will work properly74 // this function in theory should return only Promise object(an object that have )75 if(title === 'Splat'){76 return driver.sleep(1);77 } else {78 throw new Error(); // ???79 }80}).then(function(){81 return driver.sleep(0.5*1000);82}).then(function(){83 return driver.findElement(self.By.xpath("//*[text()='Browse Great Movies']"))84}).then(function(el){85 if(el) el.click();86 return driver.sleep(0.5*1000)87}).then(function(){88 return driver.findElement(self.By.xpath("//*[@id = 'TheRevenant']"));89}).then(function(el){90 if(el) el.click();91 return driver.sleep(0.5*1000)92}).then(function(){93 return driver.findElement(self.By.xpath("//*[text()='Delete Movie']"))94}).then(function(el){95 if(el) el.click();96}, function(err){97 scope.callback(true, err);98 driver.sleep(2000);99 return driver.quit()100}).then(function(){101 driver.sleep(2000);102 driver.wait(function(){103 driver.quit();104 return scope.callback()105 }, 1000);106});107/*108driver.getTitle().then(function(title) { return title === 'Splat';}).then(function(){109 driver.sleep(0.5*1000).then(function(){110 driver.findElement(self.By.xpath("//*[text()='Add Movie']")).then(function(el){ if(el) el.click();111 driver.sleep(0.5*1000).then(function(){112 driver.findElement(self.By.xpath("//*[@id = 'title']")).then(function(el){ if(el) el.sendKeys("The Revenant");113 driver.sleep(0.5*1000).then(function(){114 driver.findElement(self.By.xpath("//*[@id = 'released']")).then(function(el){ if(el) el.sendKeys("2015");115 driver.sleep(0.5*1000).then(function(){116 driver.findElement(self.By.xpath("//*[@id = 'director']")).then(function(el){ if(el) el.sendKeys("Alejandro Iniarritu");117 driver.sleep(0.5*1000).then(function(){118 driver.findElement(self.By.xpath("//*[@id = 'rating']")).then(function(el){ if(el) el.sendKeys("R");119 driver.sleep(0.5*1000).then(function(){120 driver.findElement(self.By.xpath("//*[@id = 'starring']")).then(function(el){ if(el) el.sendKeys(" Leonardo DiCaprio, Tom Hardy");121 driver.sleep(0.5*1000).then(function(){122 driver.findElement(self.By.xpath("//*[@id = 'duration']")).then(function(el){ if(el) el.sendKeys("154");123 driver.sleep(0.5*1000).then(function(){124 driver.findElement(self.By.xpath("//*[@id = 'genre']")).then(function(el){ if(el) el.sendKeys("adventure, drama");125 driver.sleep(0.5*1000).then(function(){126 driver.findElement(self.By.xpath("//*[@id = 'synopsis']")).then(function(el){ if(el) el.sendKeys("Description");127 driver.sleep(0.5*1000).then(function(){128 driver.findElement(self.By.xpath("//*[@id = 'trailer']")).then(function(el){ if(el) el.sendKeys("https://youtu.be/QRfj1VCg16Y");129 driver.findElement(self.By.xpath("//*[text()='Save Changes']")).then(function(el){ if(el) el.click();130 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })131 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })132 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })133 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })134 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })135 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })136 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })137 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })138 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })139 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })140 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })141 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })142 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })...

Full Screen

Full Screen

index.test.js

Source:index.test.js Github

copy

Full Screen

1/* global describe, before, beforeEach, afterEach, it, browser, element, by, protractor */2import { expect, config } from './globals';3const EC = protractor.ExpectedConditions;4browser.ignoreSynchronization = true;5describe('Index page', () => {6 const videoContainer = '.video-container';7 const greenBtnClass = '.btn.btn-green';8 const contactPopupEl = element(by.id('modal-contact'));9 const contactPopupCloseEl = contactPopupEl.element(by.css('.close-modal'));10 before(() => {11 browser.get('');12 });13 it('should have title as \'Tactical Mastery Flashlights\'', () => {14 expect(browser.getTitle()).to.eventually.equal('Tactical Mastery Flashlights');15 });16 describe('Contact modal - open', () => {17 afterEach(() => {18 contactPopupCloseEl.click();19 browser.wait(EC.invisibilityOf(contactPopupEl), 1000);20 });21 it('should open contact popup when click on \'Yes! I want 75% Off!\' green button.', () => {22 const buttonEl = element(by.cssContainingText(greenBtnClass, 'Yes! I want 75% Off!'));23 browser.wait(EC.visibilityOf(buttonEl));24 buttonEl.click();25 browser.sleep(1000);26 expect(contactPopupEl.isDisplayed()).to.eventually.equal(true);27 });28 if (config.capabilities.browserName === 'phantomjs') {29 // console.warn('It can\'t test video on phantomjs.');30 } else {31 it('should open contact popup when click on \'Click Here\' of hero video', () => {32 const buttonId = 'wistia_22_midrollLink_link';33 const buttonEl = element(by.css(videoContainer)).element(by.id(buttonId));34 browser.wait(EC.visibilityOf(buttonEl), 300000);35 buttonEl.click();36 browser.sleep(1000);37 expect(contactPopupEl.isDisplayed()).to.eventually.equal(true);38 });39 it.skip('should open contact popup when the hero video ends', () => 'pending');40 }41 });42 describe('Contact modal - validate', () => {43 const buttonYesEl = element(by.cssContainingText('.btn.btn-danger', 'YES!'));44 const nameEl = element(by.name('contactModalName'));45 const emailEl = element(by.name('email'));46 const phoneEl = element(by.name('phoneNumber'));47 const nameGroupEl = element(by.css('.form-group-name'));48 const emailGroupEl = element(by.css('.form-group-email'));49 const phoneGroupEl = element(by.css('.form-group-phone'));50 before(() => {51 const buttonEl = element(by.cssContainingText(greenBtnClass, 'Yes! I want 75% Off!'));52 browser.wait(EC.elementToBeClickable(buttonEl), 1000);53 buttonEl.click();54 browser.wait(EC.visibilityOf(contactPopupEl), 1000);55 });56 describe('Name field', () => {57 const emptyValidator = nameGroupEl.element(by.cssContainingText('.form-control-feedback', 'Please enter your name.'));58 const lengthValidator = nameGroupEl.element(by.cssContainingText('.form-control-feedback', 'The name must be more than 1 and less than 100'));59 const rightValidator = nameGroupEl.element(by.cssContainingText('.valid-message.text-success', 'Nice to meet you!'));60 beforeEach(() => {61 nameEl.clear();62 });63 it('should validate name when input \'\'', () => {64 nameEl.sendKeys('');65 buttonYesEl.click();66 browser.sleep(1000);67 expect(emptyValidator.isDisplayed()).to.eventually.equal(true);68 });69 it('should validate name when input long length string greater than 100', () => {70 let longName = '0';71 for (let i = 0, end = 100; i < end; i += 1) {72 longName = `0${longName}`;73 }74 nameEl.sendKeys(longName);75 expect(lengthValidator.isDisplayed()).to.eventually.equal(true);76 });77 it('should validate name when input \'OK\'', () => {78 nameEl.sendKeys('OK');79 expect(rightValidator.isDisplayed()).to.eventually.equal(true);80 });81 });82 describe('Email field', () => {83 const emptyValidator = emailGroupEl.element(by.cssContainingText('.form-control-feedback', 'The email address is required.'));84 const formatValidator = emailGroupEl.element(by.cssContainingText('.form-control-feedback', 'The email address is not valid.'));85 const lengthValidator = emailGroupEl.element(by.cssContainingText('.form-control-feedback', 'The email address must be more than 6 and less than 30'));86 const rightValidator = emailGroupEl.element(by.cssContainingText('.valid-message.text-success', 'Great!'));87 beforeEach(() => {88 emailEl.clear();89 });90 it('should validate email when input \'\'', () => {91 emailEl.sendKeys('');92 buttonYesEl.click();93 browser.sleep(1000);94 expect(emptyValidator.isDisplayed()).to.eventually.equal(true);95 });96 it('should validate email when input \'wrong\'', () => {97 emailEl.sendKeys('wrong');98 expect(formatValidator.isDisplayed()).to.eventually.equal(true);99 });100 it.skip('should validate email when input \'wrong@wrong\'', () => {101 emailEl.sendKeys('wrong@wrong');102 expect(formatValidator.isDisplayed()).to.eventually.equal(true);103 });104 it('should validate email when input \'wrong@wrong.\'', () => {105 emailEl.sendKeys('wrong@wrong.');106 expect(formatValidator.isDisplayed()).to.eventually.equal(true);107 });108 it('should validate email when input \'a@b.c\'', () => {109 emailEl.sendKeys('a@b.c');110 expect(lengthValidator.isDisplayed()).to.eventually.equal(true);111 });112 it('should validate email when input long \'aaaaaaaaaa@bbbbbbbbbb.cccccccccc\'', () => {113 emailEl.sendKeys('aaaaaaaaaa@bbbbbbbbbb.cccccccccc');114 expect(lengthValidator.isDisplayed()).to.eventually.equal(true);115 });116 it('should validate email when input \'email@test.ok\'', () => {117 emailEl.sendKeys('email@test.ok');118 expect(rightValidator.isDisplayed()).to.eventually.equal(true);119 });120 });121 describe('Phone field', () => {122 const emptyValidator = phoneGroupEl.element(by.cssContainingText('.form-control-feedback', 'Please supply a phone number'));123 const formatValidator = phoneGroupEl.element(by.cssContainingText('.form-control-feedback', 'Not a valid 10-digit US phone number'));124 const rightValidator = phoneGroupEl.element(by.cssContainingText('.valid-message.text-success', 'Success!'));125 beforeEach(() => {126 phoneEl.clear();127 });128 it('should validate phone number when input \'\'', () => {129 phoneEl.sendKeys('');130 buttonYesEl.click();131 browser.sleep(1000);132 expect(emptyValidator.isDisplayed()).to.eventually.equal(true);133 });134 it('should validate phone number when input single letter \'a\'', () => {135 phoneEl.sendKeys('a');136 expect(emptyValidator.isDisplayed()).to.eventually.equal(true);137 });138 it('should validate phone number when input letters \'test phone number\'', () => {139 phoneEl.sendKeys('test phone number');140 expect(emptyValidator.isDisplayed()).to.eventually.equal(true);141 });142 it('should validate phone number when input short digits \'12345\'', () => {143 phoneEl.sendKeys('12345');144 expect(formatValidator.isDisplayed()).to.eventually.equal(true);145 });146 it('should trim 10 digits and validate phone number when input long digits \'00001111222233334444\'', () => {147 phoneEl.sendKeys('00001111222233334444');148 expect(rightValidator.isDisplayed()).to.eventually.equal(true);149 });150 it('should filter digits and validate phone number when input complex string \'000 a111 222b cc333\'', () => {151 phoneEl.sendKeys('000 a111 222b cc333');152 expect(rightValidator.isDisplayed()).to.eventually.equal(true);153 });154 });155 });...

Full Screen

Full Screen

resursi.materijali.test.js

Source:resursi.materijali.test.js Github

copy

Full Screen

1//Auth: Maja2'use strict';3var webdriver = require('selenium-webdriver');4//var chai = require('chai');5//var expect = require('chai');6var assert = require('assert');7var sinon = require ('sinon');8var {Builder, By, until} = require('selenium-webdriver');9var test = require('selenium-webdriver/testing');10 11 12var driver = new webdriver.Builder().forBrowser('chrome').build();13/*--------------------------------------------------------------------------*/14 test.describe('AgroLife: prijavljivanje na sistem\n', function() {15 test.it('prijavna forma ispravno popunjena', function() {16 driver.get('http://localhost:3000')17 //driver.get('http://agrolife.greensoft.co:3000')18 .then(_ => driver.findElement(By.id("textfield-1011-inputEl")).sendKeys("Miodrag"))19 .then(_ => driver.findElement(By.id("textfield-1012-inputEl")).sendKeys("Miodrag"))20 .then(_ => driver.findElement(By.id("textfield-1013-inputEl")).sendKeys("1243!"))21 .then(_ => driver.wait(until.elementLocated(By.id('button-1015-btnIconEl')), 2000).click()) 22 });23 24 test.it('Prijava na sistem uspesna', function(){25 driver.wait(until.elementLocated(By.id('button-1230-btnIconEl')), 90000);26 });27 28 });29/* -------------------------------------------------------------------------- */30 test.describe('Materijali-window', function() {31 32 test.it('Otvaranje prozora materijali', function() {33 driver.wait(until.elementLocated(By.id('button-1243-btnIconEl')), 1000)34 .then(_ => driver.findElement(By.id('button-1243-btnIconEl')).click())35 .then(_ => driver.findElement(By.id('menuitem-1247-itemEl')).click())36 37 });38 });39 test.describe('Unos grupe/podgrupe/materijal', function(){40 41 test.it('Ispravni podaci grupe', function(){42 43 //Materijali grupa44 45 driver.wait(until.elementLocated(By.id('tab-1466-btnEl')), 10000).click()46 47 // Materijali-grupa/forma48 .then(_ => driver.findElement(By.id('textfield-1417-inputEl')).sendKeys('Maja grupa'))49 .then(_ => driver.findElement(By.id('textfield-1418-inputEl')).sendKeys('Maja ikonica'))50 .then(_ => driver.findElement(By.id('textfield-1419-inputEl')).sendKeys('Maja priotitet'))51 //.then(_ => driver.findElement(By.id('ext-gen5431')).click())52 53 test.it('Korisnik dodao grupu materijala', function(){54 driver.wait(until.elementLocated(By.id('button-1424-btnInnerEl')), 5000).click();55 });56 57 });58 test.it('Ispravni podaci podgrupe', function(){59 //Materijali-podgrupa/forma60 61 driver.wait(until.elementLocated(By.id('tab-1467-btnIconEl')),10000).click()62 63 .then(_ => driver.findElement(By.id('combo-1453-inputEl')).sendKeys('Maja grupa'))64 .then(_ => driver.findElement(By.id('textfield-1454-inputEl')).sendKeys('maja podgrupa'))65 .then(_ => driver.findElement(By.id('textfield-1455-inputEl')).sendKeys('majina ikona'))66 .then(_ => driver.findElement(By.id('textfield-1456-inputEl')).sendKeys('5'))67 .then(_ => driver.findElement(By.id('ext-gen5343')).click())68 69 //Dodaj70 test.it('Korisnik dodao podgrupu materijala', function(){71 driver.wait(until.elementLocated(By.id('button-1461-btnIconEl')), 5000).click();72 });73 74 75 //Sacuvaj izmene76 //Brisanje77 });78 test.it('Ispravni podaci materijal', function(){79 driver.wait(until.elementLocated(By.id('tab-1465-btnIconEl')),10000).click()80 // Materijali-forma81 .then(_ => driver.findElement(By.id('textfield-1374-inputEl')).sendKeys('789456'))82 .then(_ => driver.findElement(By.id('textfield-1375-inputEl')).sendKeys('maja materijal'))83 .then(_ => driver.findElement(By.id('numberfield-1376-inputEl')).sendKeys('100'))84 .then(_ => driver.findElement(By.id('combo-1377-inputEl')).sendKeys('Goriva i maziva'))85 .then(_ => driver.findElement(By.id('combo-1378-inputEl')).sendKeys('Gorivo'))86 .then(_ => driver.findElement(By.id('combo-1379-inputEl')).sendKeys('Kelj'))87 .then(_ => driver.findElement(By.id('textfield-1380-inputEl')).sendKeys('L'))88 89 test.it('Korisnik dodao materijal', function(){90 driver.wait(until.elementLocated(By.id('button-1385-btnIconEl')), 5000).click();91 92 });93 });94 95});96test.describe('Odjavljivanje iz aplikacije', function(){97 98 test.it('odjavljivanje uspesno', function(){99 100 // Odjava iz aplikacije101 driver.findElement(By.id("button-1354-btnIconEl")).click()102 .then(_ => driver.findElement(By.id("button-1005-btnIconEl")).click())103 })104 105 test.it('Izlazak iz browsera', function(){106 107 // Zatvaranje browsera 108 driver.quit();109 })110 ...

Full Screen

Full Screen

remember-me.spec.js

Source:remember-me.spec.js Github

copy

Full Screen

1'use strict';2var rememberMe = (function () {3 describe('Remember Me Checkbox', function() {4 var page = require('../page-object/login.po'),5 nav = require('../page-object/navigation.po'),6 users = require('../utilities/users.spec'),7 user = users.auto01,8 user2 = users.auto02,9 invalidEmail = 'email@trueffect.com',10 invalidpassword = 'password4321';11 it('should remember on valid login', function() {12 browser.get('/');13 expect(browser.getLocationAbsUrl()).toContain('/login');14 expect(page.rememberMe.isSelected()).toBe(false);15 page.usernameEl.sendKeys(user.email);16 expect(page.getUsername()).toBe(user.email);17 page.passwordEl.sendKeys(user.password);18 expect(page.getPassword()).toBe(user.password);19 page.rememberMeCheckbox.click();20 expect(page.rememberMe.isSelected()).toBe(true);21 expect(page.submitButton.isEnabled()).toBe(true);22 page.submitButton.click();23 expect(nav.campaignsItem.isDisplayed()).toBe(true);24 nav.logoutIcon.click();25 nav.logout.click();26 expect(browser.getLocationAbsUrl()).toContain('/login');27 expect(page.rememberMe.isSelected()).toBeTruthy();28 expect(page.getUsername()).toBe(user.email);29 });30 it('should not remember invalid username', function() {31 page.usernameEl.clear();32 expect(page.getUsername()).toBe('');33 page.rememberMe.isSelected().then(function(result) {34 if (result == false) {35 page.rememberMeCheckbox.click();36 }37 });38 expect(page.rememberMe.isSelected()).toBe(true);39 page.usernameEl.sendKeys(invalidEmail);40 expect(page.getUsername()).toBe(invalidEmail);41 page.passwordEl.sendKeys(invalidpassword);42 expect(page.getPassword()).toBe(invalidpassword);43 expect(page.submitButton.isEnabled()).toBe(true);44 page.submitButton.click();45 expect(page.invalidLoginMsg.isDisplayed()).toBe(true);46 browser.refresh();47 expect(page.rememberMe.isSelected()).toBe(true);48 expect(page.getUsername()).toBe(user.email);49 });50 it('should remember new user login', function() {51 page.usernameEl.clear();52 expect(page.getUsername()).toBe('');53 page.rememberMe.isSelected().then(function(result) {54 if (result == false) {55 page.rememberMeCheckbox.click();56 }57 });58 page.usernameEl.sendKeys(user2.email);59 expect(page.getUsername()).toBe(user2.email);60 page.passwordEl.sendKeys(user2.password);61 expect(page.getPassword()).toBe(user2.password);62 expect(page.submitButton.isEnabled()).toBe(true);63 page.submitButton.click();64 expect(nav.campaignsItem.isDisplayed()).toBe(true);65 nav.logoutIcon.click();66 nav.logout.click();67 expect(browser.getLocationAbsUrl()).toContain('/login');68 expect(page.rememberMe.isSelected()).toBeTruthy();69 expect(page.getUsername()).toBe(user2.email);70 });71 it('should clear remember me when unchecked', function() {72 page.rememberMe.isSelected().then(function(result) {73 if (result == true) {74 page.rememberMeCheckbox.click();75 }76 });77 expect(page.rememberMe.isSelected()).toBe(false);78 page.usernameEl.clear();79 expect(page.getUsername()).toBe('');80 page.usernameEl.sendKeys(user.email);81 expect(page.getUsername()).toBe(user.email);82 page.passwordEl.sendKeys(user.password);83 expect(page.getPassword()).toBe(user.password);84 expect(page.submitButton.isEnabled()).toBe(true);85 page.submitButton.click();86 expect(nav.campaignsItem.isDisplayed()).toBe(true);87 nav.logoutIcon.click();88 nav.logout.click();89 expect(browser.getLocationAbsUrl()).toContain('/login');90 expect(page.rememberMe.isSelected()).toBe(false);91 expect(page.usernameEl.getText()).toBe('');92 });93 });94});...

Full Screen

Full Screen

login-page.spec.js

Source:login-page.spec.js Github

copy

Full Screen

1'use strict';2var loginPage = (function () {3 describe('Login Page', function() {4 var page = require('../page-object/login.po'),5 users = require('../utilities/users.spec'),6 user = users.auto01,7 invalidEmail = 'email@trueffect.com',8 invalidPassword = 'password4321',9 login = require('../page-object/login.po'),10 nav = require('../page-object/navigation.po');11 it('should load', function() {12 login.usernameEl.isPresent().then(function(present) {13 if (present == false) {14 nav.logoutIcon.click();15 nav.logout.click();16 }17 expect(browser.getLocationAbsUrl()).toContain('/login');18 });19 });20 it('should display login page elements', function() {21 expect(page.usernameEl.isDisplayed()).toBe(true);22 expect(page.passwordEl.isDisplayed()).toBe(true);23 expect(page.rememberMe.isPresent()).toBe(true);24 expect(page.submitButton.isDisplayed()).toBe(true);25 expect(page.helpLink.isDisplayed()).toBe(true);26 expect(page.privacyLink.isDisplayed()).toBe(true);27 expect(page.contactUsLink.isDisplayed()).toBe(true);28 });29 it('should have disabled Login button until an email address and password is entered', function() {30 page.usernameEl.sendKeys(invalidEmail);31 expect(page.usernameEl.getAttribute('value')).toBe(invalidEmail);32 expect(page.submitButton.isEnabled()).toBe(false);33 page.passwordEl.sendKeys(invalidPassword);34 expect(page.passwordEl.getAttribute('value')).toBe(invalidPassword);35 expect(page.submitButton.isEnabled()).toBe(true);36 page.usernameEl.clear();37 expect(page.usernameEl.getAttribute('value')).toBe('');38 expect(page.submitButton.isEnabled()).toBe(false);39 page.usernameEl.sendKeys(invalidEmail);40 expect(page.usernameEl.getAttribute('value')).toBe(invalidEmail);41 page.passwordEl.clear();42 expect(page.passwordEl.getAttribute('value')).toBe('');43 expect(page.submitButton.isEnabled()).toBe(false);44 page.passwordEl.sendKeys(invalidPassword);45 expect(page.passwordEl.getAttribute('value')).toBe(invalidPassword);46 expect(page.submitButton.isEnabled()).toBe(true);47 });48 it('should display an invalid login message', function() {49 browser.get('/#/login');50 expect(browser.getLocationAbsUrl()).toContain('/login');51 page.usernameEl.sendKeys(invalidEmail);52 expect(page.usernameEl.getAttribute('value')).toBe(invalidEmail);53 page.passwordEl.sendKeys(invalidPassword);54 expect(page.passwordEl.getAttribute('value')).toBe(invalidPassword);55 expect(page.submitButton.isEnabled()).toBe(true);56 page.submitButton.click();57 expect(page.invalidLoginMsg.isDisplayed()).toBe(true);58 page.usernameEl.clear();59 expect(page.usernameEl.getAttribute('value')).toBe('');60 page.passwordEl.clear();61 expect(page.passwordEl.getAttribute('value')).toBe('');62 page.usernameEl.sendKeys(user.email);63 expect(page.usernameEl.getAttribute('value')).toBe(user.email);64 page.passwordEl.sendKeys(invalidPassword);65 expect(page.passwordEl.getAttribute('value')).toBe(invalidPassword);66 expect(page.submitButton.isEnabled()).toBe(true);67 page.submitButton.click();68 expect(page.invalidLoginMsg.isDisplayed()).toBe(true);69 });70 });71});...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...8 var signinButton = driver.findElement(By.className("login"));9 signinButton.click();10 //Entering email1 for one account11 driver.wait(until.elementLocated(By.id('email_create')), 10 * 1000).then(el => {12 el.sendKeys("hasib8nh@gmail.com");13 })14 driver.wait(until.elementLocated(By.id('SubmitCreate')), 12 * 1000).then(el => {15 el.click();16 })17 // Entering Firstname18 driver.wait(until.elementLocated(By.id('customer_firstname')), 15 * 1000).then(el => {19 el.sendKeys("Hasnat");20 })21 // Entering Firstname22 driver.wait(until.elementLocated(By.id('customer_lastname')), 15 * 1000).then(el => {23 el.sendKeys("Hasib");24 })25 // // Entering Password26 driver.wait(until.elementLocated(By.className('is_required validate form-control')), 100 * 1000).then(el => {27 el.sendKeys("123456");28 })29 //Address Firstname30 driver.wait(until.elementLocated(By.id('firstname')), 50 * 1000).then(el => {31 el.sendKeys("Hasnat");32 })33 //Address Lastname34 driver.wait(until.elementLocated(By.id('lastname')), 50 * 1000).then(el => {35 el.sendKeys("Hasib");36 })37 //Address Lastname38 driver.wait(until.elementLocated(By.id('address1')), 50 * 1000).then(el => {39 el.sendKeys("E-60,NS town");40 })41 //Address City42 driver.wait(until.elementLocated(By.id('city')), 50 * 1000).then(el => {43 el.sendKeys("Jashore");44 })45 //Postcode46 driver.wait(until.elementLocated(By.id('postcode')), 50 * 1000).then(el => {47 el.sendKeys("00000");48 })49 //Mobile50 driver.wait(until.elementLocated(By.id('phone_mobile')), 50 * 1000).then(el => {51 el.sendKeys("0332134345345");52 })53 // //Second Address54 driver.wait(until.elementLocated(By.id('alias')), 50 * 1000).then(el => {55 el.sendKeys("E-61");56 })57 // State58 driver.wait(until.elementLocated(By.xpath('//*[@id="id_state"]/option[2]')), 50 * 1000).then(el => {59 el.click();60 });61 // Register Button62 driver.wait(until.elementLocated(By.id('submitAccount')), 50 * 1000).then(el => {63 el.click();64 })65 66 // Login email67 driver.wait(until.elementLocated(By.id('email')), 50 * 1000).then(el => {68 el.sendKeys("hasib@gmail.com");69 })70 // Login passwprd71 driver.wait(until.elementLocated(By.id('email')), 50 * 1000).then(el => {72 el.sendKeys("654321");73 })74 // Register Button75 driver.wait(until.elementLocated(By.id('SubmitLogin')), 50 * 1000).then(el => {76 el.click();77 })78 //SignOut79 driver.wait(until.elementLocated(By.className('logout')), 50 * 1000).then(el => {80 el.click();81 })82 83}...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Xcuitest Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful