How to use driver.quit method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

cartService.js

Source:cartService.js Github

copy

Full Screen

...318 else callback(null, "update 11st cookies");319 });320 });321 });322 driver.quit();323 }, function (err) {324 console.log(err);325 driver.quit();326 });327 }); 328 },function(err){329 console.log(err);330 driver.quit();331 });332 }, function (err) {333 console.log(err);334 driver.quit();335 });336 }, function (err) {337 console.log(err);338 driver.quit();339 });340 }, function (err) {341 console.log(err);342 driver.quit();343 });344 }, function (err) {345 console.log(err);346 driver.quit();347 });348 }, function (err) {349 console.log("err - setCookiesForScheduling - 11st ::", err);350 callback(null, "update 11st cookies Err!!");351 });352 } catch (e) {353 console.log("catch exception at task4 - 11st");354 console.log(e);355 }356 } else {357 callback(null);358 }359 },360 function (callback) {361 if (websiteList.hasOwnProperty('auction')) {362 var auctionCookies = "";363 try {364 const driver = new webdriver.Builder().forBrowser('phantomjs').build();365 driver.then(function () {366 driver.manage().timeouts().implicitlyWait(3000);367 driver.get('https://memberssl.auction.co.kr/authenticate/?url=http%3a%2f%2fbuy.auction.co.kr%2fbuy%2fA2014%2fCart%2fCart.aspx%3ffrm%3dhometab').then(function () {368 driver.findElement(By.id('id')).then(function (el) {369 el.sendKeys(websiteList['auction'].websiteId);370 driver.findElement(By.id('password')).then(function (el) {371 el.sendKeys(websiteList['auction'].websitePw);372 driver.findElement(By.id('Image1')).then(function (el) {373 el.click().then(function(){374 driver.then(function () {375 driver.manage().getCookies().then(function (cookies) {376 for (var i in cookies) {377 if (i == 0) {378 auctionCookies += cookies[i]['name'] + '=' + cookies[i]['value'];379 } else {380 auctionCookies += ';' + cookies[i]['name'] + '=' + cookies[i]['value'];381 }382 }383 driver.then(function () {384 db.pool.getConnection(function (err, conn) {385 if (err) {386 return;387 }388 var sql = "update tbl_logindata set cookies = ? where email = ? and website = 'auction'";389 conn.query(sql, [auctionCookies, email], function (err, rows, fields) {390 conn.release();391 if (err) console.log("err");392 else callback(null, "update auction cookies");393 });394 });395 });396 driver.quit();397 }, function (err) {398 console.log(err);399 driver.quit();400 });401 }); 402 },function(err){403 console.log(err);404 driver.quit();405 });406 407 }, function (err) {408 console.log(err);409 driver.quit();410 });411 }, function (err) {412 console.log(err);413 driver.quit();414 });415 }, function (err) {416 console.log(err);417 driver.quit();418 });419 }, function (err) {420 console.log(err);421 driver.quit();422 });423 }, function (err) {424 console.log("err - setCookiesForScheduling - auction ::", err);425 callback(null, "update auction cookies Err!!");426 });427 } catch (e) {428 console.log("catch exception at task4 - auction");429 console.log(e);430 }431 } else {432 callback(null);433 }434 },435 function (callback) {436 if (websiteList.hasOwnProperty('interpark')) {437 var interparkCookies = "";438 try {439 const driver = new webdriver.Builder().forBrowser('phantomjs').build();440 driver.then(function () {441 driver.manage().timeouts().implicitlyWait(3000);442 driver.get('http://www.interpark.com/order/cartlist.do?_method=cartList&logintgt=cart&wid1=kang&wid2=cartlist&wid3=02').then(function () {443 driver.switchTo().frame('subIframe').then(function () {444 driver.findElement(By.id('memId')).then(function (el) {445 el.sendKeys(websiteList['interpark'].websiteId);446 driver.findElement(By.id('pwdObj')).then(function (el) {447 el.sendKeys(websiteList['interpark'].websitePw);448 driver.findElement(By.css('#login_type1 > table > tbody > tr:nth-child(1) > td:nth-child(2) > img')).then(function (el) {449 el.click().then(function(){450 driver.then(function () {451 driver.sleep(500);452 driver.manage().getCookies().then(function (cookies) {453 for (var i in cookies) {454 if (i == 0) {455 interparkCookies += cookies[i]['name'] + '=' + cookies[i]['value'];456 } else {457 interparkCookies += ';' + cookies[i]['name'] + '=' + cookies[i]['value'];458 }459 }460 driver.then(function () {461 db.pool.getConnection(function (err, conn) {462 if (err) {463 return;464 }465 var sql = "update tbl_logindata set cookies = ? where email = ? and website = 'interpark'";466 conn.query(sql, [interparkCookies, email], function (err, rows, fields) {467 conn.release();468 if (err) console.log("err");469 else callback(null, "update interpark cookies");470 });471 });472 });473 driver.quit();474 }, function (err) {475 console.log(err);476 driver.quit();477 });478 });479 },480 function(err){481 console.log(err);482 driver.quit();483 });484 }, function (err) {485 console.log(err);486 driver.quit();487 });488 }, function (err) {489 console.log(err);490 driver.quit();491 });492 }, function (err) {493 console.log(err);494 driver.quit();495 })496 }, function (err) {497 console.log(err);498 driver.quit();499 });500 }, function (err) {501 console.log(err);502 driver.quit();503 });504 }, function (err) {505 console.log("err - setCookiesForScheduling - interpark ::", err);506 callback(null, "update interpark cookies Err!!");507 });508 } catch (e) {509 console.log("catch exception at task4 - interpark");510 console.log(e);511 }512 } else {513 callback(null);514 }515 },516 function (callback) {517 if (websiteList.hasOwnProperty('gmarket')) {518 var gmarketCookies = "";519 try {520 const driver = new webdriver.Builder().forBrowser('phantomjs').build();521 driver.then(function () {522 driver.manage().timeouts().implicitlyWait(3000);523 driver.get('https://signinssl.gmarket.co.kr/login/login?prmtdisp=Y&url=http://escrow.gmarket.co.kr/ko/cart').then(function () {524 driver.findElement(By.id('id')).then(function (el) {525 el.sendKeys(websiteList['gmarket'].websiteId);526 driver.findElement(By.id('pwd')).then(function (el) {527 el.sendKeys(websiteList['gmarket'].websitePw);528 driver.findElement(By.css('#mem_login > div.login-input > div.btn-login > a > input[type="image"]')).then(function (el) {529 el.click().then(function(){530 driver.then(function () {531 driver.sleep(100);532 driver.manage().getCookies().then(function (cookies) {533 for (var i in cookies) {534 if (i == 0) {535 gmarketCookies += cookies[i]['name'] + '=' + cookies[i]['value'];536 } else {537 gmarketCookies += ';' + cookies[i]['name'] + '=' + cookies[i]['value'];538 }539 }540 driver.then(function () {541 db.pool.getConnection(function (err, conn) {542 if (err) {543 return;544 }545 var sql = "update tbl_logindata set cookies = ? where email = ? and website = 'gmarket'";546 conn.query(sql, [gmarketCookies, email], function (err, rows, fields) {547 conn.release();548 if (err) console.log("err");549 else callback(null, "update gmarket cookies");550 });551 });552 });553 driver.quit();554 }, function (err) {555 console.log(err);556 driver.quit();557 })558 }); 559 },function(err){560 console.log(err);561 driver.quit();562 });563 }, function (err) {564 console.log(err);565 driver.quit();566 });567 }, function (err) {568 console.log(err);569 driver.quit();570 });571 }, function (err) {572 console.log(err);573 driver.quit();574 })575 }, function (err) {576 console.log(err);577 driver.quit();578 });579 }, function (err) {580 console.log("err - setCookiesForScheduling - gmarket ::", err);581 callback(null, "update gmarket cookies Err!!");582 });583 } catch (e) {584 console.log("catch exception at task4 - gmarket");585 console.log(e);586 }587 } else {588 callback(null);589 }590 }591 ];592 async.waterfall(task3, function (err) {593 if (err) console.log("err");594 else {595 async.parallel(task4, function (err, result) {596 if (err) {597 console.log(err);598 }599 else {600 }601 });602 }603 });604}605var setCookiesAtAddLoginData = function (loginData, CBfunc) {606 var webCookies = "";607 var next = true;608 var loginNext = true;609 var task5 = [610 function (callback) {611 const driver = new webdriver.Builder().forBrowser('phantomjs').build();612 driver.then(function () {613 driver.manage().timeouts().implicitlyWait(3000);614 switch (loginData.website) {615 case 'gmarket':616 driver.get('https://signinssl.gmarket.co.kr/login/login?prmtdisp=Y&url=http://escrow.gmarket.co.kr/ko/cart').then(function () {617 driver.findElement(By.id('id')).then(function (el) {618 el.sendKeys(loginData.websiteId).then(function(){619 driver.findElement(By.id('pwd')).then(function (el) {620 el.sendKeys(loginData.websitePw).then(function(){621 driver.findElement(By.css('#mem_login > div.login-input > div.btn-login > a > input[type="image"]')).then(function (el) {622 el.click().then(function(){623 driver.getCurrentUrl().then(function (url) {624 if (url == "https://signinssl.gmarket.co.kr/LogIn/LogIn?member_type=MEM&failCheck=1&url=http://escrow.gmarket.co.kr/ko/cart") {625 loginNext = false;626 }627 }, function (err) {628 console.log(err);629 driver.quit();630 }); 631 },function(err){632 console.log(err);633 driver.quit();634 });635 }, function (err) {636 console.log(err);637 driver.quit();638 }); 639 },function(err){640 console.log(err);641 driver.quit();642 });643 644 }, function (err) {645 console.log(err);646 driver.quit();647 });648 },function(err){649 console.log(err);650 driver.quit();651 });652 }, function (err) {653 console.log(err);654 driver.quit();655 });656 }, function (err) {657 console.log(err);658 driver.quit();659 });660 break;661 case '11st':662 driver.get('https://login.11st.co.kr/login/Login.tmall?returnURL=http%3A%2F%2Fbuy.11st.co.kr%2Fcart%2FCartAction.tmall%3Fmethod%3DgetCartList&xfrom=').then(function () {663 driver.findElement(By.id('loginName')).then(function (el) {664 el.sendKeys(loginData.websiteId).then(function(){665 driver.findElement(By.id('passWord')).then(function (el) {666 el.sendKeys(loginData.websitePw).then(function(){667 driver.findElement(By.css('#memLogin > div.save_idW > input')).then(function (el) {668 el.click().then(function(){669 driver.getCurrentUrl().then(function (url) {670 if (url == "https://login.11st.co.kr/login/Login.tmall?returnURL=http%3A%2F%2Fbuy.11st.co.kr%2Fcart%2FCartAction.tmall%3Fmethod%3DgetCartList&errorCode=001&age19=") {671 loginNext = false;672 }673 }, function (err) {674 console.log(err);675 driver.quit();676 });677 },function(err){678 console.log(err);679 driver.quit();680 });681 }, function (err) {682 console.log(err);683 driver.quit();684 });685 },function(err){686 console.log(err);687 driver.quit();688 });689 }, function (err) {690 console.log(err);691 driver.quit();692 });693 },function(err){694 console.log(err);695 driver.quit();696 });697 }, function (err) {698 console.log(err);699 driver.quit();700 });701 }, function (err) {702 console.log(err);703 driver.quit();704 });705 break;706 case 'interpark':707 driver.get('http://www.interpark.com/order/cartlist.do?_method=cartList&logintgt=cart&wid1=kang&wid2=cartlist&wid3=02').then(function () {708 driver.switchTo().frame('subIframe').then(function () {709 driver.findElement(By.id('memId')).then(function (el) {710 el.sendKeys(loginData.websiteId).then(function(){711 driver.findElement(By.id('pwdObj')).then(function (el) {712 el.sendKeys(loginData.websitePw).then(function(){713 driver.findElement(By.css('#login_type1 > table > tbody > tr:nth-child(1) > td:nth-child(2) > img')).then(function (el) {714 el.click().then(function(){715 driver.findElement(By.css('span.cart')).getText().then(function () {716 loginNext = true;717 }).catch(function (err) {718 console.log("이거 찍히면 말좀해줘");719 console.log(err);720 loginNext = false;721 });722 },function(err){723 console.log(err);724 driver.quit();725 });726 }, function (err) {727 console.log(err);728 driver.quit();729 })730 },function(err){731 console.log(err);732 driver.quit();733 });734 }, function (err) {735 console.log(err);736 driver.quit();737 })738 },function(err){739 console.log(err);740 driver.quit();741 });742 }, function (err) {743 console.log(err);744 driver.quit();745 })746 }, function (err) {747 console.log(err);748 driver.quit();749 });750 }, function (err) {751 console.log(err);752 driver.quit();753 });754 break;755 case 'auction':756 driver.get('https://memberssl.auction.co.kr/authenticate/?url=http%3a%2f%2fbuy.auction.co.kr%2fbuy%2fA2014%2fCart%2fCart.aspx%3ffrm%3dhometab').then(function () {757 driver.findElement(By.id('id')).then(function (el) {758 el.sendKeys(loginData.websiteId).then(function(){759 driver.findElement(By.id('password')).then(function (el) {760 el.sendKeys(loginData.websitePw).then(function(){761 driver.findElement(By.id('Image1')).then(function (el) {762 el.click().then(function(){763 driver.getCurrentUrl().then(function (url) {764 if (url == "https://memberssl.auction.co.kr/Authenticate/default.aspx?return_value=-1&SELLER=&url=http%3a%2f%2fbuy.auction.co.kr%2fbuy%2fA2014%2fCart%2fCart.aspx%3ffrm%3dhometab&loginType=0&loginUIType=") {765 loginNext = false;766 }767 }, function (err) {768 console.log(err);769 driver.quit();770 });771 },function(err){772 console.log(err);773 driver.quit();774 });775 }, function (err) {776 console.log(err);777 driver.quit();778 });779 },function(err){780 console.log(err);781 driver.quit();782 });783 }, function (err) {784 console.log(err);785 driver.quit();786 });787 },function(err){788 console.log(err);789 driver.quit();790 });791 }, function (err) {792 console.log(err);793 driver.quit();794 });795 }, function (err) {796 console.log(err);797 driver.quit();798 });799 break;800 }801 }, function (err) {802 console.log("err - setWebsite - switch() : ", err);803 });804 driver.then(function () {805 if (loginNext) {806 driver.sleep(500);807 driver.manage().getCookies().then(function (cookies) {808 for (var i in cookies) {809 if (i == 0) {810 webCookies += cookies[i]['name'] + '=' + cookies[i]['value'];811 } else {812 webCookies += ';' + cookies[i]['name'] + '=' + cookies[i]['value'];813 }814 }815 driver.then(function () {816 callback(null, loginData, webCookies);817 driver.quit();818 });819 }, function (err) {820 console.log(err);821 driver.quit();822 })823 } else {824 callback("err");825 driver.quit();826 }827 }, function (err) {828 console.log("err - setWebsite - getCookies : ", err);829 });830 }, function (loginData, webCookies, callback) {831 db.pool.getConnection(function (err, conn) {832 if (err) {833 return;834 }835 var sql = "insert into tbl_loginData (email, website, websiteId, websitePw) values (?,?,?,HEX(AES_ENCRYPT(?,'aes')))";836 conn.query(sql, [loginData.email, loginData.website, loginData.websiteId, loginData.websitePw], function (err, result) {837 conn.release();838 if (err) {839 console.log("insert logindata err");...

Full Screen

Full Screen

tester.js

Source:tester.js Github

copy

Full Screen

...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() })143 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })144 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })145 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })146 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })147 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })148 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })149 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })150 }, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })151}, function(err){ scope.callback(true, err); driver.sleep(2000); return driver.quit() })152 .then(function(){ driver.sleep(2000); driver.wait(function(){driver.quit(); return scope.callback()}, 1000); });153*/154/*155// driver.get('http://localhost:4000/index.html');156// // driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');157// // driver.findElement(webdriver.By.name('btnG')).click();158// console.log('found');159// driver.wait(function() {160// return driver.getTitle().then(function(title) {161// return title === 'Splat';162// });163// }, 30000);164//165// driver.findElement(webdriver.By.id('clickid'));166//===========================167//GOOGLE TEST168driver.get('https://localhost:41484/index.html');169// driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');170// driver.findElement(webdriver.By.name('btnG')).click();171// driver.findElement(webdriver.By.id('gb_70')).click();172var run = function(callback) {173 driver.findElement(webdriver.By.xpath("//*[text()='Sign Ufhfhfp']")).then(function (el) {174 callback();175 }, function (e) {176 callback(e)177 });178 driver.findElement(webdriver.By.xpath("//*[text()='Sign']"));179};180run(function(err){181 if(err) return console.log('ERROR');182 else console.log('OK');183});184//======================185//GITHUB TEST186// driver.get('http://www.github.com');187// // driver.findElement(webdriver.By.xpath("//button[contains(.,'Sign up')]")).click();188// driver.findElement(webdriver.By.xpath("//*[text()='Sign up']")).click();189// driver.wait(function() {190// return driver.getTitle().then(function(title) {191// return title === 'Join GitHub · GitHub';192// });193// }, 1000);194driver.wait(function(){ driver.quit(); }, 4000);...

Full Screen

Full Screen

driver-e2e-specs.js

Source:driver-e2e-specs.js Github

copy

Full Screen

...26 afterEach(async () => {27 // try to get rid of the driver, so if a test fails the rest of the28 // tests aren't compromised29 try {30 await driver.quit();31 } catch (ign) {}32 });33 if (!process.env.REAL_DEVICE) {34 it('should start and stop a session', async function () {35 await driver.init(UICATALOG_SIM_CAPS);36 let els = await driver.elementsByClassName("XCUIElementTypeWindow");37 els.length.should.be.at.least(1);38 await driver.quit();39 });40 it('should start and stop a session doing pre-build', async function () {41 await driver.init(_.defaults({prebuildWDA: true}, UICATALOG_SIM_CAPS));42 let els = await driver.elementsByClassName("XCUIElementTypeWindow");43 els.length.should.be.at.least(1);44 await driver.quit();45 });46 it('should start and stop a session doing simple build-test', async function () {47 await driver.init(_.defaults({useSimpleBuildTest: true}, UICATALOG_SIM_CAPS));48 let els = await driver.elementsByClassName("XCUIElementTypeWindow");49 els.length.should.be.at.least(1);50 await driver.quit();51 });52 /* jshint ignore:start */53 describe('initial orientation', async () => {54 async function runOrientationTest (initialOrientation) {55 let caps = _.defaults({56 orientation: initialOrientation57 }, UICATALOG_SIM_CAPS);58 await driver.init(caps);59 let orientation = await driver.getOrientation();60 orientation.should.eql(initialOrientation);61 }62 for (let orientation of ['LANDSCAPE', 'PORTRAIT']) {63 it(`should be able to start in a ${orientation} mode`, async function () {64 this.timeout(MOCHA_TIMEOUT);65 await runOrientationTest(orientation);66 });67 }68 });69 /* jshint ignore:end */70 describe('reset', () => {71 it.skip('default: creates sim and deletes it afterwards', async () => {72 let caps = UICATALOG_SIM_CAPS;73 await killAllSimulators();74 let simsBefore = await getNumSims();75 await driver.init(caps);76 let simsDuring = await getNumSims();77 await driver.quit();78 let simsAfter = await getNumSims();79 simsDuring.should.equal(simsBefore + 1);80 simsAfter.should.equal(simsBefore);81 });82 it('with udid: uses sim and resets afterwards if resetOnSessionStartOnly is false', async () => {83 // before84 let udid = await createDevice('webDriverAgentTest', 'iPhone 6', UICATALOG_SIM_CAPS.platformVersion);85 let sim = await getSimulator(udid);86 await sim.run();87 // test88 let caps = _.defaults({89 udid,90 fullReset: true,91 resetOnSessionStartOnly: false92 }, UICATALOG_SIM_CAPS);93 (await simBooted(sim)).should.be.true;94 let simsBefore = await getNumSims();95 await driver.init(caps);96 let simsDuring = await getNumSims();97 await driver.quit();98 let simsAfter = await getNumSims();99 (await simBooted(sim)).should.be.false;100 // make sure no new simulators were created during the test101 simsDuring.should.equal(simsBefore);102 simsAfter.should.equal(simsBefore);103 // cleanup104 await deleteDevice(udid);105 });106 it('with udid booted: uses sim and leaves it afterwards', async () => {107 // before108 let udid = await createDevice('webDriverAgentTest', 'iPhone 6', UICATALOG_SIM_CAPS.platformVersion);109 let sim = await getSimulator(udid);110 await sim.run();111 // test112 let caps = _.defaults({113 udid,114 noReset: true115 }, UICATALOG_SIM_CAPS);116 (await simBooted(sim)).should.be.true;117 let simsBefore = await getNumSims();118 await driver.init(caps);119 let simsDuring = await getNumSims();120 await driver.quit();121 let simsAfter = await getNumSims();122 (await simBooted(sim)).should.be.true;123 simsDuring.should.equal(simsBefore);124 simsAfter.should.equal(simsBefore);125 // cleanup126 await sim.shutdown();127 await deleteDevice(udid);128 });129 it('with invalid udid: throws an error', async () => {130 // test131 let caps = _.defaults({132 udid: 'some-random-udid'133 }, UICATALOG_SIM_CAPS);134 await driver.init(caps).should.be.rejectedWith('environment you requested was unavailable');135 });136 it('with non-existent udid: throws an error', async () => {137 // test138 let udid = 'a77841db006fb1762fee0bb6a2477b2b3e1cfa7d';139 let caps = _.defaults({udid}, UICATALOG_SIM_CAPS);140 await driver.init(caps).should.be.rejectedWith('environment you requested was unavailable');141 });142 it('with noReset set to true: leaves sim booted', async function () {143 this.timeout(MOCHA_TIMEOUT);144 // before145 let udid = await createDevice('webDriverAgentTest', 'iPhone 6', UICATALOG_SIM_CAPS.platformVersion);146 let sim = await getSimulator(udid);147 // test148 let caps = _.defaults({149 udid,150 noReset: true151 }, UICATALOG_SIM_CAPS);152 let simsBefore = await getNumSims();153 await driver.init(caps);154 let simsDuring = await getNumSims();155 await driver.quit();156 let simsAfter = await getNumSims();157 (await simBooted(sim)).should.be.true;158 simsDuring.should.equal(simsBefore);159 simsAfter.should.equal(simsBefore);160 // cleanup161 await sim.shutdown();162 await deleteDevice(udid);163 });164 });165 describe('event timings', () => {166 it('should include event timings if cap is used', async () => {167 let newCaps = Object.assign({}, UICATALOG_SIM_CAPS, {eventTimings: true});168 await driver.init(newCaps);169 let res = await driver.sessionCapabilities();170 should.exist(res.events);171 should.exist(res.events.newSessionStarted);172 res.events.newSessionStarted[0].should.be.above(res.events.newSessionRequested[0]);173 });174 });175 } else {176 // real device tests177 describe('handle multiple back-to-back sessions', () => {178 it('should not fail when the new session is initiated', async () => {179 await driver.init(UICATALOG_CAPS);180 await driver.quit();181 await driver.init(UICATALOG_CAPS);182 await driver.quit();183 await driver.init(UICATALOG_CAPS);184 await driver.quit();185 });186 });187 }...

Full Screen

Full Screen

Index-man.js

Source:Index-man.js Github

copy

Full Screen

...57 await wait2sec();58 59 try {60 await driver.switchTo().alert();61 await driver.quit();62 return;63 } catch (err) {64 }65 // can't be reached66 try {67 let cant = await driver.findElement(By.id('t'));68 await driver.quit();69 return;70 } catch (err) { }71 let email;72 let start = Date.now();73 while (!email) {74 try {75 email = await driver.findElement(By.name('emailOrPhone'));76 } catch (err) { }77 let diff = Date.now() - start;78 if (diff > 100000) {79 await driver.quit();80 return;81 }82 }83 var sEmail = account.email;//_createNewEmail();84 await email.sendKeys(sEmail);85 await wait2sec();86 await wait2sec();87 await wait5sec();88 const pwd = Math.random().toString(36).substring(2, 9);89 //var sUsername = _createUserName();90 var sUsername = account.first + "." + account.last + "." + account.address.substring(0, 2);;91 var username = await driver.findElement(By.name('username'));92 await username.sendKeys(sUsername);93 await wait5sec();94 var sPwd = pwd; //_createPW();95 var password = await driver.findElement(By.name('password'));96 await password.sendKeys(sPwd);97 await wait2sec();98 var regBtn = await driver.findElement(By.xpath('//*[@id="react-root"]/section/main/article/div[2]/div[1]/div/form/div[7]/div/button'));99 var text = await regBtn.getText();100 if (text === 'Далее' || text === 'Next'){101 driver.quit();102 return;103 }104 await wait2sec();105 await wait2sec();106 await wait2sec();107 await wait2sec();108 await wait5sec();109 await regBtn.click();110 await wait2sec();111 await wait2sec();112 await wait2sec();113 await wait2sec();114 try {115 let err = await driver.findElement(By.id("ssfErrorAlert"));116 console.log("NO ", sUsername);117 } catch (err) {118 console.log("MAYBE NEED CHECK ", sUsername);119 let start1 = Date.now();120 let check18;121 while (!check18) {122 try {123 let diff = Date.now() - start1;124 if (diff > 10000) {125 try {126 let err = await driver.findElement(By.id("ssfErrorAlert"));127 try {128 let addPhone = await driver.findElement(By.xpath('//*[@id="react-root"]/section/div/div/div[1]/h2)'));129 console.log("YES PHONE ", sUsername);130 await driver.quit();131 return;132 } catch (err){133 }134 console.log("NO ", sUsername);135 await driver.quit();136 return;137 } catch (err) {138 console.log("TRY NEXT!", sUsername);139 await wait5sec();140 await driver.quit();141 return;142 }143 }144 check18 = await driver.findElement(By.id('igCoreRadioButtonageRadioabove_18'));145 await check18.click();146 await driver.findElement(By.xpath('/html/body/div[3]/div/div[3]/div/button')).click();147 console.log("YES!", sUsername);148 await driver.quit();149 } catch (err) {150 }151 }152 }153 await driver.quit();154 // return {155 // email: sEmail,156 // username: sUsername,157 // pwd: sPwd158 // }159 } catch (err) {160 // if (driver){161 // await driver.quit();162 // }163 //await driver.quit();164 var a = 1;165 }166 // await driver.quit();167}168//===============================================...

Full Screen

Full Screen

remote.test.js

Source:remote.test.js Github

copy

Full Screen

...51 });52 it('should join and leave group', async () => {53 this.timeout(240000);54 await testLoadGroup(driver);55 await driver.quit();56 }).timeout(240000);57 it('should change and delete name', async () => {58 this.timeout(240000);59 await testChangeName(driver);60 await driver.quit();61 }).timeout(240000);62 it('should check and stop share Location', async () => {63 this.timeout(240000);64 await testShareLocation(driver);65 await driver.quit();66 }).timeout(240000);67 it('should check who I am', async () => {68 this.timeout(240000);69 await testMe(driver);70 await driver.quit();71 }).timeout(240000);72 it('should send a message', async () => {73 this.timeout(240000);74 await testSendMessage(driver);75 await driver.quit();76 }).timeout(240000);77 it('should receive a message', async () => {78 this.timeout(240000);79 await testReceiveMessage(driver);80 await driver.quit();81 }).timeout(240000);82 it('should recieve a changed name', async () => {83 this.timeout(240000);84 await testCnCNameChange(driver);85 await driver.quit();86 }).timeout(240000);87 it('should delete data', async () => {88 this.timeout(240000);89 await testDeleteData(driver);90 await driver.quit();91 }).timeout(240000);92 it('should load Cookies at refresh', async () => {93 this.timeout(240000);94 await testCookies(driver);95 await driver.quit();96 }).timeout(240000);97 it('should throw error if username is empty', async () => {98 this.timeout(240000);99 await testNoUsernameAtLogin(driver);100 await driver.quit();101 }).timeout(240000);102 it('should show more information page', async () => {103 this.timeout(240000);104 await testMoreInformation(driver);105 await driver.quit();106 }).timeout(240000);107 it('should forward to feedback popup', async () => {108 this.timeout(240000);109 await testFeedbackAtLogin(driver);110 await driver.quit();111 }).timeout(240000);112 it('should open TICE software page', async () => {113 this.timeout(240000);114 await testAboutTICESoftware(driver);115 await driver.quit();116 }).timeout(240000);117 it('should open Impressum page', async () => {118 this.timeout(240000);119 await testAboutImpressum(driver);120 await driver.quit();121 }).timeout(240000);122 it('should open TICE App page', async () => {123 this.timeout(240000);124 await testAboutTICEApp(driver);125 await driver.quit();126 }).timeout(240000);127 it('should open TICE Instagram page', async () => {128 this.timeout(240000);129 await testAboutInstagram(driver);130 await driver.quit();131 }).timeout(240000);132 it('should open TICE Facebook page', async () => {133 this.timeout(240000);134 await testAboutFacebook(driver);135 await driver.quit();136 }).timeout(240000);137 it('should open TICE Twitter page', async () => {138 this.timeout(240000);139 await testAboutTwitter(driver);140 await driver.quit();141 }).timeout(240000);142 });143};...

