How to use isFirefox method in Webdriverio

Best JavaScript code snippet using webdriverio-monorepo

browser.js

Source:browser.js Github

copy

Full Screen

...25 },26 b = new browser(navigator);27 ok(b.isIE(), "isIE");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 });...

Full Screen

Full Screen

utils.js

Source:utils.js Github

copy

Full Screen

1const xtn_laptop = 'egphknkmnjfgopfbahecbemahbphomeg'2const extensionId_LocalTesting = 'dnokejphlpljkikgfgmaiojlohadfdgo'3const extensionId_InStore = 'ggdmhmaklbcaeeolnppfehjkkihhnkfe'4const extensionId_Ted = 'blacfijijfejijlceijeoiphcfdimolb'5//const API = chrome6const available_xtn = [xtn_laptop,extensionId_LocalTesting,extensionId_InStore, extensionId_Ted]7let selected_xtn = xtn_laptop8let sessionId = ''9// betterMethod when working for firefox10const betterMethod = true11// this should log to contentscript12function sendMessageExtension (payload) {13 window.postMessage({14 direction: "browser-to-extension",15 message: payload16 }, "*")17 //page will have to listen for results!18}19startMonetization = async (url, paymail) => {20 sessionId = create_UUID()21 const payload = {22 command: "start",23 data:{24 requestId:sessionId,25 paymentPointer:paymail,26 initiatingUrl: url,27 serviceProviderUrl:''28 }29 }30 if (betterMethod) {31 sendMessageExtension(payload)32 } else {33 const response = await API.runtime.sendMessage(34 selected_xtn, payload)35 return response36 }37}38stopMonetization = async () => {39 const payload = {command: "stop"}40 if (betterMethod) {41 sendMessageExtension(payload)42 } else {43 const response = await API.runtime.sendMessage(44 selected_xtn, payload)45 return response46 }47}48progressMonetization = async () => {49 const payload = {command: "progress",50 data:{51 requestId:sessionId,52 }53 }54 if (betterMethod) {55 sendMessageExtension(payload)56 } else {57 const response = await API.runtime.sendMessage(58 selected_xtn, payload)59 return response60 }61}62async function checkExtension () {63 const isFirefox = typeof InstallTrigger !== 'undefined'64 const isChrome = !!window.chrome && (!!window.chrome.webstore || !!window.chrome.runtime)65 // console.log(`firefox ${isFirefox}`)66 // console.log(`chrome ${isChrome}`)67 // available_xtn.forEach(x => {68 const payload = {command: "info"}69 if (betterMethod) {70 console.log(payload)71 sendMessageExtension(payload)72 } else {73 try {74 console.log(`Checking InStore`)75 const xtn = 76 await API.runtime.sendMessage(77 extensionId_InStore, payload)78 if (xtn) selected_xtn = extensionId_InStore79 console.log(xtn)80 return {81 isChrome: isChrome,82 isFirefox: isFirefox,83 extension: xtn84 }85 }86 catch {87 try {88 console.log(`Checking laptop`)89 const xtn = 90 await API.runtime.sendMessage(91 xtn_laptop, {command: "info"})92 if (xtn) selected_xtn = xtn_laptop93 console.log(xtn)94 return {95 isChrome: isChrome,96 isFirefox: isFirefox,97 extension: xtn98 }99 }100 catch {101 try {102 console.log(`Checking Ted`)103 const xtn = 104 await API.runtime.sendMessage(105 extensionId_Ted, {command: "info"})106 if (xtn) selected_xtn = extensionId_Ted107 console.log(xtn)108 return {109 isChrome: isChrome,110 isFirefox: isFirefox,111 extension: xtn112 }113 }114 catch {115 try {116 console.log(`Checking LocalTesting ${extensionId_LocalTesting}`)117 const xtn = 118 await API.runtime.sendMessage(119 extensionId_LocalTesting, {command: "info"})120 if (xtn) selected_xtn = extensionId_LocalTesting121 console.log(xtn)122 return {123 isChrome: isChrome,124 isFirefox: isFirefox,125 extension: xtn126 }127 }128 catch {129 console.error(`No extension found`)130 }131 132 }133 134 }135 136 }137 }138}139async function getExchange() {140 const url = 'https://cash.bitcoinofthings.com/exchange'141 const response = await fetch(url)142 const result = await response.json()143 return result144}145function convertSatoshisToUsd(satoshis, exchange) {146 if (!exchange) return satoshis147 if (!satoshis) return 0148 const dollarsPerBitcoin = exchange.data.rate149 const dollarsPerSatoshi = dollarsPerBitcoin/1e8150 //const centsPerSatoshi = dollarsPerSatoshi*100151 //console.log(centsPerSatoshi)152 //const cents = centsPerSatoshi * satoshis153 const dollars = dollarsPerSatoshi * satoshis154 return dollars155}156create_UUID = () => {157 var dt = new Date().getTime()158 var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {159 var r = (dt + Math.random()*16)%16 | 0160 dt = Math.floor(dt/16)161 return (c=='x' ? r :(r&0x3|0x8)).toString(16)162 })163 return uuid...

