How to use agent method in Best

Best JavaScript code snippet using best

browser_test.js

Source:browser_test.js Github

copy

Full Screen

1// Copyright 2013 The Closure Library Authors. All Rights Reserved.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS-IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14/**15 * @fileoverview Unit tests for goog.labs.userAgent.browser.16 */17goog.provide('goog.labs.userAgent.browserTest');18goog.require('goog.labs.userAgent.browser');19goog.require('goog.labs.userAgent.testAgents');20goog.require('goog.labs.userAgent.util');21goog.require('goog.testing.jsunit');22goog.setTestOnly('goog.labs.userAgent.browserTest');23function setUp() {24 goog.labs.userAgent.util.setUserAgent(null);25}26function testOpera10() {27 goog.labs.userAgent.util.setUserAgent(28 goog.labs.userAgent.testAgents.OPERA_10);29 assertTrue(goog.labs.userAgent.browser.isOpera());30 assertVersion('10.00');31 assertVersionBetween('10.00', '10.10');32}33function testOperaMac() {34 goog.labs.userAgent.util.setUserAgent(35 goog.labs.userAgent.testAgents.OPERA_MAC);36 assertTrue(goog.labs.userAgent.browser.isOpera());37 assertVersion('11.52');38 assertVersionBetween('11.50', '12.00');39}40function testOperaLinux() {41 goog.labs.userAgent.util.setUserAgent(42 goog.labs.userAgent.testAgents.OPERA_LINUX);43 assertTrue(goog.labs.userAgent.browser.isOpera());44 assertVersion('11.50');45 assertVersionBetween('11.00', '12.00');46}47function testOpera15() {48 goog.labs.userAgent.util.setUserAgent(49 goog.labs.userAgent.testAgents.OPERA_15);50 assertTrue(goog.labs.userAgent.browser.isOpera());51 assertVersion('15.0.1147.100');52 assertVersionBetween('15.00', '16.00');53}54function testIE6() {55 goog.labs.userAgent.util.setUserAgent(goog.labs.userAgent.testAgents.IE_6);56 assertTrue(goog.labs.userAgent.browser.isIE());57 assertVersion('6.0');58 assertVersionBetween('5.0', '7.0');59}60function testIE7() {61 goog.labs.userAgent.util.setUserAgent(goog.labs.userAgent.testAgents.IE_7);62 assertTrue(goog.labs.userAgent.browser.isIE());63 assertVersion('7.0');64}65function testIE8() {66 goog.labs.userAgent.util.setUserAgent(goog.labs.userAgent.testAgents.IE_8);67 assertTrue(goog.labs.userAgent.browser.isIE());68 assertVersion('8.0');69 assertVersionBetween('7.0', '9.0');70}71function testIE8Compatibility() {72 goog.labs.userAgent.util.setUserAgent(73 goog.labs.userAgent.testAgents.IE_8_COMPATIBILITY);74 assertTrue(goog.labs.userAgent.browser.isIE());75 assertVersion('8.0');76}77function testIE9() {78 goog.labs.userAgent.util.setUserAgent(goog.labs.userAgent.testAgents.IE_9);79 assertTrue(goog.labs.userAgent.browser.isIE());80 assertVersion('9.0');81 assertVersionBetween('8.0', '10.0');82}83function testIE9Compatibility() {84 goog.labs.userAgent.util.setUserAgent(85 goog.labs.userAgent.testAgents.IE_9_COMPATIBILITY);86 assertTrue(goog.labs.userAgent.browser.isIE());87 assertVersion('9.0');88}89function testIE10() {90 goog.labs.userAgent.util.setUserAgent(goog.labs.userAgent.testAgents.IE_10);91 assertTrue(goog.labs.userAgent.browser.isIE());92 assertVersion('10.0');93 assertVersionBetween('10.0', '11.0');94}95function testIE10Compatibility() {96 goog.labs.userAgent.util.setUserAgent(97 goog.labs.userAgent.testAgents.IE_10_COMPATIBILITY);98 assertTrue(goog.labs.userAgent.browser.isIE());99 assertVersion('10.0');100}101function testIE10Mobile() {102 goog.labs.userAgent.util.setUserAgent(103 goog.labs.userAgent.testAgents.IE_10_MOBILE);104 assertTrue(goog.labs.userAgent.browser.isIE());105 assertVersion('10.0');106}107function testIE11() {108 goog.labs.userAgent.util.setUserAgent(goog.labs.userAgent.testAgents.IE_11);109 assertTrue(goog.labs.userAgent.browser.isIE());110 assertVersion('11.0');111 assertVersionBetween('10.0', '12.0');112}113function testIE11CompatibilityMSIE7() {114 goog.labs.userAgent.util.setUserAgent(115 goog.labs.userAgent.testAgents.IE_11_COMPATIBILITY_MSIE_7);116 assertTrue(goog.labs.userAgent.browser.isIE());117 assertVersion('11.0');118}119function testIE11CompatibilityMSIE9() {120 goog.labs.userAgent.util.setUserAgent(121 goog.labs.userAgent.testAgents.IE_11_COMPATIBILITY_MSIE_9);122 assertTrue(goog.labs.userAgent.browser.isIE());123 assertVersion('11.0');124}125function testFirefox19() {126 goog.labs.userAgent.util.setUserAgent(127 goog.labs.userAgent.testAgents.FIREFOX_19);128 assertTrue(goog.labs.userAgent.browser.isFirefox());129 assertVersion('19.0');130 assertVersionBetween('18.0', '20.0');131}132function testFirefoxWindows() {133 goog.labs.userAgent.util.setUserAgent(134 goog.labs.userAgent.testAgents.FIREFOX_WINDOWS);135 assertTrue(goog.labs.userAgent.browser.isFirefox());136 assertVersion('14.0.1');137 assertVersionBetween('14.0', '15.0');138}139function testFirefoxLinux() {140 goog.labs.userAgent.util.setUserAgent(141 goog.labs.userAgent.testAgents.FIREFOX_LINUX);142 assertTrue(goog.labs.userAgent.browser.isFirefox());143 assertVersion('15.0.1');144}145function testChromeAndroid() {146 goog.labs.userAgent.util.setUserAgent(147 goog.labs.userAgent.testAgents.CHROME_ANDROID);148 assertTrue(goog.labs.userAgent.browser.isChrome());149 assertVersion('18.0.1025.133');150 assertVersionBetween('18.0', '19.0');151 assertVersionBetween('17.0', '18.1');152}153function testChromeIphone() {154 goog.labs.userAgent.util.setUserAgent(155 goog.labs.userAgent.testAgents.CHROME_IPHONE);156 assertTrue(goog.labs.userAgent.browser.isChrome());157 assertVersion('22.0.1194.0');158 assertVersionBetween('22.0', '23.0');159 assertVersionBetween('22.0', '22.10');160}161function testChromeMac() {162 goog.labs.userAgent.util.setUserAgent(163 goog.labs.userAgent.testAgents.CHROME_MAC);164 assertTrue(goog.labs.userAgent.browser.isChrome());165 assertVersion('24.0.1309.0');166 assertVersionBetween('24.0', '25.0');167 assertVersionBetween('24.0', '24.10');168}169function testSafariIpad() {170 goog.labs.userAgent.util.setUserAgent(goog.labs.userAgent.testAgents.IPAD_6);171 assertTrue(goog.labs.userAgent.browser.isSafari());172 assertVersion('6.0');173 assertVersionBetween('5.1', '7.0');174}175function testSafari6() {176 goog.labs.userAgent.util.setUserAgent(177 goog.labs.userAgent.testAgents.SAFARI_6);178 assertTrue(goog.labs.userAgent.browser.isSafari());179 assertVersion('6.0');180 assertVersionBetween('6.0', '7.0');181}182function testSafariIphone() {183 goog.labs.userAgent.util.setUserAgent(184 goog.labs.userAgent.testAgents.SAFARI_IPHONE_6);185 assertTrue(goog.labs.userAgent.browser.isSafari());186 assertVersion('6.0');187 assertVersionBetween('5.0', '7.0');188}189function testCoast() {190 goog.labs.userAgent.util.setUserAgent(191 goog.labs.userAgent.testAgents.COAST);192 assertTrue(goog.labs.userAgent.browser.isCoast());193}194function testWebviewIOS() {195 goog.labs.userAgent.util.setUserAgent(196 goog.labs.userAgent.testAgents.WEBVIEW_IPHONE);197 assertTrue(goog.labs.userAgent.browser.isIosWebview());198 goog.labs.userAgent.util.setUserAgent(199 goog.labs.userAgent.testAgents.WEBVIEW_IPAD);200 assertTrue(goog.labs.userAgent.browser.isIosWebview());201}202function testAndroidBrowser235() {203 goog.labs.userAgent.util.setUserAgent(204 goog.labs.userAgent.testAgents.ANDROID_BROWSER_235);205 assertTrue(goog.labs.userAgent.browser.isAndroidBrowser());206 assertVersion('4.0');207 assertVersionBetween('3.0', '5.0');208}209function testAndroidBrowser403() {210 goog.labs.userAgent.util.setUserAgent(211 goog.labs.userAgent.testAgents.ANDROID_BROWSER_403);212 assertTrue(goog.labs.userAgent.browser.isAndroidBrowser());213 assertVersion('4.0');214 assertVersionBetween('3.0', '5.0');215}216function testAndroidBrowser233() {217 goog.labs.userAgent.util.setUserAgent(218 goog.labs.userAgent.testAgents.ANDROID_BROWSER_233);219 assertTrue(goog.labs.userAgent.browser.isAndroidBrowser());220 assertVersion('4.0');221 assertVersionBetween('3.0', '5.0');222}223function testAndroidWebView411() {224 goog.labs.userAgent.util.setUserAgent(225 goog.labs.userAgent.testAgents.ANDROID_WEB_VIEW_4_1_1);226 assertFalse(goog.labs.userAgent.browser.isChrome());227 assertTrue(goog.labs.userAgent.browser.isAndroidBrowser());228 assertVersion('4.0');229 assertVersionBetween('3.0', '5.0');230}231function testAndroidWebView44() {232 goog.labs.userAgent.util.setUserAgent(233 goog.labs.userAgent.testAgents.ANDROID_WEB_VIEW_4_4);234 assertTrue(goog.labs.userAgent.browser.isChrome());235 assertFalse(goog.labs.userAgent.browser.isAndroidBrowser());236 assertVersion('30.0.0.0');237 assertVersionBetween('29.0', '31.0');238}239function testSilk() {240 goog.labs.userAgent.util.setUserAgent(241 goog.labs.userAgent.testAgents.KINDLE_FIRE);242 assertTrue(goog.labs.userAgent.browser.isSilk());243 assertVersion('2.1');244}245function assertVersion(version) {246 assertEquals(version, goog.labs.userAgent.browser.getVersion());247}248function assertVersionBetween(lowVersion, highVersion) {249 assertTrue(goog.labs.userAgent.browser.isVersionOrHigher(lowVersion));250 assertFalse(goog.labs.userAgent.browser.isVersionOrHigher(highVersion));...