Full Screen

Full Screen

test.js

Source:test.js Github

copy

Full Screen

...13 await driver.findElement(By.id("addresssignup")).sendKeys("kathmandu");14 await driver.findElement(By.id("mobilesignup")).sendKeys("1234567");15 await driver.sleep(delay);16 await driver.findElement(By.id("signupBtn")).click();17 await driver.quit();18});19Given("Test login functionality", { timeout: 30000 }, async function () {20 let driver = await new Builder().forBrowser("chrome").build();21 await driver.get("http://localhost:3000/login");22 await driver.findElement(By.id("usernamelogin")).sendKeys("test2");23 await driver.findElement(By.id("passwordlogin")).sendKeys("test2");24 await driver.sleep(delay);25 await driver.findElement(By.id("loginBtn")).click();26 await driver.quit();27});28Given("Test profile functionality", { timeout: 30000 }, async function () {29 let driver = await new Builder().forBrowser("chrome").build();30 await driver.get("http://localhost:3000/profile-update");31 await driver.findElement(By.id("updateFnmae")).sendKeys("test1");32 await driver.findElement(By.id("updateLname")).sendKeys("test1");33 await driver.findElement(By.id("update-email")).sendKeys("test1@gmail.com");34 await driver.findElement(By.id("update-address")).sendKeys("test10");35 await driver.findElement(By.id("update-mobile")).sendKeys("22222222");36 await driver.findElement(By.id("update-curentpasword")).sendKeys("test1");37 await driver.sleep(delay);38 await driver.findElement(By.id("upProfileBtn")).click();39 await driver.quit();40});41//Sprint 342Given("Test AskQuestion functionality", { timeout: 30000 }, async function () {43 let driver = await new Builder().forBrowser("chrome").build();44 await driver.get("http://localhost:3000/ask-question");45 await driver.findElement(By.id("title")).sendKeys("test");46 await driver.findElement(By.id("body")).sendKeys("test");47 await driver.findElement(By.id("tag-input")).sendKeys("test");48 await driver.sleep(delay);49 await driver.findElement(By.id("submit-button")).click();50 await driver.quit();51});52Given("Test PostAnswer functionality", { timeout: 30000 }, async function () {53 let driver = await new Builder().forBrowser("chrome").build();54 await driver.get("http://localhost:3000/questions/60f6ea683770120e60944e3b");55 await driver.findElement(By.id("post-answer")).sendKeys("abcd");56 await driver.sleep(delay);57 await driver.findElement(By.id("addAnswer")).click();58 await driver.quit();59});60//Sprint 461Given("Test Comment functionality", { timeout: 30000 }, async function () {62 let driver = await new Builder().forBrowser("chrome").build();63 await driver.get("http://localhost:3000/questions/60f681de79b0dd4808c76433");64 await driver65 .findElement(By.id("exampleFormControlTextarea1"))66 .sendKeys("wwww");67 await driver.sleep(delay);68 await driver.findElement(By.id("addCommentTest")).click();69 await driver.quit();70});71//Sprint 572Given("Test subject functionality", { timeout: 30000 }, async function () {73 let driver = await new Builder().forBrowser("chrome").build();74 await driver.get("http://localhost:3000/admin/Computer");75 await driver.findElement(By.id("input-topic")).sendKeys("operating system");76 await driver.sleep(delay);77 await driver.findElement(By.id("create-button")).click();78 await driver.quit();79});80//Sprint 681Given("Test Posts functionality", { timeout: 30000 }, async function () {82 let driver = await new Builder().forBrowser("chrome").build();83 await driver.get("http://localhost:3000/tag-search");84 await driver.findElement(By.id("tag")).sendKeys("science");85 await driver.sleep(delay);86 await driver.findElement(By.id("tag-button")).click();87 await driver.quit();88});89Given("Test users functionality", { timeout: 30000 }, async function () {90 let driver = await new Builder().forBrowser("chrome").build();91 await driver.get("http://localhost:3000/user-search");92 await driver.findElement(By.id("profile-search")).sendKeys("test2");93 await driver.sleep(delay);94 await driver.findElement(By.id("button-search")).click();95 await driver.quit();96});97// Sprint 798Given("Test quiz functionality", { timeout: 30000 }, async function () {99 let driver = await new Builder().forBrowser("chrome").build();100 await driver.get(101 "http://localhost:3000/admin/quiz/Algebra/612a5a443aa9d50004b90795"102 );103 await driver.findElement(By.id("question")).sendKeys("test1");104 await driver.findElement(By.id("option1")).sendKeys("test2");105 await driver.findElement(By.id("option2")).sendKeys("test3");106 await driver.findElement(By.id("option3")).sendKeys("test4");107 await driver.findElement(By.id("option4")).sendKeys("test5");108 await driver.findElement(By.id("answer")).sendKeys("test1");109 await driver.sleep(delay);110 await driver.findElement(By.id("quiz-admin")).click();111 await driver.quit();...