Full Screen

Full Screen

landing-page.js

Source:landing-page.js Github

copy

Full Screen

1export default `2<section data-hook="landing-page">3 <header id="main-header" class="responsive-content-wrapper">4 <h1>5 <a href="/" class="wordmark" data-l10n-id="siteName">Firefox Test Pilot</a>6 </h1>7 </header>8 <div class="split-banner responsive-content-wrapper">9 <div class="copter-wrapper fly-up">10 <div class="copter"></div>11 </div>12 <div class="intro-text">13 <h2 class="banner">14 <span data-l10n-id="landingIntroLead" class="block lead-in">Go beyond . . . </span>15 <span data-l10n-id="landingIntroOne" class="block">Test new features.</span>16 <span data-l10n-id="landingIntroTwo" class="block">Give your feedback.</span>17 <span data-l10n-id="landingIntroThree" class="block">Help build Firefox.</span>18 </h2>19 </div>20 </div>21 <div class="centered-banner responsive-content-wrapper">22 {{^isFirefox}}23 <span data-l10n-id="landingDownloadFirefoxDesc" class="parens">(Test Pilot is available for Firefox on Windows, OS X and Linux)</span>24 <a href="https://www.mozilla.org/firefox" class="button primary download-firefox">25 <div class="button-icon">26 <div class="button-icon-badge"></div>27 </div>28 <div class="button-copy">29 <div data-l10n-id="landingDownloadFirefoxTitle" class="button-title">Firefox</div>30 <div data-l10n-id="landingDownloadFirefoxSubTitle" class="button-description">Free Download</div>31 </div>32 </a>33 {{/isFirefox}}34 {{#isFirefox}}35 <button data-hook="install" class="button extra-large primary install">36 <span class="default-btn-msg" data-l10n-id="landingInstallButton">Install the Test Pilot Add-on</span>37 <span class="no-display progress-btn-msg" data-l10n-id="landingInstallingButton">Installing...</span>38 <div class="state-change-inner"></div>39 </button>40 {{/isFirefox}}41 </div>42 {{#isFirefox}}<p data-l10n-id="landingLegalNotice" class="legal-information">By proceeding, you agree to the <a href="/terms">Terms of Use</a> and <a href="/privacy">Privacy Notice</a> of Test Pilot</p>{{/isFirefox}}43 <div class="transparent-container">44 <div class="responsive-content-wrapper delayed-fade-in">45 <h2 class="card-list-header" data-l10n-id="landingExperimentsTitle">Try out the latest experimental features</h2>46 <div data-hook='experiment-list'></div>47 </div>48 </div>49 <div class="responsive-content-wrapper delayed-fade-in">50 <h2 class="card-list-header" data-l10n-id="landingCardListTitle">Get started in 3 easy steps</h2>51 <div id="how-to" class="card-list">52 <div class="card">53 <div class="card-icon add-on-icon large"></div>54 <div class="card-copy large" data-l10n-id="landingCardOne">Get the Test Pilot add-on</div>55 </div>56 <div class="card">57 <div class="card-icon test-pilot-icon large"></div>58 <div class="card-copy large" data-l10n-id="landingCardTwo">Enable experimental features</div>59 </div>60 <div class="card">61 <div class="card-icon chat-icon large"></div>62 <div class="card-copy large" data-l10n-id="landingCardThree">Tell us what you think</div>63 </div>64 </div>65 <div class="centered-banner">66 {{^isFirefox}}67 <span data-l10n-id="landingDownloadFirefoxDesc" class="parens">(Test Pilot is available for Firefox on Windows, OS X and Linux)</span>68 <a href="https://www.mozilla.org/firefox" class="button primary download-firefox">69 <div class="button-icon">70 <div class="button-icon-badge"></div>71 </div>72 <div class="button-copy">73 <div data-l10n-id="landingDownloadFirefoxTitle" class="button-title">Firefox</div>74 <div data-l10n-id="landingDownloadFirefoxSubTitle" class="button-description">Free Download</div>75 </div>76 </a>77 {{/isFirefox}}78 {{#isFirefox}}79 <div class="small-spacer"></div>80 <button data-hook="install" class="button extra-large primary install">81 <span class="default-btn-msg" data-l10n-id="landingInstallButton">Install the Test Pilot Add-on</span>82 <span class="no-display progress-btn-msg" data-l10n-id="landingInstallingButton">Installing...</span>83 <div class="state-change-inner"></div>84 </button>85 {{/isFirefox}}86 </div>87 {{#isFirefox}}<p data-l10n-id="landingLegalNotice" class="legal-information">By proceeding, you agree to the <a href="/terms">Terms of Use</a> and <a href="/privacy">Privacy Notice</a> of Test Pilot</p>{{/isFirefox}}88 </div>89 <footer id="main-footer" class="responsive-content-wrapper">90 <div data-hook="footer-view"></div>91 </footer>92</section>...

Full Screen

Full Screen

browserService.js

Source:browserService.js Github

copy

Full Screen

1import { isFirefox } from './extensionService';2export function getLocalStorage(name) {3 return new Promise((resolve, reject) => {4 if (isFirefox()) {5 browser.storage.local.get([name]).then(6 response => {7 resolve(response);8 },9 error => {10 reject(error);11 },12 );13 } else {14 chrome.storage.local.get(name, value => {15 try {16 resolve(value);17 } catch (error) {18 reject(error);19 }20 });21 }22 });23}24export function setLocalStorage(name, value) {25 return new Promise((resolve, reject) => {26 try {27 if (isFirefox()) {28 browser.storage.local.set({ [name]: value }).then(29 response => {30 if (!response) {31 resolve(1);32 }33 },34 error => {35 throw new Error(error);36 },37 );38 } else {39 chrome.storage.local.set({ [name]: value });40 resolve(1);41 }42 } catch (error) {43 reject(error);44 }45 });46}47export function removeLocalStorage(name) {48 return new Promise((resolve, reject) => {49 try {50 if (isFirefox()) {51 browser.storage.local.remove(name).then(52 response => {53 if (!response) {54 resolve(1);55 }56 },57 error => {58 throw new Error(error);59 },60 );61 } else {62 chrome.storage.local.remove(name);63 resolve(1);64 }65 } catch (error) {66 reject(error);67 }68 });69}70export function removeAllLocalAppStorage(keys) {71 return new Promise((resolve, reject) => {72 try {73 if (isFirefox()) {74 browser.storage.local.remove(keys).then(75 response => {76 if (!response) {77 resolve(1);78 }79 },80 error => {81 throw new Error(error);82 },83 );84 } else {85 chrome.storage.local.remove(keys);86 resolve(1);87 }88 } catch (error) {89 reject(error);90 }91 });92}93export function getBadgeText() {94 return new Promise((resolve, reject) => {95 try {96 if (isFirefox()) {97 browser.browserAction.getBadgeText({}).then(98 text => {99 resolve(text);100 },101 error => {102 throw new Error(error);103 },104 );105 } else {106 chrome.browserAction.getBadgeText({}, result => {107 resolve(result);108 });109 }110 } catch (error) {111 reject(error);112 }113 });114}115export function setBadgeText(txt) {116 return new Promise((resolve, reject) => {117 try {118 if (isFirefox()) {119 browser.browserAction.setBadgeText({ text: txt }).then(120 response => {121 if (!response) {122 resolve(1);123 }124 },125 error => {126 throw new Error(error);127 },128 );129 } else {130 chrome.browserAction.setBadgeText({ text: txt });131 resolve(1);132 }133 } catch (error) {134 reject(error);135 }136 });137}138export function sendMessage(obj) {139 return new Promise((resolve, reject) => {140 try {141 if (isFirefox()) {142 browser.runtime.sendMessage(obj).then(143 response => {144 resolve(response);145 },146 error => {147 reject(error);148 },149 );150 } else {151 chrome.runtime.sendMessage(obj, response => {152 if (response) {153 resolve(response);154 }155 });156 }157 } catch (e) {158 reject(chrome.runtime.lastError);159 }160 });161}162export function createOSNotification(id, message) {163 return new Promise((resolve, reject) => {164 try {165 const obj = {166 type: 'basic',167 iconUrl: 'img/icon-32.png',168 title: 'AIWA',169 message,170 priority: 0,171 };172 if (isFirefox()) {173 browser.notifications.create(id, obj).then(174 response => {175 resolve(response);176 },177 error => {178 reject(error);179 },180 );181 } else {182 chrome.notifications.create(id, obj, id => {183 if (id) {184 resolve(id);185 }186 reject(new Error('Error creating notification'));...

Full Screen

Full Screen

RecordRTCUtils.js

Source:RecordRTCUtils.js Github

copy

Full Screen

1var startRecording = document.getElementById('start-recording');2var stopRecording = document.getElementById('stop-recording');3var cameraPreview = document.getElementById('camera-preview');4var audio = document.querySelector('audio');5var isFirefox = !!navigator.mozGetUserMedia;6var recordAudio, recordVideo;7// function to start recording8startRecording.onclick = function() {9 //disable start recording button10 startRecording.disabled = true;11 //begin showing stream and recording12 navigator.getUserMedia({13 audio: true,14 video: true15 }, function(stream) {16 // show cam17 cameraPreview.src = window.URL.createObjectURL(stream);18 //video.play19 cameraPreview.play();20 // use recordrtc api for stream21 recordAudio = RecordRTC(stream, {22 bufferSize: 1638423 });24 //if not firefox, make a stream for video25 if (!isFirefox) {26 recordVideo = RecordRTC(stream, {27 type: 'video'28 });29 }30 //call the startRecording method on recordrtc31 recordAudio.startRecording();32 // if not firefox, start recording video as well33 if (!isFirefox) {34 recordVideo.startRecording();35 }36 // make the stop recording button clickable37 stopRecording.disabled = false;38 }, function(error) {39 // if error, alert40 alert(JSON.stringify(error));41 });42};43// function to stop recording44stopRecording.onclick = function() {45 // change button enablements 46 startRecording.disabled = false;47 stopRecording.disabled = true;48 // call stop recording on recordaudio49 recordAudio.stopRecording(function() {50 if (isFirefox) onStopRecording();51 });52 //if not firefox, stop recording vid stream as well53 if (!isFirefox) {54 recordVideo.stopRecording();55 onStopRecording();56 }57 // when done, call this func. we grab the data url(s) and post them to the server58 function onStopRecording() {59 recordAudio.getDataURL(function(audioDataURL) {60 if (!isFirefox) {61 recordVideo.getDataURL(function(videoDataURL) {62 postFiles(audioDataURL, videoDataURL);63 });64 } else postFiles(audioDataURL);65 });66 }67};68var fileName;69//called in onStopRecording70function postFiles(audioDataURL, videoDataURL) {71 // set filename to random string72 fileName = getRandomString();73 //initialize files as array74 var files = { };75 //grab info for audio76 files.audio = {77 name: fileName + (isFirefox ? '.webm' : '.wav'),78 type: isFirefox ? 'video/webm' : 'audio/wav',79 contents: audioDataURL80 };81 // if not firefox, grab info for video as well82 if (!isFirefox) {83 files.video = {84 name: fileName + '.webm',85 type: 'video/webm',86 contents: videoDataURL87 };88 }89 //pass in bool for firefox90 files.isFirefox = isFirefox;91 //make cam container blank92 cameraPreview.src = '';93 //show loader instead94 cameraPreview.poster = '/ajax-loader.gif';95 //post to upload route96 xhr('/upload', JSON.stringify(files), function(_fileName) {97 var href = location.href.substr(0, location.href.lastIndexOf('/') + 1);98 cameraPreview.src = href + 'uploads/' + _fileName;99 cameraPreview.play();100 //show link101 var h2 = document.createElement('h2');102 h2.innerHTML = '<a href="' + cameraPreview.src + '">' + cameraPreview.src + '</a>';103 document.body.appendChild(h2);104 });105}106function xhr(url, data, callback) {107 var request = new XMLHttpRequest();108 request.onreadystatechange = function() {109 if (request.readyState == 4 && request.status == 200) {110 callback(request.responseText);111 }112 };113 request.open('POST', url);114 request.send(data);115}116window.onbeforeunload = function() {117 startRecording.disabled = false;118};119function getRandomString() {120 if (window.crypto) {121 var a = window.crypto.getRandomValues(new Uint32Array(3)),122 token = '';123 for (var i = 0, l = a.length; i < l; i++) token += a[i].toString(36);124 return token;125 } else {126 return (Math.random() * new Date().getTime()).toString(36).replace( /\./g , '');127 }...

Full Screen

Full Screen

adapter.js

Source:adapter.js Github

copy

Full Screen

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;...

Full Screen

Full Screen

isFirefox.js

Source:isFirefox.js Github

copy

Full Screen

...6 IOS_2_1_MOBILE_SAFARI_3_1_1_WEBKIT_525_18_1_APPLE_IPHONE_MOBILE7} from '../../test/fixtures/userAgentStrings';8describe('isFirefox', () => {9 it('returns true if the browser is Firefox', () => {10 expect(isFirefox(WINDOWS_7_FIREFOX_15_0A2_GECKO_15_0)).toBe(true);11 expect(isFirefox(MAC_OS_10_5_FIREFOX_3_0_3_GECKO_1_9_0_3)).toBe(true);12 });13 it('returns false if the browser is not Firefox', () => {14 expect(15 isFirefox(IOS_2_1_MOBILE_SAFARI_3_1_1_WEBKIT_525_18_1_APPLE_IPHONE_MOBILE)16 ).toBe(false);17 expect(isFirefox(MAC_OS_10_6_6_SAFARI_5_0_4_WEBKIT_533_20_25)).toBe(false);18 });...

Full Screen

Full Screen

Header.jsx

Source:Header.jsx Github

copy

Full Screen

1import React from 'react';2import styled from 'styled-components';3import HeaderContent from './HeaderContent';4const Div = styled.div`5 flex-shrink: 1;6 overflow: hidden;7 min-height: 100vh;8 display: ${({ isFireFox }) => !isFireFox && 'flex'};9 flex-direction: ${({ isFireFox }) => !isFireFox && 'column'};10 justify-content: ${({ isFireFox }) => !isFireFox && 'center'};11 position: ${({ isFireFox }) => !isFireFox && 'relative'};12`;13function Header() {14 return (15 <Div16 id="header"17 isFireFox={navigator?.userAgent?.indexOf('Firefox') !== -1}>18 <HeaderContent19 isFireFox={navigator?.userAgent?.indexOf('Firefox') !== -1}20 />21 </Div>22 );23}...

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 .getTitle().then(function(title) {9 console.log('Title was: ' + title);10 })11 .end();12webdriverio.remote(options).isFirefox().then(function(isFirefox) {13 console.log('isFirefox: ' + isFirefox);14});15webdriverio.remote(options).isChrome().then(function(isChrome) {16 console.log('isChrome: ' + isChrome);17});18webdriverio.remote(options).isSafari().then(function(isSafari) {19 console.log('isSafari: ' + isSafari);20});21webdriverio.remote(options).isIE().then(function(isIE) {22 console.log('isIE: ' + isIE);23});24webdriverio.remote(options).isMobile().then(function(isMobile) {25 console.log('isMobile: ' + isMobile);26});27webdriverio.remote(options).isPhantomJS().then(function(isPhantomJS) {28 console.log('isPhantomJS: ' + isPhantomJS);29});30webdriverio.remote(options).isAndroid().then(function(isAndroid) {31 console.log('isAndroid: ' + isAndroid);32});33webdriverio.remote(options).isIOS().then(function(isIOS) {34 console.log('isIOS: ' + isIOS);35});36webdriverio.remote(options).isWindowsPhone().then(function(isWindowsPhone) {37 console.log('isWindowsPhone: ' + isWindowsPhone);38});39webdriverio.remote(options).isIPad().then(function(isIPad) {40 console.log('isIPad: ' + isIPad);41});42webdriverio.remote(options).isIPhone().then(function(isIPhone) {

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6var client = webdriverio.remote(options);7 .init()8 .getTitle().then(function(title) {9 console.log('Title was: ' + title);10 })11 .end();12client.isFirefox(function(err, res) {13});14var webdriverio = require('webdriverio');15var options = {16 desiredCapabilities: {17 }18};19var client = webdriverio.remote(options);20 .init()21 .getTitle().then(function(title) {22 console.log('Title was: ' + title);23 })24 .end();25client.isFirefox(function(err, res) {26 if (res.value) {27 .execute(function() {28 return document.title;29 })30 .then(function(result) {31 console.log(result.value);32 });33 }34});35client.isChrome(callback);36var webdriverio = require('webdriverio');37var options = {38 desiredCapabilities: {39 }40};41var client = webdriverio.remote(options);42 .init()43 .getTitle().then(function(title) {44 console.log('Title was: ' + title);45 })46 .end();47client.isChrome(function(err, res) {48});49var webdriverio = require('webdriverio');50var options = {51 desiredCapabilities: {

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6var client = webdriverio.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};17var client = webdriverio.remote(options);18 .init()19 .getTitle().then(function(title) {20 console.log('Title was: ' + title);21 })22 .end();23var webdriverio = require('webdriverio');24var options = {25 desiredCapabilities: {26 }27};28var client = webdriverio.remote(options);29 .init()30 .getTitle().then(function(title) {31 console.log('Title was: ' + title);32 })33 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('webdriver.io page', () => {2 it('should have the right title', () => {3 const title = browser.getTitle();4 expect(title).to.equal('WebdriverIO · Next-gen browser and mobile automation test framework for Node.js');5 browser.pause(3000);6 });7});8describe('webdriver.io page', () => {9 it('should have the right title', () => {10 const title = browser.getTitle();11 expect(title).to.equal('WebdriverIO · Next-gen browser and mobile automation test framework for Node.js');12 if (browser.isFirefox) {13 browser.pause(3000);14 }15 });16});17describe('webdriver.io page', () => {18 it('should have the right title', () => {19 const title = browser.getTitle();20 expect(title).to.equal('WebdriverIO · Next-gen browser and mobile automation test framework for Node.js');21 if (browser.isMobile) {22 browser.pause(3000);23 }24 });25});26describe('webdriver.io page', () => {27 it('should have the right title', () => {28 const title = browser.getTitle();29 expect(title).to.equal('WebdriverIO · Next-gen browser and mobile automation test framework for Node.js');30 if (browser.isSafari) {31 browser.pause(3000);32 }33 });34});35describe('webdriver.io page', () => {36 it('should have the right title', () => {37 const title = browser.getTitle();38 expect(title).to.equal('WebdriverIO · Next-gen browser and mobile automation test framework for Node.js');39 if (browser.isChrome) {40 browser.pause(3000);41 }42 });43});44describe('webdriver.io page', () => {45 it('should have the right title', () => {46 const title = browser.getTitle();47 expect(title).to.equal('WebdriverIO

Full Screen

Using AI Code Generation

copy

Full Screen

1const isFirefox = browser.capabilities.browserName === 'firefox';2const isSafari = browser.capabilities.browserName === 'safari';3const isIE = browser.capabilities.browserName === 'internet explorer';4const isEdge = browser.capabilities.browserName === 'MicrosoftEdge';5const isChrome = browser.capabilities.browserName === 'chrome';6const isMobile = browser.capabilities.browserName === 'chrome' && browser.capabilities['goog:chromeOptions'].mobileEmulation != null;7const isAndroid = browser.capabilities.platformName === 'Android';8const isIOS = browser.capabilities.platformName === 'iOS';9const isAndroidChrome = browser.capabilities.browserName === 'chrome' && browser.capabilities.platformName === 'Android';10const isIOSChrome = browser.capabilities.browserName === 'chrome' && browser.capabilities.platformName === 'iOS';11const isAndroidFirefox = browser.capabilities.browserName === 'firefox' && browser.capabilities.platformName === 'Android';12const isIOSFirefox = browser.capabilities.browserName === 'firefox' && browser.capabilities.platformName === 'iOS';13const isAndroidSafari = browser.capabilities.browserName === 'safari' && browser.capabilities.platformName === 'Android';14const isIOSSafari = browser.capabilities.browserName === 'safari' && browser.capabilities.platformName === 'iOS';15const isAndroidEdge = browser.capabilities.browserName === 'MicrosoftEdge' && browser.capabilities.platformName === 'Android';16const isIOSEdge = browser.capabilities.browserName === 'MicrosoftEdge' && browser.capabilities.platformName === 'iOS';

Full Screen

Using AI Code Generation

copy

Full Screen

1const isFirefox = browser.capabilities.browserName === 'firefox';2const isFirefox = browser.capabilities.browserName === 'firefox';3const isFirefox = browser.capabilities.browserName === 'firefox';4const isFirefox = browser.capabilities.browserName === 'firefox';5const isFirefox = browser.capabilities.browserName === 'firefox';6const isFirefox = browser.capabilities.browserName === 'firefox';7const isFirefox = browser.capabilities.browserName === 'firefox';8const isFirefox = browser.capabilities.browserName === 'firefox';9const isFirefox = browser.capabilities.browserName === 'firefox';10const isFirefox = browser.capabilities.browserName === 'firefox';11const isFirefox = browser.capabilities.browserName === 'firefox';12const isFirefox = browser.capabilities.browserName === 'firefox';

Full Screen

Using AI Code Generation

copy

Full Screen

1if (browser.isFirefox) {2 console.log('This is Firefox');3} else {4 console.log('This is not Firefox');5}6if (browser.isChrome) {7 console.log('This is Chrome');8} else {9 console.log('This is not Chrome');10}11if (browser.isSafari) {12 console.log('This is Safari');13} else {14 console.log('This is not Safari');15}16if (browser.isIE) {17 console.log('This is IE');18} else {19 console.log('This is not IE');20}21if (browser.isEdge) {22 console.log('This is Edge');23} else {24 console.log('This is not Edge');25}26if (browser.isMobile) {27 console.log('This is Mobile');28} else {29 console.log('This is not Mobile');30}31if (browser.isAndroid) {32 console.log('This is Android');33} else {34 console.log('This is not Android');35}36if (browser.isIOS) {37 console.log('This is iOS');38} else {

Full Screen

Using AI Code Generation

copy

Full Screen

1const isFirefox = require('webdriverio/build/lib/utils/isFirefox').default;2if (isFirefox(browser.capabilities)) {3 console.log('This is firefox browser');4}5const isSafari = require('webdriverio/build/lib/utils/isSafari').default;6if (isSafari(browser.capabilities)) {7 console.log('This is safari browser');8}9const isChrome = require('webdriverio/build/lib/utils/isChrome').default;10if (isChrome(browser.capabilities)) {11 console.log('This is chrome browser');12}13const isMobile = require('webdriverio/build/lib/utils/isMobile').default;14if (isMobile(browser.capabilities)) {15 console.log('This is mobile browser');16}17const isMobileIOS = require('webdriverio/build/lib/utils/isMobileIOS').default;18if (isMobileIOS(browser.capabilities)) {19 console.log('This is mobile ios browser');20}21const isMobileAndroid = require('webdriverio/build/lib/utils/isMobileAndroid').default;22if (isMobileAndroid(browser.capabilities)) {23 console.log('This is mobile android browser');24}25const isMobileWebkit = require('webdriverio/build/lib/utils/isMobileWebkit').default;26if (isMobileWebkit(browser.capabilities)) {27 console.log('This is mobile webkit browser');28}29const isMobileChrome = require('webdriverio/build/lib/utils/isMobileChrome').default;30if (isMobileChrome(browser.capabilities)) {31 console.log('This is mobile chrome browser');32}33const isAndroid = require('webdriverio/build/lib/utils/isAndroid').default;34if (isAndroid(browser.capabilities)) {35 console.log('This is android browser');36}37const isIOS = require('webdriverio/build/lib/utils/isIOS').default;38if (isIOS(browser.capabilities)) {39 console.log('This is ios browser');40}

Full Screen

WebdriverIO Tutorial

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.

Chapters

  1. 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.

  2. Selenium Automation With WebdriverIO - Read more about automation testing with WebdriverIO and how it supports both browsers and mobile devices.

  3. 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?

  4. 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.

  5. 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.

  6. 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.

  7. Handling Dropdown In Selenium - Learn more about handling dropdowns and how it's important while performing automated browser testing.

  8. 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.

  9. JavaScript Testing with Selenium and WebdriverIO - Speed up your Javascript testing with Selenium and WebdriverIO.

  10. 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.

Run Webdriverio 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