How to use driver.getLog method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

jsStatement.js

Source:jsStatement.js Github

copy

Full Screen

1/* WebRequestオブジェクト */2var WebRequest = function(uribase) {3 this.uribase = uribase;4}5WebRequest.debug = false;6WebRequest.http_request_progid = "WinHttp.WinHttpRequest.5.1";7WebRequest.send = function(method, uri, body) {8 var xhr = new ActiveXObject(WebRequest.http_request_progid);9 xhr.open(method, uri, false);10 xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8");11 strbody = body ? JSON.stringify(body): null;12 xhr.send(strbody);13 if (WebRequest.debug) {14 WebDriver.Log.push({15 "api": uri,16 "body": strbody,17 "status": xhr.status,18 "statusText": xhr.statusText,19 "response": xhr.responseText20 });21 }22 if (xhr.status === 200) {23 return JSON.parse(xhr.responseText);24 }25 return null;26};27WebRequest.prototype.Get = function(api) {28 var uri = this.uribase + api;29 return WebRequest.send('GET', uri, null);30}31WebRequest.prototype.Post = function(api, body) {32 var uri = this.uribase + api;33 return WebRequest.send('POST', uri, body);34}35WebRequest.prototype.Put = function(api, body) {36 var uri = this.uribase + api;37 return WebRequest.send('PUT', uri, body);38}39WebRequest.prototype.Delete = function(api) {40 var uri = this.uribase + api;41 return WebRequest.send('DELETE', uri, null);42}43/* WebDriverオブジェクト */44var WebDriver = function(sessionId, uribase, capabilities) {45 this.uribase = uribase;46 this.sessionId = sessionId;47 this.capabilities = capabilities;48 var apibase = uribase + '/session/' + this.sessionId;49 this.request = new WebRequest(apibase);50 this.version = null;51 this.path = null;52};53WebDriver.prototype.GetSession = function() {54 return [55 this.sessionId,56 this.uribase,57 JSON.stringify(this.capabilities),58 // this.GetBrowserName(),59 // this.GetBrowserVersion(),60 this.path,61 this.version62 ].join('|');63};64WebDriver.Start = function(uribase, capabilities, debug) {65 WebRequest.debug = debug;66 if (capabilities)67 capabilities = JSON.parse(capabilities);68 var uri = uribase + '/session';69 var body = capabilities;70 r = WebRequest.send('POST', uri, body);71 if (r) {72 var sessionId = r.sessionId || r.value.sessionId;73 var d = new WebDriver(sessionId, uribase, (r.value.capabilities || r.value));74 d.SetImplicitWait(10000);75 return d;76 }77 return null;78};79WebDriver.Connect = function(sessionString, debug) {80 WebRequest.debug = debug;81 var s = sessionString.split('|');82 var capa = JSON.parse(s[2]);83 var d = new WebDriver(s[0], s[1], capa);84 if (! d)85 return null;86 d.path = s[3]87 d.version = s[4]88 // apiが通れば再接続成功89 var r = d.request.Get('/url');90 if (! r)91 return null; // edge, firefoxでエラー92 if (r.status)93 return null; // chromeでエラー94 return d;95};96WebDriver.Log = [];97WebDriver.GetLog = function() {98 var d = new ActiveXObject("Scripting.Dictionary");99 for (var i = 0; i < WebDriver.Log.length; i++) {100 d.add(i, WebDriver.Log[i]);101 }102 return d.Items();103}104WebDriver.ClearLog = function() {105 WebDriver.Log = [];106}107WebDriver.NewJSArray = function() {108 return [];109}110WebDriver.Contains = function(arr, value) {111 for (var i = 0; i < arr.length; i++) {112 if (arr[i] === value)113 return true;114 }115 return false;116}117WebDriver.ConvertToSafeArray = function(arr) {118 var dictionary = new ActiveXObject("Scripting.Dictionary");119 for (var i = 0; i < arr.length; i++) {120 dictionary.add(i, arr[i]);121 }122 return dictionary.Items();123}124WebDriver.prototype.get_browser_pid = function() {125 return this.capabilities["moz:processID"] || 0;126}127WebDriver.prototype.get_browser_port = function() {128 var opt = this.capabilities["goog:chromeOptions"] || this.capabilities["ms:edgeOptions"];129 if (opt != null)130 return opt.debuggerAddress.split(':')[1];131 return 0;132};133WebDriver.prototype.getbrowsername = 134WebDriver.prototype.GETBROWSERNAME = 135WebDriver.prototype.GetBrowserName = 136WebDriver.prototype.GetBrowserName = function() {137 return this.capabilities.browserName;138};139WebDriver.prototype.get_browser_version = 140WebDriver.prototype.getbrowserversion = 141WebDriver.prototype.GETBROWSERVERSION = 142WebDriver.prototype.getBrowserVersion = 143WebDriver.prototype.GetBrowserVersion = function() {144 return this.capabilities.browserVersion || this.capabilities.version;145};146WebDriver.prototype.set_implicit_wait = 147WebDriver.prototype.setImplicitWait =148WebDriver.prototype.setimplicitwait = 149WebDriver.prototype.SETIMPLICITWAIT = 150WebDriver.prototype.SetImplicitWait = function(millisec) {151 var api = '/timeouts';152 var body = {"implicit": millisec};153 return this.request.Post(api, body);154};155WebDriver.prototype.navigate =156WebDriver.prototype.NAVIGATE =157WebDriver.prototype.Navigate = function(url, target) {158 var api = '/url';159 var body = {"url": url};160 if (! target) {161 return this.request.Post(api, body);162 }163 var js = "var tmp = document.createElement('a');"164 + "tmp.href = arguments[0];"165 + "tmp.target = arguments[1];"166 + "tmp.click();"167 + "tmp = null;";168 return this.ExecuteScript(js, [url, target]);169};170WebDriver.prototype.reload =171WebDriver.prototype.RELOAD =172WebDriver.prototype.Reload = function() {173 var api = '/refresh';174 var body = {"url": ""};175 this.request.Post(api, body);176};177WebDriver.prototype.switch_window =178WebDriver.prototype.switchWindow =179WebDriver.prototype.switchwindow =180WebDriver.prototype.SWITCHWINDOW =181WebDriver.prototype.SwitchWindow = function(handleOrName) {182 var handles = this._getWindowHandles();183 var api = '/window';184 var body, name185 if (WebDriver.Contains(handles, handleOrName)) {186 body = {187 "handle": handleOrName,188 "name": ""189 };190 this.request.Post(api, body);191 var r = this.request.Get(api);192 if (r)193 return r.value;194 } else {195 for (var i = 0; i < handles.length; i++) {196 body = {197 "handle": handles[i],198 "name": handleOrName199 };200 this.request.Post(api, body);201 name = this.ExecuteScript('return window.name;');202 if (name == handleOrName) {203 var r = this.request.Get(api);204 if (r)205 return r.value;206 }207 }208 }209 return null;210};211WebDriver.prototype.switch_frame =212WebDriver.prototype.switchFrame =213WebDriver.prototype.switchframe =214WebDriver.prototype.SWITCHFRAME =215WebDriver.prototype.SwitchFrame = function(id) {216 var api = '/frame';217 var body = {};218 if (id < 0) {219 api += '/parent'220 } else {221 body["id"] = id || null;222 }223 var r = this.request.Post(api, body);224 // return JSON.stringify(r);225 return r != null && r.value == null226};227WebDriver.prototype.get_current_window_handle =228WebDriver.prototype.getCurrentWindowHandle =229WebDriver.prototype.getcurrentwindowhandle =230WebDriver.prototype.GETCURRENTWINDOWHANDLE =231WebDriver.prototype.GetCurrentWindowHandle = function() {232 var api = '/window';233 var r = this.request.Get(api);234 return r.value;235};236WebDriver.prototype._getWindowHandles = function() {237 var api = '/window/handles';238 var r = this.request.Get(api);239 if (r)240 return r.value;241 return [];242};243WebDriver.prototype.get_window_handles =244WebDriver.prototype.getWindowHandles =245WebDriver.prototype.getwindowhandles =246WebDriver.prototype.GETWINDOWHANDLES =247WebDriver.prototype.GetWindowHandles = function() {248 var handles = this._getWindowHandles();249 return WebDriver.ConvertToSafeArray(handles);250};251WebDriver.prototype.get_url =252WebDriver.prototype.getUrl =253WebDriver.prototype.geturl =254WebDriver.prototype.GETURL =255WebDriver.prototype.GetUrl = function() {256 var api = '/url';257 var r = this.request.Get(api);258 if (r)259 return r.value;260};261WebDriver.prototype.get_title =262WebDriver.prototype.getTitle =263WebDriver.prototype.gettitle =264WebDriver.prototype.GETTITLE =265WebDriver.prototype.GetTitle = function() {266 var api = '/title';267 var r = this.request.Get(api);268 if (r)269 return r.value;270};271WebDriver.prototype.get_source =272WebDriver.prototype.getSource =273WebDriver.prototype.getsource =274WebDriver.prototype.GETSOURCE =275WebDriver.prototype.GetSource = function() {276 var api = '/source';277 var r = this.request.Get(api);278 if (r)279 return r.value;280};281WebDriver.prototype.find_single_elem = function(body) {282 var api = '/element';283 var r = this.request.Post(api, body);284 var eid;285 if (r && r.value) {286 return WebDriver.to_element_object(this.request.uribase, r.value);287 }288 return null;289};290WebDriver.prototype.find_multi_elem = function(body) {291 var api = '/elements';292 var r = this.request.Post(api, body);293 if (! r && r.status != 0)294 return null;295 var dictionary = new ActiveXObject("Scripting.Dictionary");296 for (var i = 0; i < r.value.length; i++) {297 var element = WebDriver.to_element_object(this.request.uribase, r.value[i]);298 dictionary.add(i, element);299 }300 return dictionary.Items();301};302WebDriver.prototype.find_element =303WebDriver.prototype.findElement =304WebDriver.prototype.findelement =305WebDriver.prototype.FINDELEMENT =306WebDriver.prototype.FindElement = function(selector) {307 var body = {308 "using": "css selector",309 "value": selector310 };311 return this.find_single_elem(body);312};313WebDriver.prototype.find_elements =314WebDriver.prototype.findElements =315WebDriver.prototype.findelements =316WebDriver.prototype.FINDELEMENTS =317WebDriver.prototype.FindElements = function(selector) {318 var body = {319 "using": "css selector",320 "value": selector321 };322 return this.find_multi_elem(body);323};324WebDriver.prototype.find_elements_by_name =325WebDriver.prototype.findElementsByName =326WebDriver.prototype.findelementsbyname =327WebDriver.prototype.FINDELEMENTSBYNAME =328WebDriver.prototype.FindElementsByName = function(name) {329 return this.FindElements('*[name="' + name + '"]');330};331WebDriver.prototype.find_element_by_x_path =332WebDriver.prototype.findElementByXPath =333WebDriver.prototype.findelementbyxpath =334WebDriver.prototype.FINDELEMENTBYXPATH =335WebDriver.prototype.FindElementByXPath = function(xpath) {336 var body = {337 "using": "xpath",338 "value": xpath339 };340 return this.find_single_elem(body);341};342WebDriver.prototype.find_elements_by_x_path =343WebDriver.prototype.findElementsByXPath =344WebDriver.prototype.findelementsbyxpath =345WebDriver.prototype.FINDELEMENTSBYXPATH =346WebDriver.prototype.FindElementsByXPath = function(xpath) {347 var body = {348 "using": "xpath",349 "value": xpath350 };351 return this.find_multi_elem(body);352};353WebDriver.prototype.close =354WebDriver.prototype.CLOSE =355WebDriver.prototype.Close = function() {356 var api = '';357 this.request.Delete(api);358};359WebDriver.prototype.get_dialog_text =360WebDriver.prototype.getDialogText =361WebDriver.prototype.getdialogtext =362WebDriver.prototype.GETDIALOGTEXT =363WebDriver.prototype.GetDialogText = function() {364 var api = '/alert/text';365 var r = this.request.Get(api);366 if (r) {367 if (r.value.error)368 return null;369 return r.value;370 }371};372WebDriver.prototype.set_dialog_text =373WebDriver.prototype.setDialogText =374WebDriver.prototype.setdialogtext =375WebDriver.prototype.SETDIALOGTEXT =376WebDriver.prototype.SetDialogText = function(value) {377 var api = '/alert/text';378 var body = {379 text: value,380 value: value.split('')381 };382 this.request.Post(api, body);383};384WebDriver.prototype.accept_dialog =385WebDriver.prototype.acceptDialog =386WebDriver.prototype.acceptdialog =387WebDriver.prototype.ACCEPTDIALOG =388WebDriver.prototype.AcceptDialog = function() {389 var api = '/alert/accept';390 var body = {};391 this.request.Post(api, body);392};393WebDriver.prototype.dismiss_dialog =394WebDriver.prototype.dismissDialog =395WebDriver.prototype.dismissdialog =396WebDriver.prototype.DISMISSDIALOG =397WebDriver.prototype.DismissDialog = function() {398 var api = '/alert/dismiss';399 var body = {};400 this.request.Post(api, body);401};402WebDriver.prototype.save_screenshot =403WebDriver.prototype.saveScreenshot =404WebDriver.prototype.savescreenshot =405WebDriver.prototype.SAVESCREENSHOT =406WebDriver.prototype.SaveScreenshot = function(path) {407 var api = '/screenshot';408 var r = this.request.Get(api);409 WebDriver._saveScreenshot(r.value, path);410};411WebDriver.to_element_object = function(apibase, value) {412 var eid;413 if (value.ELEMENT) {414 eid = value.ELEMENT;415 } else {416 for (var key in value) {417 if (key.match(/element/)) {418 eid = value[key];419 break;420 }421 }422 }423 if (eid) {424 return new WebElement(apibase, eid, value);425 }426 return null;427}428WebDriver.ExecuteScript = function(driverapibase, js, args) {429 var url = driverapibase + '/execute/sync';430 args = args || [];431 var body = {432 "script": js,433 "args": args434 };435 var r = WebRequest.send('POST', url, body);436 if (r != null && r.value != null) {437 var elem = WebDriver.to_element_object(driverapibase, r.value);438 if (elem) {439 return elem;440 }441 return r.value;442 }443 return null;444};445WebDriver.prototype.execute_script =446WebDriver.prototype.executeScript =447WebDriver.prototype.executescript =448WebDriver.prototype.EXECUTESCRIPT =449WebDriver.prototype.ExecuteScript = function(js, args) {450 return WebDriver.ExecuteScript(this.request.uribase, js, args)451};452WebDriver._saveScreenshot = function(base64, path) {453 var xmldom = new ActiveXObject('Microsoft.XMLDOM');454 var elem = xmldom.createElement("base64");455 elem.dataType = "bin.base64";456 elem.text = base64;457 bin = elem.nodeTypedValue;458 var stream = new ActiveXObject('ADODB.Stream');459 stream.Open()460 stream.Type = 1 // adTypeBinary461 stream.Write(bin)462 stream.SaveToFile(path, 2) // adSaveCreateOverWrite463 stream.Close()464}465WebDriver.prototype.get_rect =466WebDriver.prototype.getRect =467WebDriver.prototype.getrect =468WebDriver.prototype.GETRECT =469WebDriver.prototype.GetRect = function() {470 var api = '/window/rect';471 var r = this.request.Get(api);472 if (r.value.x !== null)473 return r.value;474};475WebDriver.prototype.set_rect =476WebDriver.prototype.setRect =477WebDriver.prototype.setrect =478WebDriver.prototype.SETRECT =479WebDriver.prototype.SetRect = function(width, height, x, y) {480 var api = '/window/rect';481 var body = {482 "width": width,483 "height": height,484 "x": x,485 "y": y486 }487 var r = this.request.Post(api, body);488 if (r.value.x !== null)489 return r.value;490};491WebDriver.prototype.maximize =492WebDriver.prototype.MAXIMIZE =493WebDriver.prototype.Maximize = function() {494 var api = '/window/maximize';495 var body = {}496 var r = this.request.Post(api, body);497 if (r.value.x !== null)498 return r.value;499};500WebDriver.prototype.minimize =501WebDriver.prototype.MINIMIZE =502WebDriver.prototype.Minimize = function() {503 var api = '/window/minimize';504 var body = {}505 var r = this.request.Post(api, body);506 if (r.value.x !== null)507 return r.value;508};509WebDriver.prototype.fullscreen =510WebDriver.prototype.FULLSCREEN =511WebDriver.prototype.Fullscreen = function() {512 var api = '/window/fullscreen';513 var body = {}514 var r = this.request.Post(api, body);515 if (r.value.x !== null)516 return r.value;517};518/* WebElementオブジェクト */519var WebElement = function(driverapibase, elementId, elementObject) {520 this.object = elementObject;521 this.elementId = elementId;522 this.driverapibase = driverapibase;523 var elementapibase = driverapibase + '/element/' + elementId;524 this.request = new WebRequest(elementapibase)525};526WebElement.prototype.raw =527WebElement.prototype.RAW =528WebElement.prototype.Raw = function() {529 return this.object;530};531WebElement.prototype.click =532WebElement.prototype.CLICK =533WebElement.prototype.Click = function() {534 var api = '/click';535 var body = {};536 this.request.Post(api, body);537};538WebElement.prototype.clear =539WebElement.prototype.CLEAR =540WebElement.prototype.Clear = function() {541 var api = '/clear';542 var body = {};543 this.request.Post(api, body);544};545WebElement.prototype.set_value =546WebElement.prototype.setValue =547WebElement.prototype.setvalue =548WebElement.prototype.SETVALUE =549WebElement.prototype.SetValue = function(value) {550 var api = '/value';551 var str = '' + value552 var body = {553 text: str,554 value: str.split('')555 };556 this.request.Post(api, body);557};558WebElement.prototype.get_value =559WebElement.prototype.getValue =560WebElement.prototype.getvalue =561WebElement.prototype.GETVALUE =562WebElement.prototype.GetValue = function() {563 return this.GetProperty('value');564};565WebElement.prototype.get_text =566WebElement.prototype.getText =567WebElement.prototype.gettext =568WebElement.prototype.GETTEXT =569WebElement.prototype.GetText = function() {570 var api = '/text';571 var r = this.request.Get(api);572 if (r)573 return r.value;574};575WebElement.prototype.get_attribute =576WebElement.prototype.getAttribute =577WebElement.prototype.getattribute =578WebElement.prototype.GETATTRIBUTE =579WebElement.prototype.GetAttribute = function(attribute) {580 var api = '/attribute/' + attribute;581 var r = this.request.Get(api);582 if (r.value)583 return r.value;584};585WebElement.prototype.get_property =586WebElement.prototype.getProperty =587WebElement.prototype.getproperty =588WebElement.prototype.GETPROPERTY =589WebElement.prototype.GetProperty = function(property) {590 var api = '/property/' + property;591 var r = this.request.Get(api);592 if (r.value)593 return r.value;594};595WebElement.prototype.is_selected =596WebElement.prototype.isSelected =597WebElement.prototype.isselected =598WebElement.prototype.ISSELECTED =599WebElement.prototype.IsSelected = function() {600 var api = '/selected';601 var r = this.request.Get(api);602 if (r)603 return r.value;604};605WebElement.prototype.find_single_elem = function(body) {606 var api = '/element';607 var r = this.request.Post(api, body);608 var eid, element;609 if (r.value.ELEMENT) {610 eid = r.value.ELEMENT;611 } else {612 for (var key in r.value) {613 if (key.match(/element/)) {614 eid = r.value[key];615 break;616 }617 }618 }619 if (eid) {620 element = new WebElement(this.driverapibase, eid, r.value);621 }622 return element;623};624WebElement.prototype.find_multi_elem = function(body) {625 var api = '/elements';626 var r = this.request.Post(api, body);627 if (! r && r.status != 0)628 return null;629 var dictionary = new ActiveXObject("Scripting.Dictionary");630 for (var i = 0; i < r.value.length; i++) {631 var eid;632 if (r.value[i].ELEMENT) {633 eid = r.value[i].ELEMENT;634 } else {635 for (var key in r.value[i]) {636 if (key.match(/element/)) {637 eid = r.value[i][key];638 break639 }640 }641 }642 var element = new WebElement(this.driverapibase, eid, r.value[i]);643 dictionary.add(i, element);644 }645 return dictionary.Items();646};647WebElement.prototype.find_element =648WebElement.prototype.findElement =649WebElement.prototype.findelement =650WebElement.prototype.FINDELEMENT =651WebElement.prototype.FindElement = function(selector) {652 var body = {653 "using": "css selector",654 "value": selector655 };656 return this.find_single_elem(body);657};658WebElement.prototype.find_elements =659WebElement.prototype.findElements =660WebElement.prototype.findelements =661WebElement.prototype.FINDELEMENTS =662WebElement.prototype.FindElements = function(selector) {663 var body = {664 "using": "css selector",665 "value": selector666 };667 return this.find_multi_elem(body);668};669WebElement.prototype.find_element_by_x_path =670WebElement.prototype.findElementByXPath =671WebElement.prototype.findelementbyxpath =672WebElement.prototype.FINDELEMENTBYXPATH =673WebElement.prototype.FindElementByXPath = function(xpath) {674 var body = {675 "using": "xpath",676 "value": xpath677 };678 return this.find_single_elem(body);679};680WebElement.prototype.find_elements_by_x_path =681WebElement.prototype.findElementsByXPath =682WebElement.prototype.findelementsbyxpath =683WebElement.prototype.FINDELEMENTSBYXPATH =684WebElement.prototype.FindElementsByXPath = function(xpath) {685 var body = {686 "using": "xpath",687 "value": xpath688 };689 return this.find_multi_elem(body);690};691WebElement.prototype.save_screenshot =692WebElement.prototype.saveScreenshot =693WebElement.prototype.savescreenshot =694WebElement.prototype.SAVESCREENSHOT =695WebElement.prototype.SaveScreenshot = function(path) {696 var api = '/screenshot'697 var r = this.request.Get(api);698 WebDriver._saveScreenshot(r.value, path);699};700WebElement.prototype.execute_script =701WebElement.prototype.executeScript =702WebElement.prototype.executescript =703WebElement.prototype.EXECUTESCRIPT =704WebElement.prototype.ExecuteScript = function(js, args) {705 if (! args) {706 args = [this.raw()];707 } else {708 args.push(this.raw());709 }710 var i = args.length - 1;711 js = 'const $0 = arguments[' + i + '];' + js;712 return WebDriver.ExecuteScript(this.driverapibase, js, args)713};714var WebDriverOption = function(template, browseroption) {715 this.option = JSON.parse(template);716 this.name = browseroption;717 this.args = null718};719WebDriverOption.New = function(template, browseroption) {720 var opt = new WebDriverOption(template, browseroption);721 opt.args = 722 opt.ARGS = 723 opt.Args = new WebDriverOptionArgs(opt.option.capabilities.alwaysMatch[opt.name].args);724 return opt;725};726WebDriverOption.prototype.toCapabilities = function() {727 return JSON.stringify(this.option);728};729var WebDriverOptionArgs = function(args) {730 this.args = args731};732WebDriverOptionArgs.prototype.add =733WebDriverOptionArgs.prototype.ADD =734WebDriverOptionArgs.prototype.Add = function(arg) {735 this.args.push(arg);736 return this.args.length;737};738WebDriverOptionArgs.prototype.remove =739WebDriverOptionArgs.prototype.REMOVE =740WebDriverOptionArgs.prototype.Remove = function(arg) {741 var remove = -1;742 for (i = 1; i < this.args.length; i++) {743 if (this.args[i] == arg) {744 remove = i;745 break;746 }747 }748 this.args.splice(remove, 1);749 return this.args.length;...

Full Screen

Full Screen

general-specs.js

Source:general-specs.js Github

copy

Full Screen

...138 });139 describe('getLog', () => {140 it('should get log types', async () => {141 sandbox.stub(driver.adb, 'getLogcatLogs').returns('logs');142 await driver.getLog('logcat').should.be.equal('logs');143 });144 it('should throws exception if log type is unsupported', async () => {145 expect(() => driver.getLog('unsupported_type'))146 .to.throw('Unsupported log type unsupported_type');147 });148 });149 describe('isAppInstalled', () => {150 it('should return true if app is installed', async () => {151 sandbox.stub(driver.adb, 'isAppInstalled').withArgs('pkg').returns(true);152 await driver.isAppInstalled('pkg').should.be.true;153 });154 });155 describe('removeApp', () => {156 it('should remove app', async () => {157 sandbox.stub(driver.adb, 'uninstallApk').withArgs('pkg').returns(true);158 await driver.removeApp('pkg').should.be.true;159 });...

Full Screen

Full Screen

basic-specs.js

Source:basic-specs.js Github

copy

Full Screen

...253 before(async function () { return await loadWebView(specialCaps, driver); });254 it('should be able to get the performance logs', async function () {255 let logTypes = await driver.getLogTypes();256 logTypes.should.include('performance');257 let logs = await driver.getLog('performance');258 logs.should.be.an.instanceof(Array);259 logs.length.should.be.above(0);260 });261 });...