Full Screen

Full Screen

keyboard_test.js

Source:keyboard_test.js Github

copy

Full Screen

1// Copyright 2014 The Closure Library Authors. All Rights Reserved.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS-IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14goog.provide('goog.userAgent.keyboardTest');15goog.setTestOnly('goog.userAgent.keyboardTest');16goog.require('goog.labs.userAgent.testAgents');17goog.require('goog.labs.userAgent.util');18goog.require('goog.testing.MockUserAgent');19goog.require('goog.testing.jsunit');20goog.require('goog.userAgent.keyboard');21goog.require('goog.userAgentTestUtil');22var mockAgent;23function setUp() {24 mockAgent = new goog.testing.MockUserAgent();25 mockAgent.install();26}27function tearDown() {28 mockAgent.dispose();29 goog.labs.userAgent.util.setUserAgent(null);30 goog.userAgentTestUtil.reinitializeUserAgent();31}32function testAndroid() {33 mockAgent.setNavigator({platform: 'Linux'});34 setUserAgent(goog.labs.userAgent.testAgents.ANDROID_BROWSER_235);35 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);36 setUserAgent(goog.labs.userAgent.testAgents.ANDROID_BROWSER_221);37 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);38 setUserAgent(goog.labs.userAgent.testAgents.ANDROID_BROWSER_233);39 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);40 setUserAgent(goog.labs.userAgent.testAgents.ANDROID_BROWSER_403);41 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);42 setUserAgent(goog.labs.userAgent.testAgents.ANDROID_BROWSER_403_ALT);43 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);44}45function testIe() {46 mockAgent.setNavigator({platform: 'Windows'});47 setUserAgent(goog.labs.userAgent.testAgents.IE_6);48 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);49 setUserAgent(goog.labs.userAgent.testAgents.IE_7);50 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);51 setUserAgent(goog.labs.userAgent.testAgents.IE_8);52 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);53 setUserAgent(54 goog.labs.userAgent.testAgents.IE_8_COMPATIBILITY);55 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);56 setUserAgent(goog.labs.userAgent.testAgents.IE_9);57 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);58 setUserAgent(goog.labs.userAgent.testAgents.IE_10);59 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);60 setUserAgent(61 goog.labs.userAgent.testAgents.IE_10_COMPATIBILITY);62 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);63 setUserAgent(goog.labs.userAgent.testAgents.IE_11);64 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);65 setUserAgent(66 goog.labs.userAgent.testAgents.IE_11_COMPATIBILITY_MSIE_7);67 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);68 setUserAgent(69 goog.labs.userAgent.testAgents.IE_11_COMPATIBILITY_MSIE_9);70 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);71}72function testFirefoxMac() {73 mockAgent.setNavigator({platform: 'Macintosh'});74 setUserAgent(75 goog.labs.userAgent.testAgents.FIREFOX_MAC);76 assertTrue(goog.userAgent.keyboard.MAC_KEYBOARD);77}78function testFirefoxNotMac() {79 mockAgent.setNavigator({platform: 'X11'});80 setUserAgent(81 goog.labs.userAgent.testAgents.FIREFOX_LINUX);82 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);83 mockAgent.setNavigator({platform: 'Windows'});84 setUserAgent(85 goog.labs.userAgent.testAgents.FIREFOX_WINDOWS);86 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);87}88function testSafari() {89 mockAgent.setNavigator({platform: 'Macintosh'});90 setUserAgent(91 goog.labs.userAgent.testAgents.SAFARI_6);92 assertTrue(goog.userAgent.keyboard.MAC_KEYBOARD);93 setUserAgent(94 goog.labs.userAgent.testAgents.SAFARI_MAC);95 assertTrue(goog.userAgent.keyboard.MAC_KEYBOARD);96 mockAgent.setNavigator({platform: 'iPhone'});97 setUserAgent(98 goog.labs.userAgent.testAgents.SAFARI_IPHONE_32);99 assertTrue(goog.userAgent.keyboard.MAC_KEYBOARD);100 setUserAgent(101 goog.labs.userAgent.testAgents.SAFARI_IPHONE_421);102 assertTrue(goog.userAgent.keyboard.MAC_KEYBOARD);103 setUserAgent(104 goog.labs.userAgent.testAgents.SAFARI_IPHONE_431);105 assertTrue(goog.userAgent.keyboard.MAC_KEYBOARD);106 setUserAgent(107 goog.labs.userAgent.testAgents.SAFARI_IPHONE_6);108 assertTrue(goog.userAgent.keyboard.MAC_KEYBOARD);109 mockAgent.setNavigator({platform: 'iPod'});110 setUserAgent(111 goog.labs.userAgent.testAgents.SAFARI_IPOD);112 assertTrue(goog.userAgent.keyboard.MAC_KEYBOARD);113}114function testSafariWndows() {115 mockAgent.setNavigator({platform: 'Macintosh'});116 setUserAgent(117 goog.labs.userAgent.testAgents.SAFARI_WINDOWS);118 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);119}120function testOperaMac() {121 mockAgent.setNavigator({platform: 'Macintosh'});122 setUserAgent(123 goog.labs.userAgent.testAgents.OPERA_MAC);124 assertTrue(goog.userAgent.keyboard.MAC_KEYBOARD);125}126function testOperaNonMac() {127 mockAgent.setNavigator({platform: 'X11'});128 setUserAgent(129 goog.labs.userAgent.testAgents.OPERA_LINUX);130 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);131 mockAgent.setNavigator({platform: 'Windows'});132 setUserAgent(133 goog.labs.userAgent.testAgents.OPERA_15);134 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);135}136function testIPad() {137 mockAgent.setNavigator({platform: 'iPad'});138 setUserAgent(goog.labs.userAgent.testAgents.IPAD_4);139 assertTrue(goog.userAgent.keyboard.MAC_KEYBOARD);140 setUserAgent(goog.labs.userAgent.testAgents.IPAD_5);141 assertTrue(goog.userAgent.keyboard.MAC_KEYBOARD);142 setUserAgent(goog.labs.userAgent.testAgents.IPAD_6);143 assertTrue(goog.userAgent.keyboard.MAC_KEYBOARD);144}145function testChromeMac() {146 mockAgent.setNavigator({platform: 'Macintosh'});147 setUserAgent(148 goog.labs.userAgent.testAgents.CHROME_MAC);149 assertTrue(goog.userAgent.keyboard.MAC_KEYBOARD);150 mockAgent.setNavigator({platform: 'iPhone'});151 setUserAgent(152 goog.labs.userAgent.testAgents.CHROME_IPHONE);153 assertTrue(goog.userAgent.keyboard.MAC_KEYBOARD);154}155function testChromeNonMac() {156 mockAgent.setNavigator({platform: 'Linux'});157 setUserAgent(158 goog.labs.userAgent.testAgents.CHROME_ANDROID);159 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);160 mockAgent.setNavigator({platform: 'X11'});161 setUserAgent(162 goog.labs.userAgent.testAgents.CHROME_OS);163 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);164 mockAgent.setNavigator({platform: 'X11'});165 setUserAgent(166 goog.labs.userAgent.testAgents.CHROME_LINUX);167 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);168 mockAgent.setNavigator({platform: 'Windows'});169 setUserAgent(170 goog.labs.userAgent.testAgents.CHROME_25);171 assertFalse(goog.userAgent.keyboard.MAC_KEYBOARD);172}173function setUserAgent(ua) {174 mockAgent.setUserAgentString(ua);175 goog.labs.userAgent.util.setUserAgent(ua);176 goog.userAgentTestUtil.reinitializeUserAgent();...

