Best JavaScript code snippet using webdriverio-monorepo
cross.js
Source:cross.js
1/**2 * Crossbrowser implementation for native browser3 *4 * @param {Object} a5 * @param {Object} fn6 */7var isChrome = (typeof chrome !== "undefined");8var isSafari = (typeof safari !== "undefined");9var options={10 autoparse:true 11}1213var mycore = {14 application:{15 sendRequest: function(a, fn, b){16 if (isChrome) {17 18 }19 else if (isSafari) {20 safari.application.addEventListener(a.message,fn,false);21 }22 }23 24 },25 extension: {26 sendRequest: function(){27 //to bg28 var guid=false, a, fn, l = arguments.length;29 if (l>2){30 guid=arguments[0];31 a=arguments[1];32 fn=arguments[2];33 }else{34 a=arguments[0];35 fn=arguments[1];36 }37 38 if (isChrome) {39 if (guid){40 if (fn) {41 chrome.extension.sendRequest(guid,a, fn);42 }else{43 chrome.extension.sendRequest(guid,a);44 }45 }else{46 if (fn) {47 chrome.extension.sendRequest(a, fn);48 }else{49 chrome.extension.sendRequest(a);50 }51 }52 //chrome.extension.sendRequest(arguments);53 }54 else if (isSafari) {55 safari.self.addEventListener('crossaction', function(e){56 var a = e;57 a.message = a.name;58 delete a.name;59 fn(a);60 }, false);61 safari.self.tab.dispatchMessage('crossaction', a);62 }63 },64 onRequest:{65 addListener: function(fn){66 //from bg67 if (isChrome) {68 chrome.extension.onRequest.addListener(fn);69 }70 else if (isSafari) {71 safari.application.addEventListener('crossaction',fn,false);72 }73 }74 },75 onRequestExternal:{76 addListener: function(fn){77 if (isChrome) {78 chrome.extension.onRequestExternal.addListener(fn);79 }80 else if (isSafari) {81 safari.application.addEventListener('crossaction',fn,false);82 }83 }84 }85 },86 tabs: {87 create:function(options){88 if (isChrome) {89 chrome.tabs.create(options);90 }else if (isSafari) {91 //safari92 }93 },94 get: function(id, fn){95 if (isChrome) {96 chrome.tabs.get(id, fn);97 }else if (isSafari) {98 //safari99 }100 },101 getSelected: function(options, fn){102 if (isChrome) {103 chrome.tabs.getSelected(options, fn);104 }else if (isSafari) {105 //safari106 }107 },108 update: function(id, options, fn){109 if (isChrome) {110 chrome.tabs.update(id, options, fn);111 }else if (isSafari) {112 //safari113 }114 },115 executeScript: function(id, options){116 if (isChrome) {117 chrome.tabs.executeScript(id, options);118 }else if (isSafari) {119 //safari120 }121 },122 onRemoved: {123 addListener: function(fn){124 if (isChrome) {125 chrome.tabs.onRemoved.addListener(fn);126 }127 else if (isSafari) {128 //safari129 }130 }131 }132 },133 windows:{134 getAll: function(options, fn){135 if (isChrome) {136 chrome.windows.getAll(options, fn);137 }else if (isSafari) {138 //safari139 }140 }141 },142 storage: {143 getItem: function(name){144 var v;145 if (isChrome) {146 v= localStorage.getItem(name);147 }148 else if (isSafari) {149 v= localStorage.getItem(name);150 //return safari.extension.settings.getItem(name);151 }152 if (v && typeof v ==='string' && options.autoparse){153 try {154 v = JSON.parse(v);155 }catch(e){156 //157 }158 }159 return v;160 },161 removeItem: function(name){162 if (isChrome) {163 localStorage.removeItem(name);164 }165 else if (isSafari) {166 localStorage.removeItem(name);167 }168 },169 setItem: function(name, value){170 var s = value;171 if (s && options.autoparse && typeof s ==='object'){172 s= JSON.stringify(s);173 }174 if (isChrome) {175 localStorage.setItem(name, s);176 }177 else if (isSafari) {178 localStorage.setItem(name, s);179 }180 },181 key: function(i){182 if (isChrome) {183 return localStorage.key(i);184 }185 else if (isSafari) {186 return localStorage.key(i);187 //return safari.extension.settings.key(i);188 }189 },190 getLength: function(){191 if (isChrome) {192 return localStorage.length;193 }194 else if (isSafari) {195 return localStorage.length;196 //return safari.extension.settings.length;197 }198 },199 clear:function(){200 localStorage.clear();201 }202 },203 getUrl: function(path){204 if (isChrome) {205 return 'chrome-extension://' + mycore.getGUID() + path;206 }207 else if (isSafari) {208 return safari.extension.baseURI;209 //return 'safari-extension://' + mycore.getGUID() + path;210 }211 },212 getGUID: function(){213 if (isChrome) {214 var url = chrome.extension.getURL('bg.html');215 var m = /:\/\/(\w+)/.exec(url);216 return m[1];217 }218 else if (isSafari) {219 //TODO220 var namespace = 'com.pitaso.readerplus';221 var guid = '37PA8NKYKP';222 return namespace + '-' + guid;223 }224 },225 getLocalPath: function(){226 return mycore.getProtocol() + mycore.getGUID();227 },228 getProtocol: function(){229 if (isChrome) {230 return 'chrome-extension://';231 }232 else if (isSafari) {233 return 'safari-extension://';234 }235 }236};
...
browser.js
Source:browser.js
...28 notOk(b.isNetscape(), "isNetscape");29 notOk(b.isFirefox(), "isFirefox");30 notOk(b.isOpera(), "isOpera");31 notOk(b.isSafari(), "isSafari");32 notOk(b.isChrome(), "isChrome");33 notOk(b.isUnknown(), "isUnknown");34 equal(b.platform(), "Computer-platform", "platform");35 equal(b.version(), "8.0.7.623", "version");36 equal(b.fullVersion(), "8.0.7 Version IE 8", "fullVersion");37 equal(b.canRotate (), "", "canRotate");38 });39 test("isNetscape", function() {40 var navigator = {41 userAgent: "Netscape/7.9.1",42 appVersion: "7.9 Netscape",43 platform: "Some-computer"44 },45 b = new browser(navigator);46 notOk(b.isIE(), "isIE");47 ok(b.isNetscape(), "isNetscape");48 notOk(b.isFirefox(), "isFirefox");49 notOk(b.isOpera(), "isOpera");50 notOk(b.isSafari(), "isSafari");51 notOk(b.isChrome(), "isChrome");52 notOk(b.isUnknown(), "isUnknown");53 equal(b.platform(), "Some-computer", "platform");54 equal(b.version(), "7.9.1", "version");55 equal(b.fullVersion(), "7.9 Netscape", "fullVersion");56 equal(b.canRotate(), "", "canRotate");57 });58 test("isFirefox", function() {59 var navigator = {60 userAgent: "Mozilla/8 Firefox/12.0",61 appVersion: "8-12",62 platform: "PLATFORM"63 },64 b = new browser(navigator);65 notOk(b.isIE(), "isIE");66 notOk(b.isNetscape(), "isNetscape");67 ok(b.isFirefox(), "isFirefox");68 notOk(b.isOpera(), "isOpera");69 notOk(b.isSafari(), "isSafari");70 notOk(b.isChrome(), "isChrome");71 notOk(b.isUnknown(), "isUnknown");72 equal(b.platform(), "PLATFORM", "platform");73 equal(b.version(), "12.0", "version");74 equal(b.fullVersion(), "8-12", "fullVersion");75 equal(b.canRotate(), "", "canRotate");76 });77 test("isOpera", function() {78 var navigator = {79 userAgent: "Opera",80 appVersion: "8",81 platform: "go-go"82 },83 b = new browser(navigator);84 notOk(b.isIE(), "isIE");85 notOk(b.isNetscape(), "isNetscape");86 notOk(b.isFirefox(), "isFirefox");87 ok(b.isOpera(), "isOpera");88 notOk(b.isSafari(), "isSafari");89 notOk(b.isChrome(), "isChrome");90 notOk(b.isUnknown(), "isUnknown");91 equal(b.platform(), "go-go", "platform");92 equal(b.version(), "", "version");93 equal(b.fullVersion(), "8", "fullVersion");94 equal(b.canRotate(), "", "canRotate");95 });96 test("isSafari", function() {97 var navigator = {98 userAgent: "Safari/8 Version/12",99 appVersion: "100000 ABCDE",100 platform: "go-go"101 },102 b = new browser(navigator);103 notOk(b.isIE(), "isIE");104 notOk(b.isNetscape(), "isNetscape");105 notOk(b.isFirefox(), "isFirefox");106 notOk(b.isOpera(), "isOpera");107 ok(b.isSafari(), "isSafari");108 notOk(b.isChrome(), "isChrome");109 notOk(b.isUnknown(), "isUnknown");110 equal(b.platform(), "go-go", "platform");111 equal(b.version(), "12", "version");112 equal(b.fullVersion(), "100000 ABCDE", "fullVersion");113 equal(b.canRotate(), "", "canRotate");114 });115 test("isChrome", function() {116 var navigator = {117 userAgent: "Chrome/12.0 Safari/583.7",118 appVersion: "APP-Version",119 platform: "CHROME"120 },121 b = new browser(navigator);122 notOk(b.isIE(), "isIE");123 notOk(b.isNetscape(), "isNetscape");124 notOk(b.isFirefox(), "isFirefox");125 notOk(b.isOpera(), "isOpera");126 notOk(b.isSafari(), "isSafari");127 ok(b.isChrome(), "isChrome");128 notOk(b.isUnknown(), "isUnknown");129 equal(b.platform(), "CHROME", "platform");130 equal(b.version(), "12.0", "version");131 equal(b.fullVersion(), "APP-Version", "fullVersion");132 equal(b.canRotate(), "", "canRotate");133 });134 test("isUnkown", function() {135 var navigator = {136 userAgent: "",137 appVersion: "",138 platform: ""139 },140 b = new browser(navigator);141 notOk(b.isIE(), "isIE");142 notOk(b.isNetscape(), "isNetscape");143 notOk(b.isFirefox(), "isFirefox");144 notOk(b.isOpera(), "isOpera");145 notOk(b.isSafari(), "isSafari");146 notOk(b.isChrome(), "isChrome");147 ok(b.isUnknown(), "isUnknown");148 equal(b.platform(), "", "platform");149 equal(b.version(), "", "version");150 equal(b.fullVersion(), "", "fullVersion");151 equal(b.canRotate(), "", "canRotate");152 });...
shared.js
Source:shared.js
...11}12function isOpera() {13 return/OPR/.test(window.navigator.userAgent)14}15function isChrome() {16 return window.chrome !== undefined && window.chrome.app !== undefined17}18function isChromeOnly() {19 return window.chrome !== undefined && window.chrome.app !== undefined && !isOpera()20}21function getVersionNumber() {22 var e = isSafari() ? safari.extension.displayVersion : chrome.app.getDetails().version;23 if (typeof e != "undefined")return e;24 appSettingsPath = isSafari() ? safari.extension.baseURI + "Info.plist" : chrome.extension.getURL("manifest.json");25 var t = new XMLHttpRequest;26 t.open("GET", appSettingsPath, !1), t.send(null);27 if (isSafari())$("dict > key", t.response).each(function () {28 if ($(this).text() == "CFBundleShortVersionString")return e = $(this).next().text(), !129 }); else {30 var n = JSON.parse(t.responseText);31 e = n.version32 }33 return e34}35function getBackgroundPage() {36 var e = isChrome() ? chrome.extension.getBackgroundPage() : safari.extension.globalPage.contentWindow;37 return e38}39function getCurrentTab(e) {40 if (isChrome())chrome.tabs.getSelected(null, function (t) {41 e(t)42 }); else if (isSafari()) {43 var t = safari.application.activeBrowserWindow.activeTab;44 e(t)45 }46}47function getAllTabs(e) {48 if (isChrome())chrome.tabs.query({}, e); else if (isSafari()) {49 var t = safari.application.browserWindows, n = [];50 for (var r = 0; r < t.length; r++) {51 var i = t[r].tabs;52 for (var s = 0; s < i.length; s++)n.push(i[s])53 }54 e(n)55 } else e([])56}57function executeScriptInTab(e, t) {58 isChrome() ? chrome.tabs.executeScript(e.id, {code: t}) : isSafari() && e.page.dispatchMessage("executeScript", t)59}60function executeScriptInTabWithCallback(e, t, n) {61 isChrome() ? chrome.tabs.executeScript(e.id, {code: t}, n) : isSafari() && (executeScriptInTab(e, t), setTimeout(n, 100))62}63function executeScriptFromURLInTab(e, t) {64 if (isChrome())chrome.tabs.executeScript(e.id, {file: t}); else if (isSafari()) {65 var n = $.ajax({type: "GET", url: "../" + t, async: !1});66 executeScriptInTab(e, n.responseText)67 }68}69function executeScriptFromURLInTabWithCallback(e, t, n) {70 if (isChrome())chrome.tabs.executeScript(e.id, {file: t}, n); else if (isSafari()) {71 var r = $.ajax({type: "GET", url: "../" + t, async: !1});72 executeScriptInTabWithCallback(e, r.responseText, n)73 }74}75function broadcastMessageToAllTabs(e) {76 getAllTabs(function (t) {77 $.each(t, function (t, n) {78 sendMessageToTab(n, e)79 })80 })81}82function injectScript(e) {83 var t = "(" + e + ")();", n = document.createElement("script");84 n.textContent = t, (document.head || document.documentElement).appendChild(n), n.parentNode.removeChild(n)85}86function openTabWithURL(e) {87 if (isChrome())chrome.tabs.create({url: e}); else if (isSafari()) {88 var t = safari.application.activeBrowserWindow.openTab();89 t.url = e90 }91}92function stringFromBool(e) {93 return e === !1 ? "false" : "true"94}95function boolFromString(e) {96 return typeof e == "string" ? e === "false" ? !1 : !0 : e97}98function getSetting(e) {99 return settingContainerForKey(e)[e]100}101function setSetting(e, t) {102 var n = settingContainerForKey(e);103 !t && n == localStorage ? localStorage.removeItem(e) : n[e] = t104}105function settingContainerForKey(e) {106 if (isSafari()) {107 var t;108 return e === "twitter" || e === "hackernews" || e === "reddit" || e === "yahoo" || e === "keyboard-shortcut-add" || e === "linkedin" || e === "keyboard-shortcut" ? t = safari.extension.settings : e == "username" || e == "password" ? t = safari.extension.secureSettings : t = localStorage, t109 }110 return localStorage111}112function addMessageListener(e) {113 if (isChrome())window.chrome.extension.onMessage ? chrome.extension.onMessage.addListener(e) : chrome.extension.onRequest.addListener(e); else if (isSafari()) {114 var t;115 safari.self && safari.self.addEventListener ? t = safari.self : safari.application && safari.application.addEventListener && (t = safari.application), t && t.addEventListener("message", function (t) {116 t.tab = t.target;117 var n;118 if (t.message.__cbId) {119 var r = t.tab, i = t.message.__cbId;120 n = function (e) {121 r && r.page && r.page.dispatchMessage && r.page.dispatchMessage("__performCb", {cbId: i, data: e})122 }, t.__cbId = undefined123 }124 e(t.message, t, n)125 }, !1)126 }127}128function sendMessageToTab(e, t) {129 isChrome() ? chrome.tabs.sendMessage(e.id, t) : isSafari() && e.page.dispatchMessage("message", t)130}131function sendMessage(e, t) {132 t || (t = function (e) {133 }), isChrome() ? chrome.extension.sendMessage ? chrome.extension.sendMessage(e, t) : chrome.extension.sendRequest(e, t) : isSafari() && (t && (e.__cbId = Callbacker.addCb(t)), safari.self.tab.dispatchMessage("message", e))...
sidebar.js
Source:sidebar.js
1/**2 * Shopware 4.03 * Copyright © 2012 shopware AG4 *5 * According to our dual licensing model, this program can be used either6 * under the terms of the GNU Affero General Public License, version 3,7 * or under a proprietary license.8 *9 * The texts of the GNU Affero General Public License with an additional10 * permission and of our proprietary license can be found at and11 * in the LICENSE file you have received along with this program.12 *13 * This program is distributed in the hope that it will be useful,14 * but WITHOUT ANY WARRANTY; without even the implied warranty of15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the16 * GNU Affero General Public License for more details.17 *18 * "Shopware" is a registered trademark of shopware AG.19 * The licensing of the program under the AGPLv3 does not imply a20 * trademark license. Therefore any rights, title and interest in21 * our trademarks remain entirely with us.22 *23 * @category Shopware24 * @package Article25 * @subpackage Detail26 * @copyright Copyright (c) 2012, shopware AG (http://www.shopware.de)27 * @version $Id$28 * @author shopware AG29 */30/**31 * Shopware UI - Article detail page32 * The sidebar component contains the definition of the sidebar layout.33 * The sidebar displays as an accordion. The different sidebar elements34 * defined under the 'Shopware.apps.Article.view.detail.sidebar' namespace:35 */36//{namespace name=backend/article/view/main}37//{block name="backend/article/view/detail/sidebar"}38Ext.define('Shopware.apps.Article.view.detail.Sidebar', {39 /**40 * Define that the billing field set is an extension of the Ext.form.FieldSet41 * @string42 */43 extend:'Ext.panel.Panel',44 /**45 * The Ext.container.Container.layout for the fieldset's immediate child items.46 * @object47 */48 layout: {49 type: 'accordion',50 animate: Ext.isChrome51 },52 /**53 * Enable only collapse animation in chrome.54 * @boolean55 */56 animCollapse: Ext.isChrome,57 collapsible: true,58 collapsed: true,59 title: '{s name=accordion-title}Article-Options{/s}',60 /**61 * Defines the component region62 */63 region: 'east',64 /**65 * List of short aliases for class names. Most useful for defining xtypes for widgets.66 * @string67 */68 alias:'widget.article-sidebar',69 /**70 * Set css class for this component71 * @string72 */73 cls: Ext.baseCSSPrefix + 'article-sidebar',74 /**75 * Sets the container width to a fix value.76 * @integer77 */78 width: 350,79 /**80 * The initComponent template method is an important initialization step for a Component.81 * It is intended to be implemented by each subclass of Ext.Component to provide any needed constructor logic.82 * The initComponent method of the class being created is called first,83 * with each initComponent method up the hierarchy to Ext.Component being called thereafter.84 * This makes it easy to implement and, if needed, override the constructor logic of the Component at any step in the hierarchy.85 * The initComponent method must contain a call to callParent in order to ensure that the parent class' initComponent method is also called.86 *87 * @return void88 */89 initComponent:function () {90 var me = this,91 mainWindow = me.subApp.articleWindow;92 mainWindow.on('storesLoaded', me.onStoresLoaded, me);93 me.callParent(arguments);94 },95 /**96 * Creates the elements for the sidebar container.97 * @return object98 */99 createElements: function() {100 var me = this;101 return [102 {103 xtype: 'article-sidebar-option',104 shopStore: me.shopStore,105 article: me.article,106 animCollapse: Ext.isChrome,107 animate: Ext.isChrome108 }, {109 xtype: 'article-sidebar-link',110 article: me.article,111 animCollapse: Ext.isChrome,112 animate: Ext.isChrome113 },114 {115 xtype: 'article-sidebar-accessory',116 article: me.article,117 gridStore: me.article.getAccessory(),118 animCollapse: Ext.isChrome,119 animate: Ext.isChrome120 },121 {122 xtype: 'article-sidebar-similar',123 article: me.article,124 gridStore: me.article.getSimilar(),125 animCollapse: Ext.isChrome,126 animate: Ext.isChrome127 }128 ];129 },130 onStoresLoaded: function(article, stores) {131 var me = this;132 me.article = article;133 me.shopStore = stores['shops'];134 me.add(me.createElements());135 }136});...
adapter.js
Source:adapter.js
1define(function(require, exports, module){2 3 var adapter = function(){4 this.isFirefox = false;5 this.isChrome = false;6 this.init();7 }8 adapter.prototype = {9 init: function(){10 if(navigator.mozGetUserMedia && window.mozRTCPeerConnection){11 this.isFirefox = true;12 }13 else if(navigator.webkitGetUserMedia && window.webkitRTCPeerConnection){14 this.isChrome = true;15 }16 else{17 alert("请使ç¨Chromeæfirefoxæµè§å¨ï¼");18 }19 },20 RTCPeerConnection : function(stun){21 if(this.isChrome){22 return new window.webkitRTCPeerConnection(stun);23 } 24 else if(this.isFirefox){25 return new window.mozRTCPeerConnection(stun);26 }27 },28 RTCSessionDescription : function (sdp) {29 if(this.isChrome) {30 return new window.RTCSessionDescription(sdp);31 }32 else if(this.isFirefox) {33 return new window.mozRTCSessionDescription(sdp);34 }35 },36 RTCIceCandidate: function (candidate) {37 if(this.isChrome) {38 return new window.RTCIceCandidate(candidate);39 } 40 else if(this.isFirefox) {41 return new window.mozRTCIceCandidate(candidate);42 } 43 },44 getUserMedia : function(constraints, callback, errCallback, context){45 if(this.isChrome){46 return navigator.webkitGetUserMedia.bind(navigator).call(context, constraints, callback, errCallback);47 }48 else if(this.isFirefox){49 return navigator.mozGetUserMedia.bind(navigator).call(context, constraints, callback, errCallback);50 }51 },52 attachToMedia: function(element, stream) {53 if(this.isChrome) {54 if (typeof element.srcObject !== 'undefined') {55 element.srcObject = stream;56 } else if (typeof element.mozSrcObject !== 'undefined') {57 element.mozSrcObject = stream;58 } else if (typeof element.src !== 'undefined') {59 element.src = window.URL.createObjectURL(stream);60 }61 }62 else if(this.isFirefox) {63 element.mozSrcObject = stream;64 element.play();65 }66 },67 detachToMedia: function(element) {68 if(this.isChrome) { 69 element.src = '';70 }71 else if(this.isFirefox) {72 element.mozSrcObject = null;73 }74 },75 requestAnimationFrame: function(loop){76 if(this.isChrome){77 return window.webkitRequestAnimationFrame(loop);78 }79 else if(this.isFirefox){80 return window.mozRequestAnimationFrame(loop);81 }82 },83 cancelAnimationFrame: function(handle){84 if(this.isChrome) {85 return window.webkitCancelAnimationFrame(handle);86 }87 else if(this.isFirefox) {88 return window.mozCancelAnimationFrame(handle);89 }90 }91 }92 module.exports = adapter;...
browser.spec.js
Source:browser.spec.js
...13 expect(typeof Browser.isEdge()).toBe('boolean')14 })15 it('has a function named isChrome that returns a boolean value', () => {16 expect(typeof Browser.isChrome).toBe('function')17 expect(typeof Browser.isChrome()).toBe('boolean')18 })19 describe('isChrome()', () => {20 it('returns true for Google Chrome', () => {21 const stubbedWindow = { chrome: {} }22 expect(Browser.isChrome(stubbedWindow)).toBeTruthy()23 })24 it('returns false for non Google Chrome', () => {25 const stubbedWindow = {}26 expect(Browser.isChrome(stubbedWindow)).toBeFalsy()27 })28 })29 it('has a function named isSafari that returns a boolean value', () => {30 expect(typeof Browser.isSafari).toBe('function')31 expect(typeof Browser.isSafari()).toBe('boolean')32 })...
detect.js
Source:detect.js
1// http://stackoverflow.com/questions/5899783/detect-safari-chrome-ie-firefox-opera-with-user-agent2let detectBrowserResult_ = null;3export default function detectBrowser() {4 if (detectBrowserResult_) {5 return detectBrowserResult_;6 }7 if (typeof navigator !== 'undefined') {8 const isExplorer = navigator.userAgent.indexOf('MSIE') > -1;9 const isFirefox = navigator.userAgent.indexOf('Firefox') > -1;10 const isOpera = navigator.userAgent.toLowerCase().indexOf('op') > -1;11 let isChrome = navigator.userAgent.indexOf('Chrome') > -1;12 let isSafari = navigator.userAgent.indexOf('Safari') > -1;13 if (isChrome && isSafari) {14 isSafari = false;15 }16 if (isChrome && isOpera) {17 isChrome = false;18 }19 detectBrowserResult_ = {20 isExplorer,21 isFirefox,22 isOpera,23 isChrome,24 isSafari,25 };26 return detectBrowserResult_;27 }28 detectBrowserResult_ = {29 isChrome: true,30 isExplorer: false,31 isFirefox: false,32 isOpera: false,33 isSafari: false,34 };35 return detectBrowserResult_;...
isChrome.js
Source:isChrome.js
1import {createIframe, getWindow} from '../util';2import isChrome from 'third/browser/isChrome';3describe('third/browser/isChrome', function() {4 it('isChrome', function () {5 expect(typeof isChrome).toBe('boolean');6 if (window.console && window.console.log) {7 window.console.log('Browser isChrome:' + isChrome);8 }9 });...
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .getTitle().then(function(title) {9 console.log('Title was: ' + title);10 })11 .end();12var webdriverjs = require('webdriverjs');13var client = webdriverjs.remote({14 desiredCapabilities: {15 }16});17 .init()18 .getTitle().then(function(title) {19 console.log('Title was: ' + title);20 })21 .end();22var webdriverio = require('webdriverio');23var options = {24 desiredCapabilities: {25 }26};27 .remote(options)28 .init()29 .getTitle().then(function(title) {30 console.log('Title was: ' + title);31 })32 .end();33var webdriverjs = require('webdriverjs');34var client = webdriverjs.remote({35 desiredCapabilities: {36 }37});38 .init()39 .getTitle().then(function(title) {40 console.log('Title was: ' + title);41 })42 .end();43var webdriverio = require('webdriverio');44var options = {45 desiredCapabilities: {46 }47};48 .remote(options)49 .init()
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .getTitle().then(function(title) {9 console.log('Title was: ' + title);10 })11 .end();12var webdriverio = require('webdriverio');13var options = {14 desiredCapabilities: {15 }16};17 .remote(options)18 .init()19 .getTitle().then(function(title) {20 console.log('Title was: ' + title);21 })22 .end();23 at Object.<anonymous> (/Users/ankit/Desktop/webdriverio/node_modules/nightwatch/lib/runner/cli/clirunner.js:55:15)24 at Module._compile (module.js:460:26)25 at Object.Module._extensions..js (module.js:478:10)26 at Module.load (module.js:355:32)27 at Function.Module._load (module.js:310:12)28 at Module.require (module.js:365:17)29 at require (module.js:384:17)30 at Object.<anonymous> (/Users/ankit/Desktop/webdriverio/node_modules/nightwatch/bin/nightwatch:35:13)31 at Module._compile (module.js:460:26)32 at Object.Module._extensions..js (module.js:478:10)
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .getTitle().then(function(title) {9 console.log('Title was: ' + title);10 })11 .end();
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3var client = webdriverio.remote(options);4 .init()5 .getTitle().then(function(title) {6 console.log('Title was: ' + title);7 })8 .end();9var webdriverio = require('webdriverio');10var options = { desiredCapabilities: { browserName: 'chrome' } };11var client = webdriverio.remote(options);12 .init()13 .isChrome().then(function(isChrome) {14 console.log('Is Chrome: ' + isChrome);15 })16 .end();17var webdriverio = require('webdriverio');18var client = webdriverio.remote();19 .init()20 .isChrome().then(function(isChrome) {21 console.log('Is Chrome: ' + isChrome);22 })23 .end();
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3var client = webdriverio.remote(options);4 console.log('Title was: ' + title);5}).end();6var webdriverio = require('webdriverio');7var options = { desiredCapabilities: { browserName: 'chrome' } };8var client = webdriverio.remote(options);9.init()10.getTitle().then(function(title) {11 console.log('Title was: ' + title);12})13.end();14var webdriverio = require('webdriverio');15var options = { desiredCapabilities: { browserName: 'chrome' } };16var client = webdriverio.remote(options);17.init()18.getTitle().then(function(title) {19 console.log('Title was: ' + title);20})21.end();22var webdriverio = require('webdriverio');23var options = { desiredCapabilities: { browserName: 'chrome' } };24var client = webdriverio.remote(options);25.init()26.getTitle().then(function(title) {27 console.log('Title was: ' + title);28})29.end();
Using AI Code Generation
1const isChrome = browser.capabilities.browserName === 'chrome';2const isFirefox = browser.capabilities.browserName === 'firefox';3const isSafari = browser.capabilities.browserName === 'safari';4const isIE = browser.capabilities.browserName === 'internet explorer';5const isEdge = browser.capabilities.browserName === 'MicrosoftEdge';6if (isChrome) {7}8if (isFirefox) {9}10if (isSafari) {11}12if (isIE) {13}14if (isEdge) {15}16if (isChrome) {17} else if (isFirefox) {18} else if (isSafari) {19} else if (isIE) {20} else if (isEdge) {21}22switch (browser.capabilities.browserName) {23 break;24 break;25 break;26 break;27 break;28}29const browserName = browser.capabilities.browserName;30const isChrome = browserName === 'chrome';31const isFirefox = browserName === 'firefox';32const isSafari = browserName === 'safari';33const isIE = browserName === 'internet explorer';34const isEdge = browserName === 'MicrosoftEdge';35const browserName = browser.capabilities.browserName;36const isChrome = browserName === 'chrome';
Using AI Code Generation
1const { remote } = require('webdriverio');2(async () => {3 const browser = await remote({4 capabilities: {5 }6 })7 console.log(await browser.isChrome())8 await browser.deleteSession()9})().catch((e) => console.error(e))10exports.config = {11 capabilities: [{12 'goog:chromeOptions': {13 },14 }],15 mochaOpts: {16 },17}18isChrome()19const { remote } = require('webdriverio');20(async () => {21 const browser = await remote({22 capabilities: {23 }24 })25 console.log(await browser.isChrome())26 await browser.deleteSession()27})().catch((e) => console.error(e))
Using AI Code Generation
1browser.isChrome();2browser.isChromium();3browser.isEdge();4browser.isFirefox();5browser.isSafari();6browser.isAndroid();7browser.isIOS();8browser.isMobile();9browser.isMobileWeb();10browser.isAndroidChrome();11browser.isAndroidFirefox();12browser.isIOSChrome();13browser.isIOSFirefox();14browser.isIOSWebview();15browser.isSauce();16browser.isSauceLabs();17browser.isSauceService();18browser.isTestingBot();19browser.isBrowserStack();20browser.isLambdaTest();21browser.isCrossBrowserTesting();22browser.isHeadSpin();23browser.isPerfecto();24browser.isBrowserstackLocal();25browser.isSauceConnect();26browser.isMobileNative();
Using AI Code Generation
1const isChrome = require('is-chrome');2if (isChrome) {3 console.log('is chrome');4} else {5 console.log('is not chrome');6}7const isChrome = require('is-chrome');8if (isChrome) {9 console.log('is chrome');10} else {11 console.log('is not chrome');12}13const isChrome = require('is-chrome');14if (isChrome) {15 console.log('is chrome');16} else {17 console.log('is not chrome');18}19const isChrome = require('is-chrome');20if (isChrome) {21 console.log('is chrome');22} else {23 console.log('is not chrome');24}25const isChrome = require('is-chrome');26if (isChrome) {27 console.log('is chrome');28} else {29 console.log('is not chrome');30}31const isChrome = require('is-chrome');32if (isChrome) {33 console.log('is chrome');34} else {35 console.log('is not chrome');36}37const isChrome = require('is-chrome');38if (isChrome) {39 console.log('is chrome');40} else {41 console.log('is not chrome');42}43const isChrome = require('is-chrome');44if (isChrome) {45 console.log('is chrome');46} else {47 console.log('is not chrome');48}49const isChrome = require('is-chrome');50if (isChrome) {51 console.log('is chrome');52} else {53 console.log('is not chrome');54}
Wondering what could be a next-gen browser and mobile test automation framework that is also simple and concise? Yes, that’s right, it's WebdriverIO. Since the setup is very easy to follow compared to Selenium testing configuration, you can configure the features manually thereby being the center of attraction for automation testing. Therefore the testers adopt WedriverIO to fulfill their needs of browser testing.
Learn to run automation testing with WebdriverIO tutorial. Go from a beginner to a professional automation test expert with LambdaTest WebdriverIO tutorial.
Running Your First Automation Script - Learn the steps involved to execute your first Test Automation Script using WebdriverIO since the setup is very easy to follow and the features can be configured manually.
Selenium Automation With WebdriverIO - Read more about automation testing with WebdriverIO and how it supports both browsers and mobile devices.
Browser Commands For Selenium Testing - Understand more about the barriers faced while working on your Selenium Automation Scripts in WebdriverIO, the ‘browser’ object and how to use them?
Handling Alerts & Overlay In Selenium - Learn different types of alerts faced during automation, how to handle these alerts and pops and also overlay modal in WebdriverIO.
How To Use Selenium Locators? - Understand how Webdriver uses selenium locators in a most unique way since having to choose web elements very carefully for script execution is very important to get stable test results.
Deep Selectors In Selenium WebdriverIO - The most popular automation testing framework that is extensively adopted by all the testers at a global level is WebdriverIO. Learn how you can use Deep Selectors in Selenium WebdriverIO.
Handling Dropdown In Selenium - Learn more about handling dropdowns and how it's important while performing automated browser testing.
Automated Monkey Testing with Selenium & WebdriverIO - Understand how you can leverage the amazing quality of WebdriverIO along with selenium framework to automate monkey testing of your website or web applications.
JavaScript Testing with Selenium and WebdriverIO - Speed up your Javascript testing with Selenium and WebdriverIO.
Cross Browser Testing With WebdriverIO - Learn more with this step-by-step tutorial about WebdriverIO framework and how cross-browser testing is done with WebdriverIO.
Get 100 minutes of automation test minutes FREE!!