Full Screen

Full Screen

webInterface.js

Source:webInterface.js Github

copy

Full Screen

...13 await driver.get("https://instagram.com");14 await Wait.wait(2);15 try {16 await driver.switchTo().alert();17 await driver.quit();18 resolve("dummy");19 return;20 } catch (err) {21 }22 // can't be reached23 try {24 let cant = await driver.findElement(By.id('t'));25 await driver.quit();26 resolve("dummy");27 return;28 } catch (err) { }29 let email;30 let start = Date.now();31 while (!email) {32 try {33 email = await driver.findElement(By.name('emailOrPhone'));34 } catch (err) { }35 let diff = Date.now() - start;36 if (diff > 100000) {37 await driver.quit();38 resolve("dummy");39 return;40 }41 }42 var sEmail = account.email;//_createNewEmail();43 await email.sendKeys(sEmail);44 await Wait.wait(1);45 await Wait.wait(1);46 await Wait.wait(5);47 const pwd = Math.random().toString(36).substring(2, 9);48 //var sUsername = _createUserName();49 var sUsername = account.first + "." + account.last + "." + account.address.substring(0, 2);;50 var username = await driver.findElement(By.name('username'));51 await username.sendKeys(sUsername);52 await Wait.wait(5);53 var sPwd = pwd; //_createPW();54 var password = await driver.findElement(By.name('password'));55 await password.sendKeys(sPwd);56 await Wait.wait(1);57 var regBtn = await driver.findElement(By.xpath('//*[@id="react-root"]/section/main/article/div[2]/div[1]/div/form/div[7]/div/button'));58 var text = await regBtn.getText();59 if (text === 'Далее' || text === 'Next') {60 driver.quit();61 resolve("dummy");62 return;63 }64 await Wait.wait(4);65 await Wait.wait(5);66 await regBtn.click();67 await Wait.wait(4);68 try {69 let err = await driver.findElement(By.id("ssfErrorAlert"));70 console.log("NO ", sUsername);71 } catch (err) {72 console.log("MAYBE NEED CHECK ", sUsername);73 let start1 = Date.now();74 let check18;75 while (!check18) {76 try {77 let diff = Date.now() - start1;78 if (diff > 10000) {79 try {80 let err = await driver.findElement(By.id("ssfErrorAlert"));81 try {82 let addPhone = await driver.findElement(By.xpath('//*[@id="react-root"]/section/div/div/div[1]/h2)'));83 console.log("YES PHONE ", sUsername);84 await driver.quit();85 resolve("dummy");86 return;87 } catch (err) {88 }89 console.log("NO ", sUsername);90 await driver.quit();91 resolve("dummy");92 return;93 } catch (err) {94 console.log("TRY NEXT!", sUsername);95 await Wait.wait(5);96 await driver.quit();97 resolve("dummy");98 return;99 }100 }101 check18 = await driver.findElement(By.id('igCoreRadioButtonageRadioabove_18'));102 await check18.click();103 await driver.findElement(By.xpath('/html/body/div[3]/div/div[3]/div/button')).click();104 console.log("YES!", sUsername);105 await driver.quit();106 } catch (err) {107 }108 }109 }110 await driver.quit();111 resolve("dummy");112 // return {113 // email: sEmail,114 // username: sUsername,115 // pwd: sPwd116 // }117 } catch (err) {118 // if (driver){119 // await driver.quit();120 // }121 //await driver.quit();122 var a = 1;123 }124 });...