Full Screen

Full Screen

calc-app-2-specs.js

Source:calc-app-2-specs.js Github

copy

Full Screen

...42 await driver.implicitWait(4000);43 await B.resolve(driver.findElement('accessibility id', 'SumLabelz'))44 .catch(throwMatchableError)45 .should.be.rejectedWith(/jsonwpCode: 7/);46 let logs = await driver.getLog();47 logs.length.should.be.above(0);48 logs[0].message.should.not.include('\n');49 logs[0].level.should.equal('ALL');50 logs[0].timestamp.should.exist;51 });52 it('should be able to get crashlog logs @skip-ci', async function () {53 let dir = path.resolve(process.env.HOME, 'Library', 'Logs', 'DiagnosticReports');54 let msg = 'boom';55 let logs = await driver.getLog('crashlog');56 await fs.writeFile(`${dir}/myApp_${Date.parse(new Date())}_rocksauce.crash`, msg);57 logs = await driver.getLog('crashlog');58 logs.length.should.equal(1);59 _.last(logs).message.should.not.include('\n');60 _.last(logs).message.should.equal(msg);61 _.last(logs).level.should.equal('ALL');62 _.last(logs).timestamp.should.exist;63 logs = await driver.getLog('crashlog');64 logs.length.should.equal(0);65 });...