Full Screen

Full Screen

useragenttestutil.js

Source:useragenttestutil.js Github

copy

Full Screen

1// Copyright 2006 The Closure Library Authors. All Rights Reserved.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7// http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS-IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.14/**15 * @fileoverview Shared test function to reset the constants in16 * goog.userAgent.*17 */18goog.provide('goog.userAgentTestUtil');19goog.provide('goog.userAgentTestUtil.UserAgents');20goog.require('goog.labs.userAgent.browser');21goog.require('goog.labs.userAgent.engine');22goog.require('goog.labs.userAgent.platform');23goog.require('goog.userAgent');24goog.require('goog.userAgent.keyboard');25goog.require('goog.userAgent.platform');26goog.require('goog.userAgent.product');27/** @suppress {extraRequire} */28goog.require('goog.userAgent.product.isVersion');29goog.setTestOnly('goog.userAgentTestUtil');30/**31 * Rerun the initialization code to set all of the goog.userAgent constants.32 * @suppress {accessControls}33 */34goog.userAgentTestUtil.reinitializeUserAgent = function() {35 // Unfortunately we can't isolate the useragent setting in a function36 // we can call, because things rely on it compiling to nothing when37 // one of the ASSUME flags is set, and the compiler isn't smart enough38 // to do that when the setting is done inside a function that's inlined.39 goog.userAgent.OPERA = goog.labs.userAgent.browser.isOpera();40 goog.userAgent.IE = goog.labs.userAgent.browser.isIE();41 goog.userAgent.GECKO = goog.labs.userAgent.engine.isGecko();42 goog.userAgent.WEBKIT = goog.labs.userAgent.engine.isWebKit();43 goog.userAgent.MOBILE = goog.userAgent.isMobile_();44 goog.userAgent.SAFARI = goog.userAgent.WEBKIT;45 // Platform in goog.userAgent.46 goog.userAgent.PLATFORM = goog.userAgent.determinePlatform_();47 goog.userAgent.MAC = goog.labs.userAgent.platform.isMacintosh();48 goog.userAgent.WINDOWS = goog.labs.userAgent.platform.isWindows();49 goog.userAgent.LINUX = goog.userAgent.isLegacyLinux_();50 goog.userAgent.X11 = goog.userAgent.isX11_();51 goog.userAgent.ANDROID = goog.labs.userAgent.platform.isAndroid();52 goog.userAgent.IPAD = goog.labs.userAgent.platform.isIpad();53 goog.userAgent.IPHONE = goog.labs.userAgent.platform.isIphone();54 goog.userAgent.VERSION = goog.userAgent.determineVersion_();55 // Platform in goog.userAgent.platform.56 goog.userAgent.platform.VERSION = goog.userAgent.platform.determineVersion_();57 // Update goog.userAgent.product58 goog.userAgent.product.init_();59 goog.userAgent.product.ANDROID = goog.userAgent.product.detectedAndroid_;60 goog.userAgent.product.CAMINO = goog.userAgent.product.detectedCamino_;61 goog.userAgent.product.CHROME = goog.userAgent.product.detectedChrome_;62 goog.userAgent.product.FIREFOX = goog.userAgent.product.detectedFirefox_;63 goog.userAgent.product.IE = goog.userAgent.IE;64 goog.userAgent.product.IPAD = goog.userAgent.product.detectedIpad_;65 goog.userAgent.product.IPHONE = goog.userAgent.product.detectedIphone_;66 goog.userAgent.product.OPERA = goog.userAgent.OPERA;67 goog.userAgent.product.SAFARI = goog.userAgent.product.detectedSafari_;68 goog.userAgent.product.VERSION = goog.userAgent.product.determineVersion_();69 // goog.userAgent.keyboard70 goog.userAgent.keyboard.MAC_KEYBOARD =71 goog.userAgent.keyboard.determineMacKeyboard_();72};73/**74 * Browser definitions.75 * @enum {string}76 */77goog.userAgentTestUtil.UserAgents = {78 GECKO: 'GECKO',79 IE: 'IE',80 OPERA: 'OPERA',81 WEBKIT: 'WEBKIT'82};83/**84 * Return whether a given user agent has been detected.85 * @param {string} agent Value in UserAgents.86 * @return {boolean} Whether the user agent has been detected.87 */88goog.userAgentTestUtil.getUserAgentDetected = function(agent) {89 switch (agent) {90 case goog.userAgentTestUtil.UserAgents.GECKO:91 return goog.userAgent.GECKO;92 case goog.userAgentTestUtil.UserAgents.IE:93 return goog.userAgent.IE;94 case goog.userAgentTestUtil.UserAgents.OPERA:95 return goog.userAgent.OPERA;96 case goog.userAgentTestUtil.UserAgents.WEBKIT:97 return goog.userAgent.WEBKIT;98 }99 throw Error('Unrecognized user agent');...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var agent = require('superagent');2var cheerio = require('cheerio');3var request = require('request');4var fs = require('fs');5var product = [];6agent.get(url)7 .set('User-Agent', 'Mozilla/5.0')8 .end(function(err, res) {9 if (err) {10 console.log(err);11 return;12 }13 var $ = cheerio.load(res.text);14 var items = $('.sku-item');15 items.each(function(i, e) {16 var $e = $(e);17 var $a = $e.find('a');18 var $img = $e.find('img');19 var $price = $e.find('.priceView-hero-price');20 var $title = $e.find('.heading-5');21 var $rating = $e.find('.rating');22 product.push({23 title: $title.text(),24 price: $price.text(),25 img: $img.attr('src'),26 href: $a.attr('href'),27 rating: $rating.attr('aria-label')28 });29 });30 var file = fs.createWriteStream("products.json");31 file.on('error', function(err) {32 console.log(err);33 });34 file.write(JSON.stringify(product, null, 4));35 file.end();36 });37var agent = require('superagent');38var cheerio = require('cheerio');39var request = require('request');40var fs = require('fs');41var product = [];42agent.get(url)

Full Screen

Using AI Code Generation

copy

Full Screen

1var request = require('request');2var fs = require('fs');3var cheerio = require('cheerio');4var async = require('async');5var agent = request.defaults({6 headers: {7 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36'8 }9});10agent(url, function(error, response, body){11 if(!error){12 var $ = cheerio.load(body);13 var item = [];14 $('.large-4').each(function(i, elem){15 item[i] = $(this).text().trim();16 });17 console.log(item);18 }19});20var request = require('request');21var fs = require('fs');22var cheerio = require('cheerio');23var async = require('async');24var agent = request.defaults({25 headers: {26 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36'27 }28});29agent(url, function(error, response, body){30 if(!error){31 var $ = cheerio.load(body);32 var item = [];33 $('.large-4').each(function(i, elem){34 item[i] = $(this).text().trim();35 });36 console.log(item);37 }38});39var request = require('request');40var fs = require('fs');

Full Screen

Using AI Code Generation

copy

Full Screen

1var request = require('request');2var fs = require('fs');3var cheerio = require('cheerio');4var async = require('async');5var mongoose = require('mongoose');6var cheerio = require('cheerio');7var request = require('request');8var async = require('async');9var fs = require('fs');10var json2csv = require('json2csv');11var mongoose = require('mongoose');12var Schema = mongoose.Schema;13var ObjectId = Schema.ObjectId;14var uniqueValidator = require('mongoose-unique-validator');15var db = mongoose.connection;16var db = mongoose.connection;17var mongoose = require('mongoose');18var Schema = mongoose.Schema;19var ObjectId = Schema.ObjectId;20var uniqueValidator = require('mongoose-unique-validator');21var db = mongoose.connection;22var db = mongoose.connection;23var async = require('async');24var fs = require('fs');25var json2csv = require('json2csv');26var request = require('request');27var cheerio = require('cheerio');28var mongoose = require('mongoose');29var Schema = mongoose.Schema;30var ObjectId = Schema.ObjectId;31var uniqueValidator = require('mongoose-unique-validator');32var db = mongoose.connection;33var db = mongoose.connection;34var db = mongoose.connection;35var mongoose = require('mongoose');36var Schema = mongoose.Schema;37var ObjectId = Schema.ObjectId;38var uniqueValidator = require('mongoose-unique-validator');39var db = mongoose.connection;

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestBuy = require('bestbuy');2var bb = new BestBuy('your api key');3bb.products('(search=ipod)', {show: 'sku,name,salePrice', page: 1, pageSize: 10}, function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});

