Best JavaScript code snippet using webdriverio-monorepo
test-webpage-frames.js
Source:test-webpage-frames.js
...36 expect(webpage.frameContent).toNotEqual('');37 expect(webpage.focusedFrameName).toEqual('');38 });39 it("has a frame that can be retrieved by name",function() {40 webpage.switchToFrame('frametop')41 expect(webpage.frameTitle).toEqual('frame top');42 expect(webpage.frameName).toEqual('frametop');43 expect(webpage.currentFrameName()).toEqual('frametop');44 expect(webpage.frameUrl).toEqual(domain+"frame_top.html");45 expect(webpage.frameContent).toNotEqual('');46 expect(webpage.framePlainText).toEqual(' top frame ');47 expect(webpage.title).toEqual('window frames');48 expect(webpage.url).toEqual(url);49 expect(webpage.windowName).toEqual('');50 });51 it("has a frame that can be retrieved by position",function() {52 webpage.switchToMainFrame()53 webpage.switchToFrame(0)54 expect(webpage.frameTitle).toEqual('frame top');55 expect(webpage.frameName).toEqual('frametop');56 expect(webpage.currentFrameName()).toEqual('frametop');57 expect(webpage.frameUrl).toEqual(domain+"frame_top.html");58 expect(webpage.frameContent).toNotEqual('');59 expect(webpage.framePlainText).toEqual(' top frame ');60 });61 it("has a sub frame that can be retrieved", function() {62 // verify that switchToFrame doesn't work here, so that we are still63 // in frametop64 expect(webpage.switchToFrame('frameright')).toEqual(false);65 expect(webpage.frameName).toEqual('frametop');66 // back to main frame67 webpage.switchToMainFrame()68 // go into a frame then a subframe69 webpage.switchToFrame('frameright');70 expect(webpage.framesName).toEqual(["subframetop","subframebottom"]);71 expect(webpage.framesCount).toEqual(2);72 webpage.switchToFrame('subframebottom')73 expect(webpage.frameTitle).toEqual('simple hello world');74 expect(webpage.frameName).toEqual('subframebottom');75 expect(webpage.currentFrameName()).toEqual('subframebottom');76 expect(webpage.frameUrl).toEqual(domain+"simplehello.html");77 expect(webpage.frameContent).toNotEqual('');78 expect(webpage.framePlainText).toEqual(' Hello World! ä½ å¥½ ! çà éèç ');79 // test switchToParentFrame80 webpage.switchToParentFrame();81 expect(webpage.frameName).toEqual('frameright');82 });83 it("has a sub frame that can be focused", function() {84 webpage.switchToMainFrame()85 webpage.switchToFrame('frameleft');86 expect(webpage.evaluate(function(){87 return setFocusInOtherFrame();88 })).toEqual("ok");89 expect(webpage.frameName).toEqual('frameleft');90 expect(webpage.focusedFrameName).toEqual('frametop');91 expect(webpage.switchToFocusedFrame()).toEqual(true);92 expect(webpage.frameName).toEqual('frametop');93 });94 it("has a sub frame that is unloaded", function() {95 webpage.switchToMainFrame()96 webpage.switchToFrame('frameright');97 webpage.switchToFrame('subframebottom')98 expect(webpage.frameTitle).toEqual('simple hello world');99 var loaded = false;100 runs(function() {101 expect(webpage.evaluate(function(){102 var win = window.parent.parent.frames[1];103 var url = win.location.href;104 var doc = win.document;105 var evt = doc.createEvent("MouseEvents");106 evt.initMouseEvent("click", true, true, win, 0, 0, 0, 0, 0, false, false, false, false, 0, null);107 var lk = doc.getElementById("linktoclick");108 if (!lk)109 return "no";110 lk.dispatchEvent(evt);111 return "ok "+url;112 })).toEqual("ok "+domain+"frame_left.html");113 setTimeout(function(){114 loaded = true;115 },400);116 });117 waitsFor(function(){ return loaded;}, 1000);118 runs(function(){119 expect(webpage.frameTitle).toEqual('');120 webpage.switchToMainFrame();121 webpage.switchToFrame('frameright');122 expect(webpage.frameTitle).toEqual('test consolemessage');123 webpage.close();124 });125 });126 // webpage.frameTitle RO127 // webpage.frameContent RW128 // webpage.frameUrl RO129 // webpage.framePlainText RO130 // webpage.framesName RO131 // webpage.frameName RO132 // webpage.currentFrameName() D133 // webpage.framesCount RO134 // webpage.childFramesCount() D135 // webpage.focusedFrameName136 // webpage.childFramesName RO D137 // webpage.switchToFrame(frameName)138 // webpage.switchToChildFrame(frameName) D139 // webpage.switchToFrame(position)140 // webpage.switchToChildFrame(position) D141 // webpage.switchToMainFrame()142 // webpage.switchToParentFrame()143 // webpage.switchToFocusedFrame()...
amp-driver.js
Source:amp-driver.js
...39 [AmpdocEnvironment.VIEWER_DEMO]: {40 ready(controller) {41 return controller42 .findElement('#viewer[data-loaded]')43 .then((frame) => controller.switchToFrame(frame));44 },45 url(url) {46 return getViewerUrl(url);47 },48 },49 [AmpdocEnvironment.EMAIL_DEMO]: {50 ready(controller) {51 return controller52 .findElement('#viewer[data-loaded]')53 .then((frame) => controller.switchToFrame(frame));54 },55 url(url) {56 return getViewerUrl(url, {isEmail: true});57 },58 },59 [AmpdocEnvironment.SHADOW_DEMO]: {60 async ready(controller) {61 // TODO(cvializ): this is a HACK62 // There should be a better way to detect that the shadowdoc is ready.63 const shadowHost = await controller.findElement(64 '.amp-doc-host[style="visibility: visible;"]'65 );66 const doc = await controller.getDocumentElement();67 const rect = await controller.getElementRect(shadowHost);68 await controller./*OK*/ scrollTo(doc, {left: rect.left, top: rect.top});69 await controller.switchToShadow(shadowHost);70 },71 url(url) {72 // TODO(estherkim): somehow allow non-8000 port and domain73 return `http://localhost:8000/pwa#href=${url}`;74 },75 },76 [AmpdocEnvironment.A4A_FIE]: {77 async ready(controller) {78 return controller79 .findElement('amp-ad > iframe')80 .then((frame) => controller.switchToFrame(frame));81 },82 url(url) {83 return url.replace(HOST, HOST + '/a4a');84 },85 },86 [AmpdocEnvironment.A4A_INABOX]: {87 async ready(controller) {88 return controller89 .findElement('#inabox-frame')90 .then((frame) => controller.switchToFrame(frame));91 },92 url(url) {93 return url.replace(HOST, HOST + '/inabox');94 },95 },96 [AmpdocEnvironment.A4A_INABOX_FRIENDLY]: {97 async ready(controller) {98 return controller99 .findElement('#inabox-frame')100 .then((frame) => controller.switchToFrame(frame));101 },102 url(url) {103 return url.replace(HOST, HOST + '/inabox-friendly');104 },105 },106 [AmpdocEnvironment.A4A_INABOX_SAFEFRAME]: {107 async ready(controller) {108 return controller109 .findElement('#inabox-frame')110 .then((frame) => controller.switchToFrame(frame));111 },112 url(url) {113 return url.replace(HOST, HOST + '/inabox-safeframe');114 },115 },116};117/**118 * @param {string} url119 * @param {{isEmail: boolean}=} opts120 * @return {string}121 */122function getViewerUrl(url, {isEmail} = {isEmail: false}) {123 const defaultCaps = [124 'a2a',...
payment.page.js
Source:payment.page.js
...49 * This method helps to validate credit card fields50 */51 async verifyCreditCardDetails() {52 var iframe = await $$(".card-fields-iframe");53 await browser.switchToFrame(iframe[0]);54 const cn = await (await this.txtCardNumber).getAttribute('placeholder');55 console.log(cn);56 assert(cn == "Card number");57 await browser.switchToFrame(null);58 await browser.switchToFrame(iframe[1]);59 const nodc = await (await this.txtNameOnTheCard).getAttribute('placeholder');60 console.log(nodc);61 assert(nodc == "Name on card");62 await browser.switchToFrame(null);63 await browser.switchToFrame(iframe[3]);64 const expiry = await (await this.txtExpiry).getAttribute('placeholder');65 console.log(expiry);66 assert(expiry == "Expiration date (MM / YY)");67 await browser.switchToFrame(null);68 await browser.switchToFrame(iframe[4]);69 const seccode = await (await this.txtSecurityCode).getAttribute('placeholder');70 console.log(seccode);71 assert(seccode == "Security code");72 await browser.switchToFrame(null);73 }74}...
frame-switching.js
Source:frame-switching.js
...15 assert_equals(p.frameName, "");16 assert_equals(p.framesCount, 2);17 assert_deep_equals(p.framesName, ["frame1", "frame2"]);18 setPageTitle(p, pageTitle(p) + "-visited");19 assert_is_true(p.switchToFrame("frame1"));20 assert_equals(pageTitle(p), "frame1");21 assert_equals(p.frameName, "frame1");22 assert_equals(p.framesCount, 2);23 assert_deep_equals(p.framesName, ["frame1-1", "frame1-2"]);24 setPageTitle(p, pageTitle(p) + "-visited");25 assert_is_true(p.switchToFrame("frame1-2"));26 assert_equals(pageTitle(p), "frame1-2");27 assert_equals(p.frameName, "frame1-2");28 assert_equals(p.framesCount, 0);29 assert_deep_equals(p.framesName, []);30 setPageTitle(p, pageTitle(p) + "-visited");31 assert_is_true(p.switchToParentFrame());32 assert_equals(pageTitle(p), "frame1-visited");33 assert_equals(p.frameName, "frame1");34 assert_equals(p.framesCount, 2);35 assert_deep_equals(p.framesName, ["frame1-1", "frame1-2"]);36 assert_is_true(p.switchToFrame(0));37 assert_equals(pageTitle(p), "frame1-1");38 assert_equals(p.frameName, "frame1-1");39 assert_equals(p.framesCount, 0);40 assert_deep_equals(p.framesName, []);41 assert_equals(p.switchToMainFrame(), undefined);42 assert_equals(pageTitle(p), "index-visited");43 assert_equals(p.frameName, "");44 assert_equals(p.framesCount, 2);45 assert_deep_equals(p.framesName, ["frame1", "frame2"]);46 assert_is_true(p.switchToFrame("frame2"));47 assert_equals(pageTitle(p), "frame2");48 assert_equals(p.frameName, "frame2");49 assert_equals(p.framesCount, 3);50 assert_deep_equals(p.framesName,51 ["frame2-1", "frame2-2", "frame2-3"]);52 assert_equals(p.focusedFrameName, "");53 p.evaluate(function(){54 window.focus();55 });56 assert_equals(p.focusedFrameName, "frame2");57 assert_is_true(p.switchToFrame("frame2-1"));58 p.evaluate(function(){59 window.focus();60 });61 assert_equals(p.focusedFrameName, "frame2-1");62 assert_equals(p.switchToMainFrame(), undefined);63 p.evaluate(function(){64 window.focus();65 });66 assert_equals(p.focusedFrameName, "");67 p.evaluate(function(){68 window.frames[0].focus();69 });70 assert_equals(p.focusedFrameName, "frame1");71 assert_equals(p.frameName, "");...
index.js
Source:index.js
...12 await passwordInput.setValue(process.env.BRILLCMS_PASSWORD)13 const loginBtn = await browser.$('#ctl00_ContentPlaceHolder1_Login1_LoginButton')14 await loginBtn.click()15 await browser.navigateTo('http://brillcms.com/lb')16 browser.switchToFrame(2)17}18async function searchAndClickFirst(pause) {19 const searchLink = await browser.$('#ctl00_lnkSearch')20 await searchLink.click()21 let el22 el = await browser.$('#ctl00_ContentPlaceHolder1_GeneralSearch_FieldSelectionGridView_ctl02_DropDownListFieldName')23 await el.setValue('Contributor')24 await browser.pause(pause)25 el = await browser.$('#ctl00_ContentPlaceHolder1_GeneralSearch_FieldSelectionGridView_ctl02_DropDownListFieldSelection')26 await el.setValue('SDMI')27 const sb = await browser.$('#ctl00_ContentPlaceHolder1_ButtonSearchAll')28 await sb.click()29 const r = await browser.$('#ctl00_ContentPlaceHolder1_gvRecords_ctl03_lnkDocManagement')30 await r.click()31}32async function prepareCopy(pause) {33 await browser.pause(pause)34 await browser.switchToFrame(null)35 await browser.switchToFrame(1)36}37async function copy() {38 const c = await browser.$('#copyFicheCommandButton')39 await c.click()40}41async function prepareEdit() {42 const b = await browser.$('body')43 await b.click()44}45async function clickMenuItem(item) {46 let el = await browser.$('#InsertMenuButton')47 await el.click()48 el = await browser.$('.menu')49 let el1 = await el.$('strong=' + item)50 await el1.click()51}52async function prepareSpecEdit() {53 await browser.switchToFrame(null)54 await browser.switchToFrame(1)55 await browser.switchToFrame(1)56 // console.log(browser.getPageSource())57 // change ENG to RUS58 let el0 = await browser.$('.//textNode[normalize-space()="ENG"]')59 await browser.executeScript("arguments[0].innerHTML='RUS'", [el0])60 let el = await browser.$('.//textNode[normalize-space()="(TITLESORT)"]')61 await el.click()62 await browser.switchToFrame(null)63 await browser.switchToFrame(1)64}65(async () => {66 browser = await remote({67 capabilities: {68 browserName: 'chrome'69 }70 })71 await browser.navigateTo('http://brillcms.com/lb/security/login.aspx?ReturnUrl=%2flb%2f')72 await login();73 await searchAndClickFirst(3000);74 await prepareCopy(3000);75 await copy();76 await prepareEdit();77 await clickMenuItem('ABSTRACT');...
disable.js
Source:disable.js
...14 // go to Parental Controls15 await clickMenuItem(browser, d.menuPcSelector);16 await sleep(2000);17 // get state of "Enable Parental Controls" and set it to enabled if needed18 await browser.switchToFrame(await browser.$(d.mainFrameSelector));19 let pcs = browser.$(d.enableParConSelector);20 if ( pcs.isSelected === true ) {21 throw ("Enable Parental Controls should not be selected at this moment!");22 }23 await browser.switchToFrame(null);24 await clickMainItem(browser, d.enableParConSelector);25 await sleep(2000);26 await clickMainItem(browser, d.enableParConSaveSelector);27 await sleep(2000);28 // go to System Tools -> Reboot29 await clickMenuItem(browser, d.menuToolsSelector);30 await clickMenuItem(browser, d.menuRestartSelector);31 // logout (for enable internet only)32 await clickMenuItem(browser, d.menuRestartSelector);33 await sleep(1000);34 await clickMainItem(browser, d.restartButtonSelector);35 await sleep(1000);36 try {37 await browser.acceptAlert();38 } catch (e) {39 throw e;40 }41 await browser.deleteSession()42})().catch((e) => console.error(e))43async function clickMenuItem(browser, item) {44 await browser.switchToFrame(await browser.$(d.menuFrameSelector));45 console.log("Going to click Menu " + item)46 await clickItem(browser, item);47 await browser.switchToFrame(null);48}49async function clickMainItem(browser, item) {50 await browser.switchToFrame(await browser.$(d.mainFrameSelector));51 console.log("Going to click Main " + item)52 await clickItem(browser, item);53 await browser.switchToFrame(null);54}55async function clickItem(browser,item) {56 await sleep(d.defaultWaitTime);57 await (await browser.$(item)).click();58 await sleep(d.defaultWaitTime);59}60async function sleep(ms) {61 return new Promise((resolve) => setTimeout(resolve, ms))...
frames.spec.js
Source:frames.spec.js
...7 const urlsList = new UrlsList();89 it('Test left Iframe', async () => {10 await browser.get(urlsList.url_frames);11 await framePage.switchToFrame(framePage.topFrame);12 await framePage.switchToFrame(framePage.leftFrame);13 expect(await framePage.getBodyIframe()).to.equal('LEFT');14 });1516 it('Test middle Iframe', async () => {17 await browser.switchTo().defaultContent();18 await framePage.switchToFrame(framePage.topFrame);19 await framePage.switchToFrame(framePage.middleFrame);20 expect(await helpers.getTextByLocator(framePage.contentMiddleFrame)).to.equal('MIDDLE');21 });2223 it('Test right Iframe', async () => {24 await browser.switchTo().defaultContent();25 await framePage.switchToFrame(framePage.topFrame);26 await framePage.switchToFrame(framePage.rightFrame);27 const contentRightFrame = await framePage.getBodyIframe();28 expect(contentRightFrame).to.equal('RIGHT');29 });3031 it('Test bottom Iframe', async () => {32 await browser.switchTo().defaultContent();33 await framePage.switchToFrame(framePage.bottomFrame);34 expect(await framePage.getBodyIframe()).to.equal('BOTTOM');35 });
...
textInputApp.js
Source:textInputApp.js
...3import { INPUT_TYPE_PAUSE, SAVE_USER_INPUT_PAUSE } from '../constants';4const INPUT_TEXT_FIELD_SELECTOR = '#inputTextField';5const SAVE_BUTTON_SELECTOR = 'button';6export const typeInTextInputApp = async (client, id, text) => {7 await client.switchToFrame(8 await client.$(`[name="${buildPhaseAppName(id)}"]`)9 );10 await (await client.$(INPUT_TEXT_FIELD_SELECTOR)).setValue(text);11 await client.pause(INPUT_TYPE_PAUSE);12 // click on save button13 await (await client.$(SAVE_BUTTON_SELECTOR)).click();14 await client.pause(SAVE_USER_INPUT_PAUSE);15 // reset client on parent frame16 await client.switchToFrame(null);17};18export const checkTextInputAppContainsText = async (client, id, text) => {19 await client.switchToFrame(20 await client.$(`[name="${buildPhaseAppName(id)}"]`)21 );22 const inputText = await (await client.$(INPUT_TEXT_FIELD_SELECTOR)).getText();23 expect(inputText).to.equal(text);24 // reset client on parent frame25 await client.switchToFrame(null);...
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6var client = webdriverio.remote(options);7 .init()8 .frame(0)9 .click('a[href="default.asp"]')10 .end();11var webdriverio = require('webdriverio');12var options = {13 desiredCapabilities: {14 }15};16var client = webdriverio.remote(options);17 .init()18 .frame(0)19 .click('a[href="default.asp"]')20 .frameParent()21 .end();22var webdriverio = require('webdriverio');23var options = {24 desiredCapabilities: {25 }26};27var client = webdriverio.remote(options);28 .init()29 .frame(0)30 .click('a[href="default.asp"]')31 .frameParent()32 .frame(null)33 .end();34var webdriverio = require('webdriverio');35var options = {36 desiredCapabilities: {37 }38};39var client = webdriverio.remote(options);40 .init()41 .frame(0)42 .click('a[href="default.asp"]')43 .frameParent()44 .frame(null)45 .getCurrentFrame()46 .then(function (frame) {
Using AI Code Generation
1describe('Switch to frame', function() {2 it('Switch to frame', function() {3 browser.switchToFrame(0);4 browser.pause(3000);5 browser.switchToFrame(null);6 browser.pause(3000);7 });8});9describe('Switch to frame', function() {10 it('Switch to frame', function() {11 browser.switchToFrame('frame1');12 browser.pause(3000);13 browser.switchToFrame(null);14 browser.pause(3000);15 });16});17describe('Switch to frame', function() {18 it('Switch to frame', function() {19 browser.switchToFrame($('iframe[name="frame1"]'));20 browser.pause(3000);21 browser.switchToFrame(null);22 browser.pause(3000);23 });24});
Using AI Code Generation
1describe('webdriver.io page', () => {2 it('should switch to a frame', () => {3 browser.switchToFrame(0);4 browser.switchToParentFrame();5 });6});7describe('webdriver.io page', () => {8 it('should send keys to a particular frame', () => {9 browser.switchToFrame(0);10 browser.keys('webdriverio');11 browser.switchToParentFrame();12 });13});14describe('webdriver.io page', () => {15 it('should get the title of the current frame', () => {16 browser.switchToFrame(0);17 console.log(browser.getTitle());18 browser.switchToParentFrame();19 });20});21describe('webdriver.io page', () => {22 it('should get the source of the current
Using AI Code Generation
1describe('test', function() {2 it('test', function() {3 browser.switchToFrame(0);4 });5});6describe('test', function() {7 it('test', function() {8 browser.switchToFrame('frameName');9 });10});11describe('test', function() {12 it('test', function() {13 var frame = browser.element('frameName');14 browser.switchToFrame(frame);15 });16});17describe('test', function() {18 it('test', function() {19 var frame = browser.element('frameName');20 browser.switchToFrame(frame.value);21 });22});
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .windowHandleMaximize()9 .frame(0)10 .click('#submitbtn')11 .end();
Wondering what could be a next-gen browser and mobile test automation framework that is also simple and concise? Yes, that’s right, it's WebdriverIO. Since the setup is very easy to follow compared to Selenium testing configuration, you can configure the features manually thereby being the center of attraction for automation testing. Therefore the testers adopt WedriverIO to fulfill their needs of browser testing.
Learn to run automation testing with WebdriverIO tutorial. Go from a beginner to a professional automation test expert with LambdaTest WebdriverIO tutorial.
Running Your First Automation Script - Learn the steps involved to execute your first Test Automation Script using WebdriverIO since the setup is very easy to follow and the features can be configured manually.
Selenium Automation With WebdriverIO - Read more about automation testing with WebdriverIO and how it supports both browsers and mobile devices.
Browser Commands For Selenium Testing - Understand more about the barriers faced while working on your Selenium Automation Scripts in WebdriverIO, the ‘browser’ object and how to use them?
Handling Alerts & Overlay In Selenium - Learn different types of alerts faced during automation, how to handle these alerts and pops and also overlay modal in WebdriverIO.
How To Use Selenium Locators? - Understand how Webdriver uses selenium locators in a most unique way since having to choose web elements very carefully for script execution is very important to get stable test results.
Deep Selectors In Selenium WebdriverIO - The most popular automation testing framework that is extensively adopted by all the testers at a global level is WebdriverIO. Learn how you can use Deep Selectors in Selenium WebdriverIO.
Handling Dropdown In Selenium - Learn more about handling dropdowns and how it's important while performing automated browser testing.
Automated Monkey Testing with Selenium & WebdriverIO - Understand how you can leverage the amazing quality of WebdriverIO along with selenium framework to automate monkey testing of your website or web applications.
JavaScript Testing with Selenium and WebdriverIO - Speed up your Javascript testing with Selenium and WebdriverIO.
Cross Browser Testing With WebdriverIO - Learn more with this step-by-step tutorial about WebdriverIO framework and how cross-browser testing is done with WebdriverIO.
Get 100 minutes of automation test minutes FREE!!