Full Screen

Full Screen

driver.js

Source:driver.js Github

copy

Full Screen

...77 });78 });79 if (helpers.browserName != 'internet explorer') {80 it('get log', function(done) {81 driver.getLog('browser', function(err, log) {82 if (err) return done(err);83 expect(log).to.be.an('array');84 done();85 });86 });87 }88 it('delete session', function(done) {89 driver.deleteSession(helpers.expectForDriverAndDone(done));90 });91 after(helpers.stopStaticServer);...

Full Screen

Full Screen

logging-e2e-specs.js

Source:logging-e2e-specs.js Github

copy

Full Screen

...25 };26 caps = _.merge({}, env.CAPS, caps);27 describe('errors', function () {28 it('should throw an error when an invalid type is given', async function () {29 await driver.getLog('something-random').should.eventually.be.rejected;30 });31 it('should throw an error when driver is not started', async function () {32 await driver.getLog('syslog').should.eventually.be.rejected;33 });34 });35 describe('success', function () {36 before(async function () {37 // TODO: figure out why this is so flakey in Travis38 if (process.env.TRAVIS) this.skip(); // eslint-disable-line curly39 await driver.createSession(caps);40 });41 after(async function () {42 await driver.deleteSession();43 });44 it('should get system logs', async function () {45 (await driver.getLog('syslog')).should.be.an.instanceof(Array);46 });47 it('should get crash logs', async function () {48 (await driver.getLog('crashlog')).should.be.an.instanceof(Array);49 });50 });51 });...

Full Screen

Full Screen

smoke-tests.js

Source:smoke-tests.js Github

copy

Full Screen

1const nsAppium = require("nativescript-dev-appium");2const assert = require("chai").assert;3describe("smoke tests", async function () {4 let driver;5 before(async function () {6 nsAppium.nsCapabilities.testReporter.context = this;7 driver = await nsAppium.createDriver();8 });9 after(async function () {10 await driver.quit();11 console.log("Quit driver!");12 });13 afterEach(async function () {14 if (this.currentTest.state === "failed") {15 await driver.logTestArtifacts(this.currentTest.title);16 }17 });18 it("assert console log", async function () {19 const btnTap = await driver.findElementByClassName(driver.locators.button);20 assert.isTrue(await btnTap.isDisplayed(), "App is not running");21 await btnTap.tap();22 await driver.sleep(2000);23 const logs = await driver.getlog("logcat");24 let containsJobExecutions = false;25 let containsJobScheduled = false;26 logs.forEach(log => {27 if (/Job Scheduled: 1/mig.test(log.message)) {28 containsJobScheduled = true;29 }30 if (/Job Execution/igm.test(log.message)) {31 containsJobExecutions = true;32 }33 });34 assert.isTrue(containsJobScheduled, "Not found: Job Scheduled: 1");35 assert.isTrue(containsJobExecutions, "Not found: Job execution");36 });...

Full Screen

Full Screen

logging-specs.js

Source:logging-specs.js Github

copy

Full Screen

1import IosDriver from '../../..';2import chai from 'chai';3import _ from 'lodash';4chai.should();5describe('logging -', function () {6 let driver;7 before(function () {8 driver = new IosDriver();9 });10 describe('getLogTypes', function () {11 it('should respond to the command', function () {12 driver.getLogTypes.should.an.instanceof(Function);13 });14 it('should get the list of available logs', async function () {15 const types = await driver.getLogTypes();16 _.xor(['syslog', 'crashlog', 'performance', 'server'], types).should.eql([]);17 });18 });19 describe('getLog', function () {20 it('should respond to the command', function () {21 driver.getLog.should.be.an.instanceof(Function);22 });23 // unit tests of getLog are in `appium-base-driver`24 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .getLog('logcat', function(err, logEntriesArray) {9 console.log(logEntriesArray);10 })11 .end();12var webdriverio = require('webdriverio');13var options = {14 desiredCapabilities: {15 }16};17 .remote(options)18 .init()19 .getLogTypes(function(err, logTypes) {20 console.log(logTypes);21 })22 .end();23var webdriverio = require('webdriverio');24var options = {25 desiredCapabilities: {26 }27};28 .remote(options)29 .init()30 .getNetworkConnection(function(err, connection) {31 console.log(connection);32 })33 .end();34var webdriverio = require('webdriverio');35var options = {36 desiredCapabilities: {37 }38};39 .remote(options)40 .init()41 .getOrientation(function(err, orientation) {42 console.log(orientation);43 })44 .end();45var webdriverio = require('webdriverio');46var options = {47 desiredCapabilities: {48 }49};50 .remote(options)51 .init()52 .getPerformanceData('com.android.chrome', 'memoryinfo', function(err, data) {53 console.log(data);54 })55 .end();56var webdriverio = require('webdriverio');57var options = {58 desiredCapabilities: {

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver'),2 chrome = require('selenium-webdriver/chrome'),3 test = require('selenium-webdriver/testing');4var driver;5test.describe('Appium Android Driver', function() {6 test.before(function() {7 var options = new chrome.Options();8 options.addArguments(['--user-data-dir=/Users/username/Library/Application Support/Google/Chrome']);9 driver = new webdriver.Builder()10 .forBrowser('chrome')11 .setChromeOptions(options)12 .build();13 });14 test.it('should get log', function() {15 driver.manage().logs().get('browser').then(function(logsEntries) {16 console.log(logsEntries);17 });18 });19 test.after(function() {20 driver.quit();21 });22});23var webdriver = require('selenium-webdriver'),24 chrome = require('selenium-webdriver/chrome'),25 test = require('selenium-webdriver/testing');26var driver;27test.describe('Appium Android Driver', function() {28 test.before(function() {29 var options = new chrome.Options();30 options.addArguments(['--user-data-dir=/Users/username/Library/Application Support/Google/Chrome']);31 driver = new webdriver.Builder()32 .forBrowser('chrome')33 .setChromeOptions(options)34 .build();35 });36 test.it('should get logs', function() {37 driver.manage().logs().get('browser').then(function(logsEntries) {38 console.log(logsEntries);39 });40 });41 test.after(function() {42 driver.quit();43 });44});45var webdriver = require('selenium-webdriver'),46 chrome = require('selenium-webdriver/chrome'),47 test = require('selenium-webdriver/testing');48var driver;49test.describe('Appium Android Driver', function() {50 test.before(function() {51 var options = new chrome.Options();52 options.addArguments(['--user-data-dir=/Users/username/Library/Application Support/Google/

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd'),2 path = require('path'),3 assert = require('assert');4var desired = {5 "app": path.resolve(__dirname, "app", "ApiDemos-debug.apk")6};7var driver = wd.promiseChainRemote("

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var android = require('appium-android-driver');3var path = require('path');4var fs = require('fs');5var os = require('os');6var logFile = path.resolve(os.tmpdir(), 'appium.log');7var driver = new android.AndroidDriver();8driver.createSession({

Full Screen

Using AI Code Generation

copy

Full Screen

1const assert = require('assert');2const wdio = require('webdriverio');3const opts = {4 desiredCapabilities: {5 }6};7(async () => {8 const client = await wdio.remote(opts);9 await client.pause(10000);10 const logTypes = await client.getLogTypes();11 console.log('logTypes : ' + logTypes);12 const logs = await client.getLog('logcat');13 console.log('logs : ' + logs);14 await client.deleteSession();15})();16const assert = require('assert');17const wdio = require('webdriverio');18const opts = {19 desiredCapabilities: {

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 Android Driver automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful