How to use browser.close method in qawolf

Best JavaScript code snippet using qawolf

client-navigation.js

Source:client-navigation.js Github

copy

Full Screen

...10 .elementByCss('#about-link').click()11 .waitForElementByCss('.nav-about')12 .elementByCss('p').text()13 expect(text).toBe('This is the about page.')14 browser.close()15 })16 it('should navigate via the client side', async () => {17 const browser = await webdriver(context.appPort, '/nav')18 const counterText = await browser19 .elementByCss('#increase').click()20 .elementByCss('#about-link').click()21 .waitForElementByCss('.nav-about')22 .elementByCss('#home-link').click()23 .waitForElementByCss('.nav-home')24 .elementByCss('#counter').text()25 expect(counterText).toBe('Counter: 1')26 browser.close()27 })28 })29 describe('With url property', () => {30 it('Should keep immutable pathname, asPath and query', async () => {31 const browser = await webdriver(context.appPort, '/nav/url-prop-change')32 await browser.elementByCss('#add-query').click()33 const urlResult = await browser.elementByCss('#url-result').text()34 const previousUrlResult = await browser.elementByCss('#previous-url-result').text()35 expect(JSON.parse(urlResult)).toMatchObject({ 'query': { 'added': 'yes' }, 'pathname': '/nav/url-prop-change', 'asPath': '/nav/url-prop-change?added=yes' })36 expect(JSON.parse(previousUrlResult)).toMatchObject({ 'query': {}, 'pathname': '/nav/url-prop-change', 'asPath': '/nav/url-prop-change' })37 browser.close()38 })39 })40 describe('with <a/> tag inside the <Link />', () => {41 it('should navigate the page', async () => {42 const browser = await webdriver(context.appPort, '/nav/about')43 const text = await browser44 .elementByCss('#home-link').click()45 .waitForElementByCss('.nav-home')46 .elementByCss('p').text()47 expect(text).toBe('This is the home.')48 browser.quit()49 })50 it('should not navigate if the <a/> tag has a target', async () => {51 const browser = await webdriver(context.appPort, '/nav')52 const counterText = await browser53 .elementByCss('#increase').click()54 .elementByCss('#target-link').click()55 .elementByCss('#counter').text()56 expect(counterText).toBe('Counter: 1')57 browser.close()58 })59 })60 describe('with unexpected <a/> nested tag', () => {61 it('should not redirect if passHref prop is not defined in Link', async () => {62 const browser = await webdriver(context.appPort, '/nav/pass-href-prop')63 const text = await browser64 .elementByCss('#without-href').click()65 .waitForElementByCss('.nav-pass-href-prop')66 .elementByCss('p').text()67 expect(text).toBe('This is the passHref prop page.')68 browser.close()69 })70 it('should redirect if passHref prop is defined in Link', async () => {71 const browser = await webdriver(context.appPort, '/nav/pass-href-prop')72 const text = await browser73 .elementByCss('#with-href').click()74 .waitForElementByCss('.nav-home')75 .elementByCss('p').text()76 expect(text).toBe('This is the home.')77 browser.close()78 })79 })80 describe('with empty getInitialProps()', () => {81 it('should render an error', async () => {82 let browser83 try {84 browser = await webdriver(context.appPort, '/nav')85 await browser.elementByCss('#empty-props').click()86 await waitFor(3000)87 expect(await getReactErrorOverlayContent(browser)).toMatch(88 /should resolve to an object\. But found "null" instead\./89 )90 } finally {91 if (browser) {92 browser.close()93 }94 }95 })96 })97 describe('with the same page but different querystring', () => {98 it('should navigate the page', async () => {99 const browser = await webdriver(context.appPort, '/nav/querystring?id=1')100 const text = await browser101 .elementByCss('#next-id-link').click()102 .waitForElementByCss('.nav-id-2')103 .elementByCss('p').text()104 expect(text).toBe('2')105 browser.close()106 })107 it('should remove querystring', async () => {108 const browser = await webdriver(context.appPort, '/nav/querystring?id=1')109 const text = await browser110 .elementByCss('#main-page').click()111 .waitForElementByCss('.nav-id-0')112 .elementByCss('p').text()113 expect(text).toBe('0')114 browser.close()115 })116 })117 describe('with the current url', () => {118 it('should reload the page', async () => {119 const browser = await webdriver(context.appPort, '/nav/self-reload')120 const defaultCount = await browser.elementByCss('p').text()121 expect(defaultCount).toBe('COUNT: 0')122 const countAfterClicked = await browser123 .elementByCss('#self-reload-link').click()124 .elementByCss('p').text()125 expect(countAfterClicked).toBe('COUNT: 1')126 browser.close()127 })128 it('should always replace the state', async () => {129 const browser = await webdriver(context.appPort, '/nav')130 const countAfterClicked = await browser131 .elementByCss('#self-reload-link').click()132 .waitForElementByCss('#self-reload-page')133 .elementByCss('#self-reload-link').click()134 .elementByCss('#self-reload-link').click()135 .elementByCss('p').text()136 // counts (page change + two clicks)137 expect(countAfterClicked).toBe('COUNT: 3')138 // Since we replace the state, back button would simply go us back to /nav139 await browser140 .back()141 .waitForElementByCss('.nav-home')142 browser.close()143 })144 })145 describe('with onClick action', () => {146 it('should reload the page and perform additional action', async () => {147 let browser148 try {149 browser = await webdriver(context.appPort, '/nav/on-click')150 const defaultCountQuery = await browser.elementByCss('#query-count').text()151 const defaultCountState = await browser.elementByCss('#state-count').text()152 expect(defaultCountQuery).toBe('QUERY COUNT: 0')153 expect(defaultCountState).toBe('STATE COUNT: 0')154 await browser.elementByCss('#on-click-link').click()155 const countQueryAfterClicked = await browser.elementByCss('#query-count').text()156 const countStateAfterClicked = await browser.elementByCss('#state-count').text()157 expect(countQueryAfterClicked).toBe('QUERY COUNT: 1')158 expect(countStateAfterClicked).toBe('STATE COUNT: 1')159 } finally {160 if (browser) {161 browser.close()162 }163 }164 })165 it('should not reload if default was prevented', async () => {166 let browser167 try {168 browser = await webdriver(context.appPort, '/nav/on-click')169 const defaultCountQuery = await browser.elementByCss('#query-count').text()170 const defaultCountState = await browser.elementByCss('#state-count').text()171 expect(defaultCountQuery).toBe('QUERY COUNT: 0')172 expect(defaultCountState).toBe('STATE COUNT: 0')173 await browser.elementByCss('#on-click-link-prevent-default').click()174 const countQueryAfterClicked = await browser.elementByCss('#query-count').text()175 const countStateAfterClicked = await browser.elementByCss('#state-count').text()176 expect(countQueryAfterClicked).toBe('QUERY COUNT: 0')177 expect(countStateAfterClicked).toBe('STATE COUNT: 1')178 await browser.elementByCss('#on-click-link').click()179 const countQueryAfterClickedAgain = await browser.elementByCss('#query-count').text()180 const countStateAfterClickedAgain = await browser.elementByCss('#state-count').text()181 expect(countQueryAfterClickedAgain).toBe('QUERY COUNT: 1')182 expect(countStateAfterClickedAgain).toBe('STATE COUNT: 2')183 } finally {184 if (browser) {185 browser.close()186 }187 }188 })189 it('should always replace the state and perform additional action', async () => {190 let browser191 try {192 browser = await webdriver(context.appPort, '/nav')193 await browser.elementByCss('#on-click-link').click().waitForElementByCss('#on-click-page')194 const defaultCountQuery = await browser.elementByCss('#query-count').text()195 expect(defaultCountQuery).toBe('QUERY COUNT: 1')196 await browser.elementByCss('#on-click-link').click()197 const countQueryAfterClicked = await browser.elementByCss('#query-count').text()198 const countStateAfterClicked = await browser.elementByCss('#state-count').text()199 expect(countQueryAfterClicked).toBe('QUERY COUNT: 2')200 expect(countStateAfterClicked).toBe('STATE COUNT: 1')201 // Since we replace the state, back button would simply go us back to /nav202 await browser.back().waitForElementByCss('.nav-home')203 } finally {204 if (browser) {205 browser.close()206 }207 }208 })209 })210 describe('with hash changes', () => {211 describe('when hash change via Link', () => {212 it('should not run getInitialProps', async () => {213 const browser = await webdriver(context.appPort, '/nav/hash-changes')214 const counter = await browser215 .elementByCss('#via-link').click()216 .elementByCss('p').text()217 expect(counter).toBe('COUNT: 0')218 browser.close()219 })220 it('should scroll to the specified position on the same page', async () => {221 let browser222 try {223 browser = await webdriver(context.appPort, '/nav/hash-changes')224 // Scrolls to item 400 on the page225 const scrollPosition = await browser226 .elementByCss('#scroll-to-item-400').click()227 .eval('window.pageYOffset')228 expect(scrollPosition).toBe(7258)229 // Scrolls back to top when scrolling to `#` with no value.230 const scrollPositionAfterEmptyHash = await browser231 .elementByCss('#via-empty-hash').click()232 .eval('window.pageYOffset')233 expect(scrollPositionAfterEmptyHash).toBe(0)234 } finally {235 if (browser) {236 browser.close()237 }238 }239 })240 it('should scroll to the specified position on the same page with a name property', async () => {241 let browser242 try {243 browser = await webdriver(context.appPort, '/nav/hash-changes')244 // Scrolls to item 400 with name="name-item-400" on the page245 const scrollPosition = await browser246 .elementByCss('#scroll-to-name-item-400').click()247 .eval('window.pageYOffset')248 console.log(scrollPosition)249 expect(scrollPosition).toBe(16258)250 // Scrolls back to top when scrolling to `#` with no value.251 const scrollPositionAfterEmptyHash = await browser252 .elementByCss('#via-empty-hash').click()253 .eval('window.pageYOffset')254 expect(scrollPositionAfterEmptyHash).toBe(0)255 } finally {256 if (browser) {257 browser.close()258 }259 }260 })261 it('should scroll to the specified position to a new page', async () => {262 let browser263 try {264 browser = await webdriver(context.appPort, '/nav')265 // Scrolls to item 400 on the page266 await browser267 .elementByCss('#scroll-to-hash').click()268 .waitForElementByCss('#hash-changes-page')269 const scrollPosition = await browser.eval('window.pageYOffset')270 expect(scrollPosition).toBe(7258)271 } finally {272 if (browser) {273 browser.close()274 }275 }276 })277 })278 describe('when hash change via A tag', () => {279 it('should not run getInitialProps', async () => {280 const browser = await webdriver(context.appPort, '/nav/hash-changes')281 const counter = await browser282 .elementByCss('#via-a').click()283 .elementByCss('p').text()284 expect(counter).toBe('COUNT: 0')285 browser.close()286 })287 })288 describe('when hash get removed', () => {289 it('should not run getInitialProps', async () => {290 const browser = await webdriver(context.appPort, '/nav/hash-changes')291 const counter = await browser292 .elementByCss('#via-a').click()293 .elementByCss('#page-url').click()294 .elementByCss('p').text()295 expect(counter).toBe('COUNT: 1')296 browser.close()297 })298 })299 describe('when hash set to empty', () => {300 it('should not run getInitialProps', async () => {301 const browser = await webdriver(context.appPort, '/nav/hash-changes')302 const counter = await browser303 .elementByCss('#via-a').click()304 .elementByCss('#via-empty-hash').click()305 .elementByCss('p').text()306 expect(counter).toBe('COUNT: 0')307 browser.close()308 })309 })310 describe('when hash changed to a different hash', () => {311 it('should not run getInitialProps', async () => {312 const browser = await webdriver(context.appPort, '/nav/hash-changes')313 const counter = await browser314 .elementByCss('#via-a').click()315 .elementByCss('#via-link').click()316 .elementByCss('p').text()317 expect(counter).toBe('COUNT: 0')318 browser.close()319 })320 })321 })322 describe('with shallow routing', () => {323 it('should update the url without running getInitialProps', async () => {324 const browser = await webdriver(context.appPort, '/nav/shallow-routing')325 const counter = await browser326 .elementByCss('#increase').click()327 .elementByCss('#increase').click()328 .elementByCss('#counter').text()329 expect(counter).toBe('Counter: 2')330 const getInitialPropsRunCount = await browser331 .elementByCss('#get-initial-props-run-count').text()332 expect(getInitialPropsRunCount).toBe('getInitialProps run count: 1')333 browser.close()334 })335 it('should handle the back button and should not run getInitialProps', async () => {336 const browser = await webdriver(context.appPort, '/nav/shallow-routing')337 let counter = await browser338 .elementByCss('#increase').click()339 .elementByCss('#increase').click()340 .elementByCss('#counter').text()341 expect(counter).toBe('Counter: 2')342 counter = await browser343 .back()344 .elementByCss('#counter').text()345 expect(counter).toBe('Counter: 1')346 const getInitialPropsRunCount = await browser347 .elementByCss('#get-initial-props-run-count').text()348 expect(getInitialPropsRunCount).toBe('getInitialProps run count: 1')349 browser.close()350 })351 it('should run getInitialProps always when rending the page to the screen', async () => {352 const browser = await webdriver(context.appPort, '/nav/shallow-routing')353 const counter = await browser354 .elementByCss('#increase').click()355 .elementByCss('#increase').click()356 .elementByCss('#home-link').click()357 .waitForElementByCss('.nav-home')358 .back()359 .waitForElementByCss('.shallow-routing')360 .elementByCss('#counter').text()361 expect(counter).toBe('Counter: 2')362 const getInitialPropsRunCount = await browser363 .elementByCss('#get-initial-props-run-count').text()364 expect(getInitialPropsRunCount).toBe('getInitialProps run count: 2')365 browser.close()366 })367 })368 describe('with URL objects', () => {369 it('should work with <Link/>', async () => {370 const browser = await webdriver(context.appPort, '/nav')371 const text = await browser372 .elementByCss('#query-string-link').click()373 .waitForElementByCss('.nav-querystring')374 .elementByCss('p').text()375 expect(text).toBe('10')376 expect(await browser.url())377 .toBe(`http://localhost:${context.appPort}/nav/querystring/10#10`)378 browser.close()379 })380 it('should work with "Router.push"', async () => {381 const browser = await webdriver(context.appPort, '/nav')382 const text = await browser383 .elementByCss('#query-string-button').click()384 .waitForElementByCss('.nav-querystring')385 .elementByCss('p').text()386 expect(text).toBe('10')387 expect(await browser.url())388 .toBe(`http://localhost:${context.appPort}/nav/querystring/10#10`)389 browser.close()390 })391 it('should work with the "replace" prop', async () => {392 const browser = await webdriver(context.appPort, '/nav')393 let stackLength = await browser394 .eval('window.history.length')395 expect(stackLength).toBe(2)396 // Navigation to /about using a replace link should maintain the url stack length397 const text = await browser398 .elementByCss('#about-replace-link').click()399 .waitForElementByCss('.nav-about')400 .elementByCss('p').text()401 expect(text).toBe('This is the about page.')402 stackLength = await browser403 .eval('window.history.length')404 expect(stackLength).toBe(2)405 // Going back to the home with a regular link will augment the history count406 await browser407 .elementByCss('#home-link').click()408 .waitForElementByCss('.nav-home')409 stackLength = await browser410 .eval('window.history.length')411 expect(stackLength).toBe(3)412 browser.close()413 })414 })415 describe('with getInitialProp redirect', () => {416 it('should redirect the page via client side', async () => {417 const browser = await webdriver(context.appPort, '/nav')418 const text = await browser419 .elementByCss('#redirect-link').click()420 .waitForElementByCss('.nav-about')421 .elementByCss('p').text()422 expect(text).toBe('This is the about page.')423 browser.close()424 })425 it('should redirect the page when loading', async () => {426 const browser = await webdriver(context.appPort, '/nav/redirect')427 const text = await browser428 .waitForElementByCss('.nav-about')429 .elementByCss('p').text()430 expect(text).toBe('This is the about page.')431 browser.close()432 })433 })434 describe('with different types of urls', () => {435 it('should work with normal page', async () => {436 const browser = await webdriver(context.appPort, '/with-cdm')437 const text = await browser.elementByCss('p').text()438 expect(text).toBe('ComponentDidMount executed on client.')439 browser.close()440 })441 it('should work with dir/ page', async () => {442 const browser = await webdriver(context.appPort, '/nested-cdm')443 const text = await browser.elementByCss('p').text()444 expect(text).toBe('ComponentDidMount executed on client.')445 browser.close()446 })447 it('should work with /index page', async () => {448 const browser = await webdriver(context.appPort, '/index')449 const text = await browser.elementByCss('p').text()450 expect(text).toBe('ComponentDidMount executed on client.')451 browser.close()452 })453 it('should work with / page', async () => {454 const browser = await webdriver(context.appPort, '/')455 const text = await browser.elementByCss('p').text()456 expect(text).toBe('ComponentDidMount executed on client.')457 browser.close()458 })459 })460 describe('with the HOC based router', () => {461 it('should navigate as expected', async () => {462 const browser = await webdriver(context.appPort, '/nav/with-hoc')463 const pathname = await browser.elementByCss('#pathname').text()464 expect(pathname).toBe('Current path: /nav/with-hoc')465 const asPath = await browser.elementByCss('#asPath').text()466 expect(asPath).toBe('Current asPath: /nav/with-hoc')467 const text = await browser468 .elementByCss('.nav-with-hoc a').click()469 .waitForElementByCss('.nav-home')470 .elementByCss('p').text()471 expect(text).toBe('This is the home.')472 browser.close()473 })474 })475 describe('with asPath', () => {476 describe('inside getInitialProps', () => {477 it('should show the correct asPath with a Link with as prop', async () => {478 const browser = await webdriver(context.appPort, '/nav')479 const asPath = await browser480 .elementByCss('#as-path-link').click()481 .waitForElementByCss('.as-path-content')482 .elementByCss('.as-path-content').text()483 expect(asPath).toBe('/as/path')484 browser.close()485 })486 it('should show the correct asPath with a Link without the as prop', async () => {487 const browser = await webdriver(context.appPort, '/nav')488 const asPath = await browser489 .elementByCss('#as-path-link-no-as').click()490 .waitForElementByCss('.as-path-content')491 .elementByCss('.as-path-content').text()492 expect(asPath).toBe('/nav/as-path')493 browser.close()494 })495 })496 describe('with next/router', () => {497 it('should show the correct asPath', async () => {498 const browser = await webdriver(context.appPort, '/nav')499 const asPath = await browser500 .elementByCss('#as-path-using-router-link').click()501 .waitForElementByCss('.as-path-content')502 .elementByCss('.as-path-content').text()503 expect(asPath).toBe('/nav/as-path-using-router')504 browser.close()505 })506 })507 describe('with next/link', () => {508 it('should use pushState with same href and different asPath', async () => {509 let browser510 try {511 browser = await webdriver(context.appPort, '/nav/as-path-pushstate')512 await browser.elementByCss('#hello').click().waitForElementByCss('#something-hello')513 const queryOne = JSON.parse(await browser.elementByCss('#router-query').text())514 expect(queryOne.something).toBe('hello')515 await browser.elementByCss('#same-query').click().waitForElementByCss('#something-same-query')516 const queryTwo = JSON.parse(await browser.elementByCss('#router-query').text())517 expect(queryTwo.something).toBe('hello')518 await browser.back().waitForElementByCss('#something-hello')519 const queryThree = JSON.parse(await browser.elementByCss('#router-query').text())520 expect(queryThree.something).toBe('hello')521 await browser.elementByCss('#else').click().waitForElementByCss('#something-else')522 await browser.elementByCss('#hello2').click().waitForElementByCss('#nav-as-path-pushstate')523 await browser.back().waitForElementByCss('#something-else')524 const queryFour = JSON.parse(await browser.elementByCss('#router-query').text())525 expect(queryFour.something).toBe(undefined)526 } finally {527 if (browser) {528 browser.close()529 }530 }531 })532 it('should detect asPath query changes correctly', async () => {533 let browser534 try {535 browser = await webdriver(context.appPort, '/nav/as-path-query')536 await browser.elementByCss('#hello').click().waitForElementByCss('#something-hello-something-hello')537 const queryOne = JSON.parse(await browser.elementByCss('#router-query').text())538 expect(queryOne.something).toBe('hello')539 await browser.elementByCss('#hello2').click().waitForElementByCss('#something-hello-something-else')540 const queryTwo = JSON.parse(await browser.elementByCss('#router-query').text())541 expect(queryTwo.something).toBe('else')542 } finally {543 if (browser) {544 browser.close()545 }546 }547 })548 })549 })550 describe('runtime errors', () => {551 it('should show react-error-overlay when a client side error is thrown inside a component', async () => {552 let browser553 try {554 browser = await webdriver(context.appPort, '/error-inside-browser-page')555 await waitFor(3000)556 const text = await getReactErrorOverlayContent(browser)557 expect(text).toMatch(/An Expected error occurred/)558 expect(text).toMatch(/pages\/error-inside-browser-page\.js:5/)559 } finally {560 if (browser) {561 browser.close()562 }563 }564 })565 it('should show react-error-overlay when a client side error is thrown outside a component', async () => {566 let browser567 try {568 browser = await webdriver(context.appPort, '/error-in-the-browser-global-scope')569 await waitFor(3000)570 const text = await getReactErrorOverlayContent(browser)571 expect(text).toMatch(/An Expected error occurred/)572 expect(text).toMatch(/error-in-the-browser-global-scope\.js:2/)573 } finally {574 if (browser) {575 browser.close()576 }577 }578 })579 })580 describe('with 404 pages', () => {581 it('should 404 on not existent page', async () => {582 const browser = await webdriver(context.appPort, '/non-existent')583 expect(await browser.elementByCss('h1').text()).toBe('404')584 expect(await browser.elementByCss('h2').text()).toBe('This page could not be found.')585 browser.close()586 })587 it('should 404 for <page>/', async () => {588 const browser = await webdriver(context.appPort, '/nav/about/')589 expect(await browser.elementByCss('h1').text()).toBe('404')590 expect(await browser.elementByCss('h2').text()).toBe('This page could not be found.')591 browser.close()592 })593 it('should should not contain a page script in a 404 page', async () => {594 const browser = await webdriver(context.appPort, '/non-existent')595 const scripts = await browser.elementsByCss('script[src]')596 for (const script of scripts) {597 const src = await script.getAttribute('src')598 expect(src.includes('/non-existent')).toBeFalsy()599 }600 browser.close()601 })602 })603 describe('updating head while client routing', () => {604 it('should update head during client routing', async () => {605 let browser606 try {607 browser = await webdriver(context.appPort, '/nav/head-1')608 expect(await browser.elementByCss('meta[name="description"]').getAttribute('content')).toBe('Head One')609 await browser.elementByCss('#to-head-2').click().waitForElementByCss('#head-2')610 expect(await browser.elementByCss('meta[name="description"]').getAttribute('content')).toBe('Head Two')611 await browser.elementByCss('#to-head-1').click().waitForElementByCss('#head-1')612 expect(await browser.elementByCss('meta[name="description"]').getAttribute('content')).toBe('Head One')613 } finally {614 if (browser) {615 browser.close()616 }617 }618 })619 })620 it('should not error on module.exports + polyfills', async () => {621 let browser622 try {623 browser = await webdriver(context.appPort, '/read-only-object-error')624 expect(await browser.elementByCss('body').text()).toBe('this is just a placeholder component')625 } finally {626 if (browser) {627 browser.close()628 }629 }630 })631 it('should work on nested /index/index.js', async () => {632 const browser = await webdriver(context.appPort, '/nested-index/index')633 expect(await browser.elementByCss('p').text()).toBe('This is an index.js nested in an index/ folder.')634 browser.close()635 })636 })...

Full Screen

Full Screen

webexChange.js

Source:webexChange.js Github

copy

Full Screen

...19 const page = await browser.newPage();20 // navigate to webex21 await page.goto("https://rensselaer.webex.com/").catch(() => {22 page.close();23 browser.close();24 console.log("Connection error!")25 process.exit(-1);26 });27 // click login button28 await Promise.all([29 page.waitForSelector("#IDToken1"),30 page.click("#guest_signin_split_button-trigger > div > button:nth-child(1)")31 ]).catch(error => {32 page.close();33 browser.close();34 console.log("Failed to click login button!")35 process.exit(-1);36 });37 // enter email38 await page.type("#IDToken1", email).catch(error => {39 page.close();40 browser.close();41 console.log("Failed to type email!")42 process.exit(-1);43 });44 await Promise.all([45 page.waitForSelector("#username"),46 page.click("#IDButton2")47 ]).catch(error => {48 page.close();49 browser.close();50 console.log("Incorrect email!")51 process.exit(-1);52 });53 // login54 await page.type("#username", uname).catch(error => {55 page.close();56 browser.close();57 console.log("Failed to type username!")58 process.exit(-1);59 });60 await page.type("#password", pword).catch(error => {61 page.close();62 browser.close();63 console.log("Failed to type password!")64 process.exit(-1);65 });66 await Promise.all([67 page.waitForSelector("#main_top_menu > div.nav_bar > div.top_nav > div.nav_t"),68 page.click("#homepage > div > div > div > form > button")69 ]).catch(error => {70 page.close();71 browser.close();72 console.log("Incorrect Username or Password!")73 process.exit(-1);74 });75 // nav to profile edit76 await page.goto("https://rensselaer.webex.com/webappng/sites/rensselaer/myprofile/home").catch(error => {77 page.close();78 browser.close();79 console.log("Failed to access namechange page!")80 process.exit(-1);81 });82 // open popup83 const popupPromise = new Promise(x => page.once('popup', x));84 await page.click("#viewMyProfile-changeMyProfile-Button").catch(error => {85 page.close();86 browser.close();87 console.log("Failed to open popup!")88 process.exit(-1);89 });90 const popup = await popupPromise;91 // edit name92 await popup.waitForSelector("body > main > article > section:nth-child(1) > a:nth-child(3)").catch(error => {93 page.close();94 browser.close();95 console.log("Failed to access namechange page!")96 process.exit(-1);97 });98 await Promise.all([99 popup.waitForSelector("body > main > article > section > div.row > div:nth-child(2) > input"),100 popup.click("body > main > article > section:nth-child(1) > a:nth-child(3)")101 ]).catch(error => {102 page.close();103 browser.close();104 console.log("Failed to access namechange page!")105 process.exit(-1);106 });107 await popup.evaluate( (pname) => {document.querySelector("body > main > article > section > div.row > div:nth-child(2) > input").value=pname}, pname).catch(error => {108 page.close();109 browser.close();110 console.log("Failed to submit namechange!")111 process.exit(-1);112 });113 await popup.click("body > main > article > section > div.form-actions > button").catch(error => {114 page.close();115 browser.close();116 console.log("Failed to submit namechange!")117 process.exit(-1);118 });119 await page.close();120 await browser.close();...

Full Screen

Full Screen

internal-df-browser-close-util.js

Source:internal-df-browser-close-util.js Github

copy

Full Screen

1/**2 * This javascript file is built to listen to browser window/tab close event and take action (callback) accordingly3 */4define(['knockout',5 'jquery'6 ],7 function(ko, $)8 {9 function InternalBrowserCloseUtility(){10 var self = this;11 self.isBrowserCloseEvent = true;12 self.action = null;13 function browserCloseEventListener(e) {14 if (self.isBrowserCloseEvent) {15 if(!e) {16 e = window.event;17 }18 //e.cancelBubble is supported by IE - this will kill the bubbling process.19 e.cancelBubble = true;20 //e.stopPropagation works in Firefox.21 if (e.stopPropagation) {22 e.stopPropagation();23 }24 if ($.isFunction(self.action)){25 self.action();26 }27 //for Chrome and Safari28 }29 }30 self.hookupBrowserCloseEvent = function(callback){31 self.action = callback;32 window.onbeforeunload=browserCloseEventListener;33 /* Important*34 // Attach the event keypress to exclude the refresh (F5 for windows, command+R for mac )35 // comment below, for no generic way to handle refresh event across different browsers/OS36 // so refresh will be treated browser winow close now37 */38 // Attach the event: "click" for all links in the page39 $("a").bind("click", function() {40 self.isBrowserCloseEvent=false;41 });42 // Attach the event: "submit" for all forms in the page43 $("form").bind("submit", function() {44 self.isBrowserCloseEvent=false;45 });46 // Attach the event: "click" for all inputs in the page47 $("input[type=submit]").bind("click", function() {48 self.isBrowserCloseEvent=false;49 });50 };51 }52 return new InternalBrowserCloseUtility();53 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require("qawolf");2const browser = await qawolf.launch();3const puppeteer = require("puppeteer");4const browser = await puppeteer.launch();5const playwright = require("playwright");6const browser = await playwright.chromium.launch();7const webdriverio = require("webdriverio");8const browser = await webdriverio.remote();9const { Builder } = require("selenium-webdriver");10const browser = await new Builder().forBrowser("chrome").build();11const testcafe = require("testcafe");12const browser = await testcafe.createBrowserConnection();13const webdriver = require("selenium-webdriver");14const browser = await new webdriver.Builder().forBrowser("chrome").build();15const cypress = require("cypress");16const browser = await cypress.launch();17const nightwatch = require("nightwatch");18const browser = await nightwatch.launch();19const protractor = require("protractor");20const browser = await protractor.launch();21const codeceptjs = require("codeceptjs");22const browser = await codeceptjs.launch();23const nightmare = require("nightmare");24const browser = await nightmare.launch();25const casperjs = require("casperjs");26const browser = await casperjs.launch();27const zombie = require("zombie");28const browser = await zombie.launch();29const spectron = require("spectron");30const browser = await spectron.launch();31const capybara = require("capybara");32const browser = await capybara.launch();33const capybara_webkit = require("capybara-webkit");

Full Screen

Using AI Code Generation

copy

Full Screen

1const qawolf = require('qawolf');2qawolf.register();3describe('test', () => {4 let browser;5 let page;6 beforeAll(async () => {7 browser = await qawolf.launch();8 });9 afterAll(async () => {10 await browser.close();11 });12 beforeEach(async () => {13 page = await browser.newPage();14 });15 afterEach(async () => {16 await qawolf.stopVideos();17 await page.close();18 });19 test('test', async () => {20 await page.type('[name="q"]', 'qawolf');21 await page.click('[name="btnK"]');22 await page.waitForSelector('h3');23 await qawolf.create();24 });25});261 test passed (1s)

Full Screen

Using AI Code Generation

copy

Full Screen

1import { launch } from 'qawolf';2import { test } from 'qawolf';3describe('test', () => {4 let browser;5 beforeAll(async () => {6 browser = await launch();7 });8 afterAll(async () => {9 await browser.close();10 });11 it('test', async () => {12 const context = await browser.newContext();13 const page = await context.newPage();14 await test('test', page);15 });16});17import { launch } from 'qawolf';18import { test } from 'qawolf';19describe('test', () => {20 let browser;21 beforeAll(async () => {22 browser = await launch();23 });24 afterAll(async () => {25 await browser.close();26 });27 it('test', async () => {28 const context = await browser.newContext();29 const page = await context.newPage();30 await test('test', page);31 });32});33import { launch } from 'qawolf';34import { test } from 'qawolf';35describe('test', () => {36 let browser;37 beforeAll(async () => {38 browser = await launch();39 });40 afterAll(async () => {41 await browser.close();42 });43 it('test', async () => {44 const context = await browser.newContext();45 const page = await context.newPage();46 await test('test', page);47 });48});49import { launch } from 'qawolf';50import { test } from 'qawolf';51describe('test', () => {52 let browser;53 beforeAll(async () => {54 browser = await launch();55 });56 afterAll(async () => {57 await browser.close();58 });59 it('test', async () => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { browser } = require("qawolf");2const { closeBrowser } = require("qawolf/src/browser");3const puppeteer = require("puppeteer");4const browser = await puppeteer.launch();5const playwright = require("playwright");6const browser = await playwright.chromium.launch();7const createTestCafe = require("testcafe");8const testcafe = await createTestCafe("localhost", 1337, 1338);9const runner = testcafe.createRunner();10const { remote } = require("webdriverio");11const browser = await remote({12 capabilities: {13 },14});15const cypress = require("cypress");16const cypress = cypress.run();17const { Builder, By, Key, until } = require("selenium-webdriver");18const driver = new Builder().forBrowser("chrome").build();19const { Client } = require("nightwatch-api");20const client = new Client();21const { browser } = require("protractor");22const karate = require("karate");23const testium = require("testium");24const capybara = require("capybara");25const wdio = require("wdio");26const webdriver = require("webdriver");27const puppeteer = require("puppeteer-core");28const playwright = require("playwright-core");29const testcafe = require("testcafe-browser-provider-electron");30const { Builder, By, Key, until } = require("selenium-webdriver");

Full Screen

Using AI Code Generation

copy

Full Screen

1const { launch } = require("qawolf");2const selectors = require("./selectors/test");3const browser = await launch();4const page = await browser.newPage();5await page.click(selectors[0]);6await page.type(selectors[0], "hello");7await page.click(selectors[0]);8await page.type(selectors[0], "hello world");9await page.click(selectors[0]);10await page.type(selectors[0], "hello world");11await page.click(selectors[0]);12await page.type(selectors[0], "hello world");13await browser.close();14const { launch } = require("qawolf");15const selectors = require("./selectors/test");16const browser = await launch();17const page = await browser.newPage();18await page.waitForSelector(selectors[0]);19const { launch } = require("qawolf");20const selectors = require("./selectors/test");21const browser = await launch();22const page = await browser.newPage();23await page.waitForSelector(selectors[0]);

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