Full Screen

Using AI Code Generation

copy

Full Screen

1var BestBuy = require('bestbuy');2var bestbuy = new BestBuy('your_api_key');3bestbuy.products('(search=ipod)', {show: 'sku,name,salePrice' ,pageSize: 1, page: 1}, function(err, data) {4 console.log(data);5});6var BestBuy = require('bestbuy');7var bestbuy = new BestBuy('your_api_key');8bestbuy.stores('(area(55407,25))', {show: 'storeId,storeType,name,city,distance,phone,region,address,postalCode', pageSize: 1, page: 1}, function(err, data) {9 console.log(data);10});11var BestBuy = require('bestbuy');12var bestbuy = new BestBuy('your_api_key');13bestbuy.stores('(storeId=2747)', {show: 'storeId,storeType,name,city,distance,phone,region,address,postalCode', pageSize: 1, page: 1}, function(err, data) {14 console.log(data);15});16var BestBuy = require('bestbuy');17var bestbuy = new BestBuy('your_api_key');18bestbuy.categories('(id=abcat0502000)', {show: 'id,name,active', pageSize: 1, page: 1}, function(err, data) {19 console.log(data);20});21var BestBuy = require('bestbuy');22var bestbuy = new BestBuy('your_api_key');23bestbuy.categories('(id=abcat0502000)', {show: 'id,name,active', pageSize: 1, page: 1}, function(err, data) {24 console.log(data);25});26var BestBuy = require('bestbuy');27var bestbuy = new BestBuy('your_api_key');28bestbuy.categories('(id=abcat0502000)', {show: 'id,name,active', pageSize: 1, page: 1}, function(err, data) {29 console.log(data);30});

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 Best 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