Best JavaScript code snippet using appium-xcuitest-driver
factorsInputControl.js
Source:factorsInputControl.js
1function getParameter(parameter) {2 var query = window.location.search.substring(1);3 var vars = query.split("&");4 for (var i = 0; i < vars.length; i++) {5 var pair = vars[i].split("=");6 if (pair[0] == parameter) {7 return pair[1];8 }9 }10 return(false);11}1213var startnewControl = {14 15};1617var cocomoData = null;18if(sessionStorage.getItem('cocomoData') != undefined || sessionStorage.getItem('cocomoData') != null){19 cocomoData = JSON.parse(sessionStorage.getItem('cocomoData'));20}2122if(cocomoData == null)23{24 cocomoData = {};25 // setDefaultValues(cocomoData);26 setDefaultValues(cocomoData);27}2829function clickSlider(){30 var slider = $(this);31 var sliderId = slider.attr('id').replace('_ad', '');32 var costDriverId = sliderId+"_active_cost_driver";33 var output = $("#"+sliderId+"_value");34 var activeOutput = $("#"+sliderId+"_ad_value");35 36 $('.active_cost_driver').each(function(index, element){37 var costDriver = $(element);38 if(costDriver.hasClass('shown')){39 costDriver.removeClass('shown');40 costDriver.addClass('hidden');41 }42 43 if(costDriver.attr('id') == costDriverId){44 if(costDriver.hasClass('hidden')){45 costDriver.removeClass('hidden');46 }47 if(!costDriver.hasClass('shown')){48 costDriver.addClass('shown');49 }50 }51 52 });53 54 var value = slider.val();55 var eaf = getCOCOMOValue(sliderId, value, cocomoData);56 $("#"+costDriverId).find('.slider').val(value);57 $("#"+sliderId).val(value);58 output.text(eaf);59 activeOutput.text(eaf);6061 var activeCostDriverFrame = $('#active_cost_driver_frame');62 if( activeCostDriverFrame.css('display') == 'none'){63 activeCostDriverFrame.css('display', 'block');64 }6566 cocomoData[sliderId+"_value"] = eaf;67 68}6970 71function displayRangeValue(range) {72 var columnWidth = $('body').width()*0.0625;7374 var myRange = $('#' + range);757677 var output = $("#"+range+"_value");78 var activeOutput = $("#"+range+"_ad_value");7980 if(myRange === undefined){81 return;82 }8384 var product_type = cocomoData.product_type;8586 // var myValue = $('#' + value);87 myRange.click(clickSlider);8889 var activeRange = $('#'+range+"_ad");90 91 activeRange.click(clickSlider);92 93 var activeDriver = activeRange.closest(".active_cost_driver");94 var rankDescriptions = activeDriver.find(".rank_description_column");9596 // var labelWidth = 135;97 var labelWidth = columnWidth;9899 var labelElement = myRange.parent().siblings(".label");100101 var labelElements = labelElement.children();102 var numberOfLabels = labelElements.length;103 var sliderOffset = labelWidth*5;104105 var activeLabelElement = activeRange.parent().siblings(".label");106 var activeValueLabelElement = activeRange.parent().siblings(".value_label");107 var activeLabelElements = activeLabelElement.children();108 var activeValueLabelElements = activeValueLabelElement.children();109 var minValue = 21;110 var maxValue = 1;111112 var height = -1;113 var tallDescription = numberOfLabels - 1;114 var tallDescriptionLeft = 0;115 116 for(var i = 0; i<numberOfLabels; i++){117 var label = $(labelElements[i]);118 var offset = 0;119 var rankValue = 0;120 if(label.html() == "Very Low"){121 offset = labelWidth*0;122 value = 1;123 }124 else if(label.html() == "Low"){125 offset = labelWidth*1;126 value = 5;127 }128 else if(label.html() == "Nominal"){129 offset = labelWidth*2;130 value = 9;131 }132 else if(label.html() == "High"){133 offset = labelWidth*3;134 value = 13;135 }136 else if(label.html() == "Very High"){137 offset = labelWidth*4;138 value = 17;139 }140 else if(label.html() == "Extra High"){141 offset = labelWidth*5;142 value = 21;143 }144 145 if(offset < sliderOffset){146 sliderOffset = offset;147 }148149 if(value > maxValue){150 maxValue = value;151 }152153 if(value < minValue){154 minValue = value;155 }156 157 $(labelElements[i]).css('left', offset+"px").css('position', 'absolute');158 $(activeLabelElements[i]).css('left', offset+"px").css('position', 'absolute');159 $(activeValueLabelElements[i]).css('left', offset+"px").css('position', 'absolute');160161 var rankDescriptionOffset = -15;162163 $(rankDescriptions[i]).css('left', offset+rankDescriptionOffset+"px").css('position', 'absolute').css('width', labelWidth+"px");164165 if($(rankDescriptions[i]).html().length >= $(rankDescriptions[tallDescription]).html().length){166 tallDescription = i;167 tallDescriptionLeft = offset+rankDescriptionOffset-15;168 }169 170 // if(i == numberOfLabels -1){171 // $(rankDescriptions[i]).css('left', offset+rankDescriptionOffset+"px").css('position', 'relative');172 // }173 // else174 // {175 // $(rankDescriptions[i]).css('left', offset+rankDescriptionOffset+"px").css('position', 'absolute');176 // }177178 }179 180 181 $(rankDescriptions[tallDescription]).css('position', 'relative').css('left', tallDescriptionLeft+'px');182183184 var sliderWidth = (numberOfLabels - 1)*labelWidth;185 var sliderAlignmentLeft = 20;186 myRange.css('width', sliderWidth+"px");187 myRange.css('left', (sliderOffset+sliderAlignmentLeft)+"px").css('position', 'absolute');188 myRange.attr('min', minValue);189 myRange.attr('max', maxValue);190 myRange.attr('step', 1);191192 activeRange.css('width', sliderWidth+"px");193 activeRange.css('left', (sliderOffset+sliderAlignmentLeft)+"px").css('position', 'absolute');194 activeRange.attr('min', minValue);195 activeRange.attr('max', maxValue);196 activeRange.attr('step', 1);197198 setSliderValue(myRange, myRange.attr('id'), cocomoData);199 // myRange.value(cocomoData[myRange.attr('id')+"_slider_value"]);200 setSliderValue(activeRange, activeRange.attr('id').replace(/_ad/g, ''), cocomoData);201 // myRange.value(cocomoData[myRange.attr('id')+"_slider_value"]);202203 var eaf = cocomoData[range+"_value"].toFixed(2);204 output.text(eaf);205 activeOutput.text(eaf);206207208 // var factorName = property.replace('_slider_value', '');209 // var rating = Math.floor((cocomoData[property]-1)/4);210 // var ratingOffset = (cocomoData[property]-1)%4;211 // var ratingRank = "none"212 // var ratingRankNext = "none";213 // if(rating < 1){214 // ratingRank = "_very_low";215 // ratingRankNext = "_low";216 // }217218// myRange.click(clickSlider);219// alert('hello');220// 221//222// // Figure out placement percentage between left and right of input223// var newPoint = (parseInt(myRange.val()) - parseInt(myRange.attr('min'))) / (parseInt(myRange.attr('max')) - parseInt(myRange.attr('min')));224//225// // Measure width of range input226//// var width = myRange.outerWidth();227// myRange.width(sliderWidth);228// myRange.css('left', sliderStartPoint+'px');229//230// // Janky value to get pointer to line up better231// var offset = 18;232//233// // Prevent bubble from going beyond left or right (unsupported browsers)234// var newPlace = 0;235// if (newPoint < 0) { newPlace = 0; }236// else if (newPoint > 1) { newPlace = width; }237// else { newPlace = width * newPoint + offset * (1 - newPoint); }238//239// myValue.parent().css('left', newPlace + 'px');240// myValue.parent().css('top', myRange.outerHeight() + 'px');241// myValue.html(myRange.val());242//243// myRange.on('input', function(){244// var newPoint = (parseInt(myRange.val()) - parseInt(myRange.attr('min'))) / (parseInt(myRange.attr('max')) - parseInt(myRange.attr('min')));245// myValue.html(myRange.val());246//247// var newPlace = 0;248// if (newPoint < 0) { newPlace = 0; }249// else if (newPoint > 1) { newPlace = width; }250// else { newPlace = width * newPoint + offset * (1 - newPoint); }251// myValue.parent().css('left', newPlace + 'px');252// });253}254255//Typical Change Rate for Increment256//Required Software Reliability257//Software Complexity258//Hardware Complexity259//Data Base Size260//Application Experience261//Analyst Capability262//Platform Requirement Volatility263//Supportability264//Reusability265266function render() {267 // displayRangeValue('product_type', 'product_type_value');268 // aler("render");269 // displayRangeValue('typical_change_rate', 'typical_change_rate_value');270 // displayRangeValue('required_software_reliability', 'required_software_reliability_value');271 // displayRangeValue('software_complexity', 'software_complexity_value');272 // displayRangeValue('hardware_complexity', 'hardware_complexity_value');273 // displayRangeValue('data_base_size', 'data_base_size_value');274 // displayRangeValue('application_experience', 'application_experience_value');275 // displayRangeValue('analyst_capability', 'analyst_capability_value');276 // displayRangeValue('platform_requirement_volatility', 'platform_requirement_volatility_value');277 // displayRangeValue('supportability', 'supportability_value');278 // displayRangeValue('reusability', 'reusability_value');279280 displayRangeValue('chng');281 displayRangeValue('rely');282 displayRangeValue('sw_cplx');283 displayRangeValue('hw_cplx');284 displayRangeValue('data');285 displayRangeValue('apex');286 displayRangeValue('acap');287 displayRangeValue('pvol');288 displayRangeValue('supp');289 displayRangeValue('ruse');290 displayRangeValue('pr');291 displayRangeValue('tsl');292 displayRangeValue('aa');293294 var product_type = cocomoData.product_type;295296297 // setSizeSliderValue(myRange, product_type, cocomoData);298299 // console.log(cocomoData['product_type_'+product_type]);300 $('#product_type').parent().find('.default.text').text(cocomoData['product_type_'+product_type]);301 // $('#product_type').dropdown('set selected', cocomoData['product_type_'+product_type]);302 303}304305306var redirectToAgileDevelopment = false;307$(function() {308309310 // Initialize dropdown box311 $('.ui.dropdown').dropdown();312 $('#product_type').change(function() {313 if ($(this).val() == "Web Server") {314 cocomoData.product_type = "web_server"315 // $('#release_cycle').val(5);316 // $('#sw_complexity').val(5);317 // $('#hw_dependency').val(5);318 // $('#avaliable_skills').val(5);319 // $('#quality').val(5);320 // $('#outage_response_time').val(5);321 } else if ($(this).val() == "Mobile/Internet Feature") {322 cocomoData.product_type = "mobile_internet_feature";323 // $('#release_cycle').val(5);324 // $('#sw_complexity').val(5);325 // $('#hw_dependency').val(5);326 // $('#avaliable_skills').val(5);327 // $('#quality').val(5);328 // $('#outage_response_time').val(5);329 redirectToAgileDevelopment = true;330 } else if ($(this).val() == "R&D Tools") {331 cocomoData.product_type = "R_D_tools";332 // $('#release_cycle').val(4);333 // $('#sw_complexity').val(3);334 // $('#hw_dependency').val(1);335 // $('#avaliable_skills').val(8);336 // $('#quality').val(4);337 // $('#outage_response_time').val(3);338 } else if ($(this).val() == "Security kernel; Safety-critical LSI Chip") {339 cocomoData.product_type = "security_kernel";340 // $('#release_cycle').val(5);341 // $('#sw_complexity').val(5);342 // $('#hw_dependency').val(5);343 // $('#avaliable_skills').val(5);344 // $('#quality').val(5);345 // $('#outage_response_time').val(5);346347 } else if ($(this).val() == "Multi-sensor Control Device/Router/Switch") {348349 cocomoData.product_type = "multi_sensor_control_device";350351 } else if ($(this).val() == "Legacy system") {352 353 cocomoData.product_type = "legacy_system";354355 } else if ($(this).val() == "Carrier Class Large Scale SW Intensive; Other Regulated Environments") {356357 cocomoData.product_type = "carrier_class_large_scale";358359 } else if ($(this).val() == "Digital City; Industry Vertical (Oil & Gas)") {360361 cocomoData.product_type = "digital_city";362 363 }364 else if ($(this).val() == "New IOT Product Line") {365366 cocomoData.product_type = "new_IOT_product_line";367368 } else {369 cocomoData.product_type = "default";370 // $('#release_cycle').val(5);371 // $('#sw_complexity').val(5);372 // $('#hw_dependency').val(5);373 // $('#avaliable_skills').val(5);374 // $('#quality').val(5);375 // $('#outage_response_time').val(5);376 } 377 render();378 });379380 // Create choice button381 $('.choice .button').click(function() {382 $(this).addClass('choosed');383 $(this).siblings().removeClass('choosed');384 });385386 // Define the value display on the top of slider387388 render();389390 $( window ).resize(function() {391 render();392 });393394395 function clickNextToProjectSize(){396397 if(redirectToAgileDevelopment){398 window.location.href = 'http://ec2-54-67-99-52.us-west-1.compute.amazonaws.com:8686/demo/phase3/basicWorkflow.html';399 return;400 }401402 // var product_type = $('#product_type').val();403 cocomoData.chng_slider_value = Number($('#chng').val());404405 // var software_complexity = $('#software_complexity').val();406 // var hardware_complexity = $('#hardware_complexity').val();407 // var data_base_size = $('#data_base_size').val();408 // var application_experience = $('#application_experience').val();409 // var analyst_capability = $('#analyst_capability').val();410 // var platform_requirement_volatility = $('#platform_requirement_volatility').val();411 // var supportability = $('#supportability').val();412 // var reusability = $('#reusability').val();413414 //later on translate slider value into cocomo value.415 cocomoData.rely_slider_value = Number($('#rely').val());416 // alert($('#required_software_reliability').html());417 cocomoData.sw_cplx_slider_value = Number($('#sw_cplx').val());418 cocomoData.hw_cplx_slider_value = Number($('#hw_cplx').val());419 cocomoData.data_slider_value = Number($('#data').val());420 cocomoData.apex_slider_value = Number($('#apex').val());421 cocomoData.acap_slider_value = Number($('#acap').val());422 cocomoData.pvol_slider_value = Number($('#pvol').val());423 cocomoData.supp_slider_value = Number($('#supp').val());424 cocomoData.ruse_slider_value = Number($('#ruse').val());425 // cocomoData.product_type = $('#product_type').val();426427 // alert(cocomoData.ruse_slider_value);428 sessionStorage.cocomoData = JSON.stringify(cocomoData);429430 window.location.href = getParameter("instanceId") ? "./projectSizePage.html?instanceId=" + getParameter("instanceId") : "./projectSizePage.html";431 }432433 $('#next_to_project_size').on('click', clickNextToProjectSize);434435436 function clickResetFactor() {437 sessionStorage.cocomoData = null;438 location.reload();439 }440 $('#reset_factor').on('click', clickResetFactor);441442443 function clickExportFactor() {444 let factor_value = {445 RELY : Number($('#rely_value').text()),446 DATA : Number($('#data_value').text()),447 CPLX : (Number($('#sw_cplx_value').text()) + Number($('#hw_cplx_value').text())) / 2,448 RUSE : Number($('#ruse_value').text()),449 PVOL : Number($('#pvol_value').text()),450 ACAP : Number($('#acap_value').text()),451 APEX : Number($('#apex_value').text()),452 AA : Number($('#aa_value').text()),453 PR : Number($('#pr_value').text()),454 TSL : Number($('#tsl_value').text())455 };456457 let rows = [458 ["RELY", "DATA", "CPLX", "RUSE", "PVOL", "ACAP", "APEX", "AA", "PR", "TSL"],459 [factor_value["RELY"], factor_value["DATA"], factor_value["CPLX"], factor_value["RUSE"], factor_value["PVOL"], factor_value["ACAP"], factor_value["APEX"], factor_value["AA"], factor_value["PR"], factor_value["TSL"]]460 ];461462 let csv_content = "data:text/csv;charset=utf-8,";463 rows.forEach(function(row_array){464 let row = row_array.join(",");465 csv_content += row + "\r\n";466 }); 467468 let encoded_uri = encodeURI(csv_content);469 let filename = "ExportFactors" + new Date().getTime() + ".csv";470 471 let link = document.createElement('a');472 link.setAttribute('href', encoded_uri);473 link.setAttribute('download', filename);474 link.click();475 }476 $('#export_factor').on('click', clickExportFactor);477
...
safari-window-e2e-specs.js
Source:safari-window-e2e-specs.js
...84 beforeEach(async () => {85 await driver.get(GUINEA_PIG_FRAME_PAGE);86 });87 it('should switch to frame by name', async () => {88 await driver.frame('first');89 (await driver.title()).should.be.equal('Frameset guinea pig');90 let h1 = await driver.elementByTagName('h1');91 (await h1.text()).should.be.equal('Sub frame 1');92 });93 it('should switch to frame by index', async () => {94 await driver.frame(1);95 (await driver.title()).should.be.equal('Frameset guinea pig');96 let h1 = await driver.elementByTagName('h1');97 (await h1.text()).should.be.equal('Sub frame 2');98 });99 it('should switch to frame by id', async () => {100 await driver.frame('frame3');101 (await driver.title()).should.be.equal('Frameset guinea pig');102 let h1 = await driver.elementByTagName('h1');103 (await h1.text()).should.be.equal('Sub frame 3');104 });105 it('should switch back to default content from frame', async () => {106 await driver.frame('first');107 (await driver.title()).should.be.equal('Frameset guinea pig');108 let h1 = await driver.elementByTagName('h1');109 (await h1.text()).should.be.equal('Sub frame 1');110 await driver.frame(null);111 (await driver.elementByTagName('frameset')).should.exist;112 });113 it('should switch to child frames', async () => {114 await driver.frame('third');115 (await driver.title()).should.be.equal('Frameset guinea pig');116 await driver.frame('childframe');117 (await driver.elementById('only_on_page_2')).should.exist;118 });119 it('should execute javascript in frame', async () => {120 await driver.frame('first');121 (await driver.execute(GET_ELEM_SYNC)).should.be.equal('Sub frame 1');122 });123 it.skip('should execute async javascript in frame', async () => {124 await driver.frame('first');125 (await driver.executeAsync(GET_ELEM_ASYNC)).should.be.equal('Sub frame 1');126 });127 });128 describe('iframes', function () {129 beforeEach(async () => {130 await driver.get(GUINEA_PIG_IFRAME_PAGE);131 });132 it('should switch to iframe by name', async () => {133 await driver.frame('iframe1');134 (await driver.title()).should.be.equal('Iframe guinea pig');135 let h1 = await driver.elementByTagName('h1');136 (await h1.text()).should.be.equal('Sub frame 1');137 });138 it('should switch to iframe by index', async () => {139 await driver.frame(1);140 (await driver.title()).should.be.equal('Iframe guinea pig');141 let h1 = await driver.elementByTagName('h1');142 (await h1.text()).should.be.equal('Sub frame 2');143 });144 it('should switch to iframe by id', async () => {145 await driver.frame('id-iframe3');146 (await driver.title()).should.be.equal('Iframe guinea pig');147 let h1 = await driver.elementByTagName('h1');148 (await h1.text()).should.be.equal('Sub frame 3');149 });150 it('should switch to iframe by element', async () => {151 let frame = await driver.elementById('id-iframe3');152 await driver.frame(frame);153 (await driver.title()).should.be.equal('Iframe guinea pig');154 let h1 = await driver.elementByTagName('h1');155 (await h1.text()).should.be.equal('Sub frame 3');156 });157 it('should not switch to iframe by element of wrong type', async () => {158 let h1 = await driver.elementByTagName('h1');159 await driver.frame(h1).should.eventually.be.rejected;160 });161 it('should switch back to default content from iframe', async () => {162 await driver.frame('iframe1');163 (await driver.title()).should.be.equal('Iframe guinea pig');164 let h1 = await driver.elementByTagName('h1');165 (await h1.text()).should.be.equal('Sub frame 1');166 await driver.frame(null);167 (await driver.elementsByTagName('iframe')).should.have.length(3);168 });169 });...
frames-base.js
Source:frames-base.js
...50 .elementById("only_on_page_2").should.eventually.exist51 .nodeify(done);52 });53 it('should execute javascript in frame', function (done) {54 driver.frame("first")55 .execute("return document.getElementsByTagName('h1')[0].innerHTML;")56 .should.become("Sub frame 1")57 .nodeify(done);58 });59 it('should execute async javascript in frame', function (done) {60 driver.frame("first")61 .executeAsync("arguments[arguments.length - 1](" +62 "document.getElementsByTagName('h1')[0].innerHTML);")63 .should.become("Sub frame 1")64 .nodeify(done);65 });66 });...
iframes-base.js
Source:iframes-base.js
...46 it('should not switch to iframe by element of wrong type', function (done) {47 driver48 .elementByTagName('h1')49 .then(function (h1) {50 return driver.frame(h1)51 .should.be.rejectedWith(/status: 8/);52 }).nodeify(done);53 });54 it('should switch back to default content from iframe', function (done) {55 driver56 .frame("iframe1")57 .title().should.become("Iframe guinea pig")58 .elementByTagName("h1").text().should.become("Sub frame 1")59 .frame(null)60 .elementsByTagName('iframe')61 .should.eventually.have.length(3)62 .nodeify(done);63 });64 });...
driver.js
Source:driver.js
1'use strict';2const EventEmitter = require('events');3module.exports = class Driver extends EventEmitter {4 constructor(client) {5 super();6 this.client = client;7 this.client.on("frame", this.router.bind(this))8 this.client.on("connect", () => this.emit("connect"))9 this.client.on("disconnect", () => this.emit("disconnect"))10 }11 connect() {12 if (this.client) this.client.connect();13 }14 disconnect() {15 if (this.client) this.client.disconnect();16 }17 queryManufacturer() {18 this.client.send('m');19 }20 querySensors() {21 this.client.send('s');22 }23 querySensorUnits(sensor) {24 this.client.send('u', [sensor]);25 }26 querySensorValue(sensor, unit) {27 this.client.send('v', [sensor, unit]);28 }29 router(frame) {30 // console.log("Driver: Frame received: command => " + frame.command + ", data => " + frame.data)31 switch (frame.command) {32 case 'm':33 if (frame.data.length == 1) {34 this.emit("manufacturer", frame.data[0])35 }36 break;37 case 's':38 if (frame.data.length > 0) {39 this.emit("sensors", frame.data)40 }41 break;42 case 'v':43 if (frame.data && frame.data.length == 3) {44 this.emit("value", {45 sensorName: frame.data[0],46 value: frame.data[1],47 unit: frame.data[2]48 })49 }50 break;51 case 'u':52 if (frame.data && frame.data.length > 2) {53 this.emit("units", {54 sensorName: frame.data[0],55 units: frame.data.slice(1)56 })57 }58 break;59 default:60 this.server.send('e', "Incorrect frame or command")61 break;62 }63 }...
context-tests.js
Source:context-tests.js
...28 await driver.elementByXPath('//*').getTagName()29 .should.eventually.become('html');30 });31 it('should not switch to a frame that is not there', async function () {32 await driver.frame('foo').should.eventually.be.rejectedWith(/8/);33 });34 it('should switch to an iframe', async function () {35 await driver.frame('iframe1').title()36 .should.eventually.become('Test iFrame');37 });38 it('should switch back to default frame', async function () {39 await driver.frame(null).title()40 .should.eventually.become('Test Webview');41 });42 it('should go back to native context', async function () {43 await driver.context('NATIVE_APP').elementByXPath('//*').getTagName()44 .should.eventually.become('app');45 });46 it('should not set a frame in a native context', async function () {47 await driver.frame('iframe1').should.eventually.be.rejectedWith(/36/);48 });49 });50}...
google-search.js
Source:google-search.js
1/** @format */2/**3 * External dependencies4 */5import { By as by, until } from 'selenium-webdriver';6/**7 * Internal dependencies8 */9import AsyncBaseContainer from '../../async-base-container';10import * as driverHelper from '../../driver-helper.js';11export default class GoogleSearchPage extends AsyncBaseContainer {12 constructor( driver ) {13 const frameSelector = by.css( 'iframe.iframe-preview' );14 super( driver, frameSelector );15 this.frameSelector = frameSelector;16 }17 async createAdLink( referenceUrl ) {18 await this.driver.wait(19 until.ableToSwitchToFrame( this.frameSelector ),20 this.explicitWaitMS,21 'Could not switch to iFrame'22 );23 await this.driver.sleep( 2000 ); // https://stackoverflow.com/questions/41429723/unhandled-error-cannot-find-context-with-specified-id-using-robot-framework24 this.adLinkselector = by.xpath(25 '//li[@class="ads-ad"]//a[contains(@href, "' + referenceUrl + '")]'26 );27 await driverHelper.waitTillPresentAndDisplayed( this.driver, this.adLinkselector );28 }29 async adExists() {30 return await driverHelper.isEventuallyPresentAndDisplayed( this.driver, this.adLinkselector );31 }32 async getAdUrl() {33 const adLink = await this.driver.findElement( this.adLinkselector );34 return await adLink.getAttribute( 'href' );35 }36 async getAdHeadline() {37 const adLink = await this.driver.findElement( this.adLinkselector );38 return await adLink.getText();39 }40 async getAdText() {41 const adLink = await this.driver.findElement( this.adLinkselector );42 return await adLink.findElement( by.xpath( '../../div[@class="ads-visurl"]/cite' ) ).getText();43 }44 async getAdVisibleUrl() {45 const adLink = await this.driver.findElement( this.adLinkselector );46 return await adLink47 .findElement( by.xpath( '../../div[contains(@class,"ads-creative")]' ) )48 .getText();49 }...
frame.js
Source:frame.js
1import type Driver from './driver';2import addDebugging from './add-debugging';3import BaseClass from './base-class';4class Frame extends BaseClass {5 constructor(driver: Driver) {6 super(driver, '/frame');7 }8 /*9 * Change focus to the default context on the page10 */11 async activateDefault(): Promise<void> {12 await this.requestJSON('POST', '', {id: null});13 }14 /*15 * Change focus to a specific frame on the page16 */17 async activate(id: string): Promise<void> {18 await this.requestJSON('POST', '', {id});19 }20 /*21 * Change focus to the parent context. If the current context is the top level browsing context, the context remains unchanged.22 */23 async activateParent(): Promise<void> {24 await this.requestJSON('POST', '/parent');25 }26}27addDebugging(Frame);...
Using AI Code Generation
1const wd = require('wd');2const chai = require('chai');3const chaiAsPromised = require('chai-as-promised');4const chaiSubset = require('chai-subset');5const { assert } = chai;6chai.use(chaiAsPromised);7chai.use(chaiSubset);8const desiredCaps = {9};10driver.init(desiredCaps);11driver.frame('frame name');12driver.quit();13[debug] [W3C (d6f0b7a0)] Calling AppiumDriver.frame() with args: ["frame name","d6f0b7a0-3e6e-4287-8f6b-1b2e2c9d00a3"]14[debug] [W3C (d6f0b7a0)] Encountered internal error running command: Error: frame is not supported on iOS15[debug] [W3C (d6f0b7a0)] at XCUITestDriver.frame (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest-driver/lib/commands/frame.js:13:11)16[debug] [W3C (d6f0b7a0)] at XCUITestDriver.wrapCommandFn (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:327:23)17[debug] [W3C (d6f0b7a0)] at XCUITestDriver.executeCommand (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/basedriver/driver.js:366:23)18[debug] [W3C (d6f0b7a0)] at XCUITestDriver.executeCommand (/Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-xcuitest
Using AI Code Generation
1let { remote } = require('webdriverio');2let assert = require('assert');3(async () => {4 const browser = await remote({5 capabilities: {6 }7 })8 await browser.frame({ id: 'iframe' })9 await browser.setValue('#name', 'John Doe')10 await browser.setValue('#email', '
Using AI Code Generation
1const wd = require('wd');2const {assert} = require('chai');3const {exec} = require('teen_process');4const {fs, tempDir} = require('appium-support');5const {retryInterval} = require('asyncbox');6const {IOSPerformanceLog} = require('appium-ios-log');7const {createDevice, deleteDevice} = require('node-simctl');8const MOCHA_TIMEOUT = 120000;9const MOCHA_LONG_TIMEOUT = 240000;10const TEST_APP = 'UICatalog.app.zip';11const TEST_APP_BUNDLE_ID = 'com.example.apple-samplecode.UICatalog';12const TEST_APP_NAME = 'UICatalog';
Using AI Code Generation
1describe('Test', function() {2 it('test', function() {3 driver.frame(0);4 driver.frame(1);5 driver.frame(2);6 driver.frame(3);7 driver.frame(4);8 driver.frame(5);9 driver.frame(6);10 driver.frame(7);11 driver.frame(8);12 driver.frame(9);13 driver.frame(10);14 driver.frame(11);15 driver.frame(12);16 driver.frame(13);17 driver.frame(14);18 driver.frame(15);19 driver.frame(16);20 driver.frame(17);21 driver.frame(18);22 driver.frame(19);23 driver.frame(20);24 driver.frame(21);25 driver.frame(22);26 driver.frame(23);27 driver.frame(24);28 driver.frame(25);29 driver.frame(26);30 driver.frame(27);31 driver.frame(28);32 driver.frame(29);33 driver.frame(30);34 driver.frame(31);35 driver.frame(32);36 driver.frame(33);37 driver.frame(34);38 driver.frame(35);39 driver.frame(36);40 driver.frame(37);41 driver.frame(38);42 driver.frame(39);43 driver.frame(40);44 driver.frame(41);45 driver.frame(42);46 driver.frame(43);47 driver.frame(44);48 driver.frame(45);49 driver.frame(46);50 driver.frame(47);51 driver.frame(48);52 driver.frame(49);53 driver.frame(50);54 driver.frame(51);55 driver.frame(52);56 driver.frame(53);57 driver.frame(54);58 driver.frame(55);59 driver.frame(56);60 driver.frame(57);61 driver.frame(58);62 driver.frame(59);63 driver.frame(60);64 driver.frame(61);65 driver.frame(62);66 driver.frame(63);67 driver.frame(64);68 driver.frame(65);69 driver.frame(66);70 driver.frame(67);71 driver.frame(68);72 driver.frame(69);73 driver.frame(70);74 driver.frame(71);75 driver.frame(72);76 driver.frame(73);77 driver.frame(74);78 driver.frame(75);79 driver.frame(76);80 driver.frame(77);81 driver.frame(78);82 driver.frame(79);
Using AI Code Generation
1var webdriver = require('selenium-webdriver');2var By = webdriver.By;3var driver = new webdriver.Builder()4 .withCapabilities(webdriver.Capabilities.ios())5 .build();6driver.frame('iframeResult');7driver.findElement(By.tagName('h1')).getText().then(function(text){8 console.log(text);9});10driver.frame(null);11driver.findElement(By.tagName('h1')).getText().then(function(text){12 console.log(text);13});14driver.quit();
Using AI Code Generation
1const wd = require('wd');2const { assert } = require('chai');3const { config } = require('./config');4describe('Appium XCUITest Driver Tests', function () {5 this.timeout(300000);6 let driver;7 before(async function () {8 driver = await wd.promiseChainRemote(config.host, config.port);9 await driver.init(config.capabilities);10 });11 after(async function () {12 await driver.quit();13 });14 it('should switch to frame', async function () {15 await driver.frame('frame1');16 const frame1 = await driver.elementByAccessibilityId('frame1');17 await assert.isTrue(frame1 !== null);18 });19 it('should switch back to native context', async function () {20 await driver.frame(null);21 const frame1 = await driver.elementByAccessibilityId('frame1');22 await assert.isTrue(frame1 === null);23 });24});25const config = {26 capabilities: {27 }28};29module.exports.config = config;
Using AI Code Generation
1const wd = require('wd');2const assert = require('assert');3const { exec } = require("child_process");4const config = {5};6(async function main() {7 try {8 await driver.init(config);9 await driver.setImplicitWaitTimeout(60000);10 await driver.frame('iframe');11 await driver.setImplicitWaitTimeout(60000);12 await driver.elementById('introAgreeButton').click();13 await driver.setImplicitWaitTimeout(60000);14 await driver.setImplicitWaitTimeout(60000);15 await driver.frame('iframe');16 await driver.setImplicitWaitTimeout(60000);17 await driver.elementById('introAgreeButton').click();18 await driver.setImplicitWaitTimeout(60000);19 await driver.setImplicitWaitTimeout(60000);20 await driver.frame('iframe');21 await driver.setImplicitWaitTimeout(60000);22 await driver.elementById('introAgreeButton').click();23 await driver.setImplicitWaitTimeout(60000);24 await driver.setImplicitWaitTimeout(60000);25 await driver.frame('iframe');26 await driver.setImplicitWaitTimeout(60000);27 await driver.elementById('introAgreeButton').click();28 await driver.setImplicitWaitTimeout(60000);29 await driver.setImplicitWaitTimeout(60000);30 await driver.frame('iframe');31 await driver.setImplicitWaitTimeout(60000);32 await driver.elementById('introAgreeButton').click();
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!