Full Screen

Full Screen

devices.js

Source:devices.js Github

copy

Full Screen

...19 this.driver = createDriver(url, size, browserType);20 return this.driver;21 },22 quit: function () {23 this.driver.quit();24 }25 });26}27function inSeleniumGrid(gridUrl, deviceName, tags, gridSettings) {28 return new Device({29 deviceName: deviceName,30 tags: tags,31 initDriver: function (url) {32 this.driver = createGridDriver(gridUrl, gridSettings);33 return this.driver;34 },35 quit: function () {36 this.driver.quit();37 }38 });39}40function convertGridDevices(devicesJson, gridUrl) {41 if (gridUrl === undefined || gridUrl === null) {42 throw new Error("Missing gridUrl argument");43 }44 var devices = {};45 forMap(devicesJson, function (deviceName, deviceSettings) {46 devices[deviceName] = inSeleniumGrid(gridUrl, deviceSettings.deviceName, deviceSettings.tags, deviceSettings.gridSettings);47 });48 return devices;49}50function loadGridDevices(configPath, gridUrl) {...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const assert = require('assert');3const chai = require('chai');4const chaiAsPromised = require('chai-as-promised');5chai.use(chaiAsPromised);6chai.should();7chaiAsPromised.transferPromiseness = wd.transferPromiseness;8const desiredCaps = {9};10const driver = wd.promiseChainRemote('localhost', 4723);11driver.init(desiredCaps)12 .then(() => driver.quit())13 .then(() => console.log('success'))14 .catch((err) => console.log('error', err));15{16 "scripts": {17 },18 "dependencies": {19 }20}21const driver = wd.promiseChainRemote('localhost', 4723);22driver.init(desiredCaps)23 .then(() => driver.quit())24 .then(() => console.log('success'))25 .catch((err) => console.log('error', err));26const driver = wd.promiseChainRemote('localhost', 4723);27driver.init(desiredCaps)28 .then(() => console.log('success'))29 .catch((err) => console.log('error', err));30const driver = wd.promiseChainRemote('localhost', 4723);31driver.init(desiredCaps)32 .then(() => driver.quit())33 .then(() => console.log('success'))34 .catch((err) => console.log('error', err));

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .forBrowser('selenium-appium')4 .withCapabilities({5 })6 .build();7driver.quit();8var webdriver = require('selenium-webdriver');9var driver = new webdriver.Builder()10 .forBrowser('selenium-appium')11 .withCapabilities({12 })13 .build();14driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1(async () => {2 const driver = await wdio.remote({3 capabilities: {4 }5 });6 await driver.pause(5000);7 console.log("Test Passed");8})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const { assert } = require('chai');3const { exec } = require('child_process');4const path = require('path');5const { retryInterval } = require('asyncbox');6const { fs } = require('appium-support');7const BUNDLE_ID = 'com.apple.Preferences';8const APP = path.resolve(__dirname, 'TestApp.app.zip');9const caps = {10};11driver.on('status', console.log);12driver.on('command', console.log);13driver.on('http', console.log);14async function main () {15 await driver.init(caps);16 const el = await driver.elementByAccessibilityId('General');17 await el.click();18 const el2 = await driver.elementByAccessibilityId('About');19 await el2.click();20 const el3 = await driver.elementByAccessibilityId('Version');21 const text = await el3.text();22 assert.equal(text, 'Version');23 await driver.quit();24}25main();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { remote } = require('webdriverio');2const opts = {3 capabilities: {4 },5};6(async () => {7 const driver = await remote(opts);8 await driver.quit();9})();10const { remote } = require('webdriverio');11const opts = {12 capabilities: {13 },14};15(async () => {16 const driver = await remote(opts);17 await driver.deleteSession();18})();19const { remote } = require('webdriverio');20const opts = {21 capabilities: {22 },23};24(async () => {25 const driver = await remote(opts);26 await driver.deleteSession();27})();28const { remote } = require('webdriverio');29const opts = {30 capabilities: {

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