How to use setTimeouts method in Webdriverio

Best JavaScript code snippet using webdriverio-monorepo

test.js

Source:test.js Github

copy

Full Screen

...8 const driver = await new webdriver.Builder().forBrowser('chrome').build(); 9 //your code inside this block10 await driver.get('http://localhost:3500/tda/'); 11 driver.manage().window().maximize()12 await driver.manage().setTimeouts( { implicit: 10000 } );13 14 await driver.findElement(By.xpath('//*[@id="tda-trace-view"]')).click();15 16 await driver.manage().setTimeouts( { implicit: 10000 } );17 await driver.findElement(By.xpath('//*[@id="miApplication"]/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-header/div/div[1]/button[1]')).click();18 const day = await driver.findElement(By.xpath('//*[@id="cdk-overlay-0"]/nz-modal-container/div/div/div[2]/tda-dataset-config/div/div[1]/div/input')).click();19 await driver.manage().setTimeouts( { implicit: 10000 } );20 await driver.findElement(By.xpath('//*[@id="cdk-overlay-0"]/nz-modal-container/div/div/div[2]/tda-dataset-config/div/div[1]/div/input')).sendKeys('150');21 await driver.manage().setTimeouts( { implicit: 10000 } );22 // Equipment23 await driver.findElement(By.xpath('//*[@id="cdk-overlay-0"]/nz-modal-container/div/div/div[2]/tda-dataset-config/div/div[3]/div[6]/div/nz-select/nz-select-top-control/nz-select-placeholder')).click();24 await driver.manage().setTimeouts( { implicit: 10000 } );25 await driver.findElement(By.xpath('//*[@id="cdk-overlay-1"]/nz-option-container/div/cdk-virtual-scroll-viewport/div[1]/nz-option-item[1]/div')).click();26 await driver.findElement(By.xpath('//*[@id="cdk-overlay-1"]/nz-option-container/div/cdk-virtual-scroll-viewport/div[1]/nz-option-item[4]/div[1]')).click();27 await driver.findElement(By.xpath('//*[@id="cdk-overlay-0"]/nz-modal-container/div/div/div[2]/tda-dataset-config/div/div[3]/div[6]/div/nz-select/nz-select-top-control')).click();28 await driver.manage().setTimeouts( { implicit: 10000 } );29 // Chamber30 await driver.manage().setTimeouts( { implicit: 20000 } );31 await driver.findElement(By.xpath('//*[@id="cdk-overlay-0"]/nz-modal-container/div/div/div[2]/tda-dataset-config/div/div[3]/div[7]/div/nz-select/nz-select-top-control/nz-select-placeholder')).click();32 await driver.findElement(By.xpath('//*[@id="cdk-overlay-2"]/nz-option-container/div/cdk-virtual-scroll-viewport/div[1]/nz-option-item[1]/div')).click();33 await driver.manage().setTimeouts( { implicit: 20000 } );34 await driver.findElement(By.xpath('//*[@id="cdk-overlay-0"]/nz-modal-container/div/div/div[2]/tda-dataset-config/div/div[3]/div[7]/div/nz-select/nz-select-top-control')).click();35 // Recipe36 await driver.manage().setTimeouts( { implicit: 20000 } );37 await driver.findElement(By.xpath('//*[@id="cdk-overlay-0"]/nz-modal-container/div/div/div[2]/tda-dataset-config/div/div[3]/div[9]/button')).click();38 await driver.manage().setTimeouts( { implicit: 30000 } );39 await driver.findElement(By.xpath('//*[@id="ag-82-input"]')).click();40 await driver.manage().setTimeouts( { implicit: 30000 } );41 await driver.findElement(By.xpath('//*[@id="cdk-overlay-3"]/div/ul/li/button')).click();42 await driver.findElement(By.xpath('//*[@id="cdk-overlay-0"]/nz-modal-container/div/div/div[3]/button[2]')).click();43 // Parameter44 await driver.manage().setTimeouts( { implicit: 30000 } );45 await driver.findElement(By.xpath('//*[@id="ag-241-input"]')).click();46 await driver.findElement(By.xpath('//*[@id="ag-237-input"]')).click();47 // Step48 await driver.manage().setTimeouts( { implicit: 20000 } );49 await driver.findElement(By.xpath('//*[@id="miApplication"]/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-sider/div/tda-trace-view-condition-config/div[2]/div/form/nz-form-item/nz-form-control/div/div/input')).click();50 await driver.findElement(By.xpath('//*[@id="miApplication"]/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-sider/div/tda-trace-view-condition-config/div[2]/div/form/nz-form-item/nz-form-control/div/div/input')).sendKeys('1,2,3,4');51 // Filter52 await driver.manage().setTimeouts( { implicit: 20000 } );53 await driver.findElement(By.xpath('//*[@id="miApplication"]/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-sider/div/tda-trace-view-condition-config/div[1]/h3/button')).click();54 // await driver.manage().setTimeouts( { implicit: 10000 } );55 // await driver.findElement(By.xpath('//*[@id="cdk-overlay-4"]/nz-modal-container/div/div/div[2]/tda-trace-view-context-filter/div/div[1]/nz-radio-group/label[2]/span[1]/input')).click();56 await driver.manage().setTimeouts( { implicit: 20000 } );57 await driver.findElement(By.xpath('//*[@id="ag-501-input"]')).click();58 await driver.findElement(By.xpath('//*[@id="cdk-overlay-4"]/nz-modal-container/div/div/div[3]/button[2]')).click();59 // Run60 await driver.manage().setTimeouts( { implicit: 20000 } );61 await driver.findElement(By.xpath('//*[@id="miApplication"]/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-header/div/div[1]/button[2]')).click();62 // chart option63 await driver.manage().setTimeouts( { implicit: 10000 } );64 await driver.findElement(By.xpath('//*[@id="miApplication"]/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-content/tda-trace-view-main/div/nz-tabset/div/div/div[1]/div/div[1]/div/button[1]')).click();65 await driver.findElement(By.xpath('//*[@id="cdk-overlay-5"]/div/div/label/span[1]/input')).click();66 await driver.findElement(By.xpath('//*[@id="cdk-overlay-5"]/div/div/div[2]/input[1]')).click();67 await driver.findElement(By.xpath('//*[@id="cdk-overlay-5"]/div/div/div[2]/input[1]')).clear();68 await driver.findElement(By.xpath('//*[@id="cdk-overlay-5"]/div/div/div[2]/input[1]')).sendKeys('-5');69 await driver.manage().setTimeouts( { implicit: 10000 } );70 await driver.findElement(By.xpath('//*[@id="cdk-overlay-5"]/div/div/div[3]/button[2]')).click();71 await driver.manage().setTimeouts( { implicit: 10000 } );72 await driver.findElement(By.xpath('//*[@id="miApplication"]/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-content/tda-trace-view-main/div/nz-tabset/div/div/div[1]/div/div[1]/div/button[1]')).click();73 await driver.findElement(By.xpath('//*[@id="cdk-overlay-5"]/div/div/label/span[1]/input')).click();74 await driver.findElement(By.xpath('//*[@id="cdk-overlay-5"]/div/div/div[3]/button[2]')).click();75 76 // Show Step Filter77 await driver.manage().setTimeouts( { implicit: 10000 } );78 await driver.findElement(By.xpath('//*[@id="miApplication"]/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-content/tda-trace-view-main/div/nz-tabset/div/div/div[1]/div/div[1]/div/button[3]')).click();79 await driver.manage().setTimeouts( { implicit: 20000 } );80 await driver.findElement(By.xpath('//*[@id="cdk-overlay-6"]/div/div/div[2]/div/div[2]/div/div[1]/div[2]/label/span[1]/input')).click();81 await driver.manage().setTimeouts( { implicit: 10000 } );82 await driver.findElement(By.xpath('//*[@id="cdk-overlay-6"]/div/div/div[2]/div/div[2]/div/div[2]/button')).click();83 // Trace Context List84 await driver.manage().setTimeouts( { implicit: 10000 } );85 await driver.findElement(By.xpath('//*[@id="miApplication"]/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-content/tda-trace-view-main/div/nz-tabset/div/div/div[1]/div/div[1]/div/button[4]')).click();86 await driver.manage().setTimeouts( { implicit: 10000 } );87 await driver.findElement(By.xpath('//*[@id="ag-664-input"]')).click();88 await driver.manage().setTimeouts( { implicit: 20000 } );89 await driver.findElement(By.xpath('/html/body/div/div[2]/div/nz-modal-container/div/div/div[3]/button[2]')).click();90 // View Data91 await driver.manage().setTimeouts( { implicit: 10000 } );92 await driver.findElement(By.xpath('//*[@id="miApplication"]/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-content/tda-trace-view-main/div/nz-tabset/div/div/div[1]/div/div[1]/div/button[5]')).click();93 await driver.manage().setTimeouts( { implicit: 10000 } );94 await driver.findElement(By.xpath('/html/body/div/div[2]/div/nz-modal-container/div/div/div[3]/button[2]')).click();95 // show legend96 await driver.manage().setTimeouts( { implicit: 10000 } );97 await driver.findElement(By.xpath('//*[@id="miApplication"]/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-content/tda-trace-view-main/div/nz-tabset/div/div/div[1]/div/div[1]/div/button[2]')).click();98 await driver.manage().setTimeouts( { implicit: 10000 } );99 await driver.findElement(By.xpath('/html/body/div/div[2]/div/div/div/ul/li/label/span[1]/input')).click();100 await driver.manage().setTimeouts( { implicit: 10000 } );101 await driver.findElement(By.xpath('/html/body/div/div[2]/div/div/div/ul/li/label/span[1]/input')).click();102 // await driver.manage().setTimeouts( { implicit: 20000 } );103 // await driver.findElement(By.xpath('//*[@id="cdk-overlay-7"]/div/div/ul/li/label/span[1]/input')).click();104 await driver.manage().setTimeouts( { implicit: 10000 } );105 // await driver.findElement(By.xpath('//*[@id="miApplication"]/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-content/tda-trace-view-main/div/nz-tabset/div/div/div[1]/div/div[1]/div/button[2]')).click();106 await driver.findElement(By.xpath('//*[@id="miApplication"]/body/div/div[1]')).click();107 // groupview108 await driver.manage().setTimeouts( { implicit: 10000 } );109 await driver.findElement(By.xpath('//*[@id="miApplication"]/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-content/tda-trace-view-main/div/nz-tabset/nz-tabs-nav/div/div/div[2]/div')).click();110 // await driver.findElement(By.xpath('')).click();111 // chamber to chamber112 // await driver.manage().setTimeouts( { implicit: 10000 } );113 // await driver.findElement(By.xpath('//*[@id="ag-487-input"]')).click();114 // await driver.findElement(By.xpath('//*[@id="ag-489-input"]')).click();115 // await driver.manage().setTimeouts( { implicit: 10000 } );116 // await driver.findElement(By.xpath('//*[@id="miApplication"]/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-summary/div/nz-layout/div[2]/nz-layout/nz-content/div/nz-tabset/div/div/div[2]/div/tda-summary-group-main/div[2]/div[1]/div[1]/dl/dd[7]/button')).click();117 // // expand118 // await driver.manage().setTimeouts( { implicit: 10000 } );119 // await driver.findElement(By.xpath('//*[@id="idx"]/div[1]/span/i')).click();120 // await driver.findElement(By.xpath('//*[@id="cdk-overlay-5"]/nz-modal-container/div/div/div[3]/button[2]')).click();121 122 // recipe to recipe123 await driver.manage().setTimeouts( { implicit: 10000 } );124 await driver.findElement(By.xpath('/html/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-content/tda-trace-view-main/div/nz-tabset/div/div/div[2]/div/tda-group-main/div[1]/div/button')).click();125 await driver.findElement(By.xpath('/html/body/div/div[2]/div/div/ul/li[2]')).click();126 await driver.findElement(By.xpath('//*[@id="ag-617-input"]')).click();127 await driver.manage().setTimeouts( { implicit: 10000 } );128 await driver.findElement(By.xpath('/html/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-content/tda-trace-view-main/div/nz-tabset/div/div/div[2]/div/tda-group-main/div[2]/div[1]/div[1]/dl/dd[7]/button')).click();129 // Step Filter130 await driver.manage().setTimeouts( { implicit: 10000 } );131 await driver.findElement(By.xpath('//*[@id="miApplication"]/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-content/tda-trace-view-main/div/nz-tabset/div/div/div[2]/div/tda-group-main/div[2]/div[2]/div/tda-group-recipe-chart/div[1]/div/button[2]')).click();132 await driver.manage().setTimeouts( { implicit: 10000 } );133 await driver.findElement(By.xpath('/html/body/div/div/div/div/div/div[2]/div/div[2]/div/div[1]/div[2]/label/span[1]/input')).click();134 await driver.manage().setTimeouts( { implicit: 10000 } );135 await driver.findElement(By.xpath('/html/body/div/div/div/div/div/div[2]/div/div[2]/div/div[2]/button')).click();136 // X Axis137 await driver.manage().setTimeouts( { implicit: 10000 } );138 await driver.findElement(By.xpath('/html/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-content/tda-trace-view-main/div/nz-tabset/div/div/div[2]/div/tda-group-main/div[2]/div[2]/div/tda-group-recipe-chart/div[2]/div/div[1]/div/span[1]/select')).click();139 await driver.manage().setTimeouts( { implicit: 20000 } );140 await driver.findElement(By.xpath('/html/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-content/tda-trace-view-main/div/nz-tabset/div/div/div[2]/div/tda-group-main/div[2]/div[2]/div/tda-group-recipe-chart/div[2]/div/div[1]/div/span[1]/select/option[2]')).click();141 await driver.manage().setTimeouts( { implicit: 10000 } );142 await driver.findElement(By.xpath('/html/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-content/tda-trace-view-main/div/nz-tabset/div/div/div[2]/div/tda-group-main/div[2]/div[2]/div/tda-group-recipe-chart/div[2]/div/div[1]/div/span[1]/select')).click();143 // await driver.findElement(By.xpath('//*[@id="cdk-overlay-12"]/div/div/div[2]/div/div[2]/div/div[2]/button')).click();144 // show lengend145 await driver.manage().setTimeouts( { implicit: 10000 } );146 await driver.findElement(By.xpath('//*[@id="miApplication"]/body/tda-root/mia-home/mia-body/nz-spin/div/div/nz-tabset/div/div/div/mia-page-layer/div/tda-trace-view/div/div[2]/nz-layout/nz-content/tda-trace-view-main/div/nz-tabset/div/div/div[2]/div/tda-group-main/div[2]/div[2]/div/tda-group-recipe-chart/div[1]/div/button[1]')).click();147 await driver.findElement(By.xpath('//*[@id="cdk-overlay-12"]/div/div/ul/li/label/span[1]/input')).click();148 await driver.manage().setTimeouts( { implicit: 10000 } );149 await driver.findElement(By.xpath('/html/body/div/div[1]')).click();150 151 152 // setTimeout(async () => { 153 // await driver.quit(); 154 // process.exit(0); }155 // , 3000); 156})();...

Full Screen

Full Screen

movieCrawler.js

Source:movieCrawler.js Github

copy

Full Screen

...28 // return new Builder().withCapabilities(Capabilities.chrome()).setChromeOptions(new chrome.Options().headless()).build();29}30const getMListView = async (driver) => {31 await driver.get('https://www.kobis.or.kr/kobis/business/mast/mvie/searchMovieList.do');32 await driver.manage().setTimeouts(implicit_wait);33 await (driver.findElement(By.css(".slt_comm #sOrderBy > option:nth-child(4)"))).click();34 await driver.manage().setTimeouts(implicit_wait);35 return await driver.findElements(By.css("#content > div.rst_sch > table > tbody > tr"));36}37const findNumIdxInArrView = async (arrView, num) => {38 let arr = [];39 for(const p of arrView) arr.push(Number(await p.getText()));40 let idx = arr.findIndex((v) => v == num);41 return idx;42}43(async function example() {44 const driver = await loadChromeDriver();45 try {46 await dbInit();47 let mListView = await getMListView(driver);48 while(true) {49 await driver.manage().setTimeouts(implicit_wait);50 let pageBtns = await driver.findElements(By.css("#pagingForm > div > ul > li a"));51 await driver.manage().setTimeouts(implicit_wait);52 let numArr = [];53 for(const p of pageBtns) numArr.push(Number(await p.getText()));54 for(let btn of numArr) {55 await driver.manage().setTimeouts(implicit_wait);56 mListView = await driver.findElements(By.css("#content > div.rst_sch > table > tbody > tr"));57 await driver.manage().setTimeouts(implicit_wait);58 pageBtns = await driver.findElements(By.css("#pagingForm > div > ul > li a"));59 await driver.manage().setTimeouts(implicit_wait);60 let idx = await findNumIdxInArrView(pageBtns, btn);61 await driver.manage().setTimeouts(implicit_wait);62 await driver.sleep(2000);63 try {await pageBtns[idx].click();} 64 catch (error) { console.log("클릭 x");}65 66 console.log("btn: "+ btn);67 await driver.manage().setTimeouts(implicit_wait);68 for(const movies of mListView.division(10)) {69 await Promise.all(movies.map( async (v,i) => await movieInfoByWebDriver(btn, i)));70 }71 if(idx >= 9) {72 try {73 await driver.findElement(By.css("#pagingForm > div > a.btn.next")).click();74 await driver.sleep(2000);75 pageBtns = await driver.findElements(By.css("#pagingForm > div > ul > li a"));76 await driver.manage().setTimeouts(implicit_wait);77 } catch (error) {78 console.log("get out");79 break; 80 }81 }82 }83 }84 } catch (error) {85 console.log(error);86 } finally {87 console.log("✨ finished ✨");88 driver.quit();89 }90})();91const getMovieJSON = async (listView, driver, i) => {92 try {93 var urlArr;94 let title = listView[i].findElement(By.css("td:nth-child(1) > span > a"));95 let mJson = {96 "movie_id": (await (listView[i].findElement(By.css("td:nth-child(3) > span"))).getText()).trim(),97 "title": (await title.getText()).trim(),98 "eng_title": (await listView[i].findElement(By.css("td:nth-child(2) > span > a")).getText()).trim(),99 "production_year": (await listView[i].findElement(By.css("td:nth-child(4) > span")).getAttribute("title")).trim(),100 "production_country": (await listView[i].findElement(By.css("td:nth-child(5) > span")).getAttribute("title")).trim(),101 "size_type": (await listView[i].findElement(By.css("td:nth-child(6) > span")).getAttribute("title")).trim(),102 "genore": (await listView[i].findElement(By.css("td:nth-child(7) > span")).getAttribute("title")).trim(),103 "production_status": (await listView[i].findElement(By.css("td:nth-child(8) > span")).getAttribute("title")).trim(),104 "poster_img": null, "release_date": "", "updated_date": null, "memo": null,105 "director": (await listView[i].findElement(By.css("td:nth-child(9) > span")).getAttribute("title")).trim(),106 "actor": {}, "story": "",107 "href": ""108 };109 await driver.manage().setTimeouts(implicit_wait);110 await title.click();111 await driver.sleep(2000);112 113 mJson.href = await (await driver.findElement(By.css(".item_tab.basic > div.ovf.info.info1 > a"))).getAttribute("href");114 urlArr = mJson.href.split("/"); 115 let imgLink = `${Date.now()}_${urlArr[urlArr.length-1]}`;116 if(urlArr[urlArr.length-1] == "searchMovieList.do#") { mJson.poster_img = "";} 117 else { mJson.poster_img = imgLink; }118 119 mJson.memo = (await driver.findElement(By.css(".item_tab.basic > div.ovf.info.info1 > dl > dd:nth-child(8)")).getText()).trim();120 mJson.updated_date = (await driver.findElement(By.css(".item_tab.basic > div.bar_top > div")).getText()).trim().split("최종수정: ")[1].split(" 수정요청")[0];121 await driver.manage().setTimeouts(implicit_wait);122 let dts = await driver.findElements(By.css(".item_tab.basic dl > *"));123 await driver.manage().setTimeouts(implicit_wait);124 let dtNum = 0;125 for(let dt of dts) {126 dtName = (await dt.getText()).trim();127 if(dtName == "개봉일") {128 mJson.release_date = (await dts[dtNum+1].getText());129 break;130 }131 dtNum++;132 };133 try {mJson.story = (await driver.findElement(By.css(".item_tab.basic p.desc_info")).getText()).trim(); } 134 catch (error) {mJson.story = "";}135 // await console.log(mJson);136 return mJson;137 } catch (error) {138 console.log("movieJSON ERR - ", error);139 return {error: error}140 }141}142const pushMovieQuery = async (mJson) => {143 try {144 // 원래 있는 데이터 업데이트145 res = await dbQuery("GET", "SELECT * FROM "+tableName+" WHERE movie_id = ?", [mJson.movie_id]);146 if(res.row.length > 0) {147 // console.log(res.row[0].updated_date, mJson.updated_date);148 if(res.row[0].updated_date != mJson.updated_date) {149 let sql = "UPDATE "+tableName+" SET `title`=?,`eng_title`=?,`production_year`=?,`production_country`=?,`size_type`=?,`genore`=?,`production_status`=?,`poster_img`=?,`release_date`=?,`updated_date`=?,`memo`=?,`director`=?,`actor`=?,`story`=? WHERE `movie_id`=?";150 let imgUrl;151 if(res.row[0].poster_img == "") imgUrl = mJson.poster_img;152 else imgUrl = res.row[0].poster_img;153 let params = [mJson.title, mJson.eng_title, mJson.production_year, mJson.production_country, mJson.size_type, mJson.genore,154 mJson.production_status, imgUrl, mJson.release_date, mJson.updated_date, mJson.memo,155 mJson.director, JSON.stringify(mJson.actor), mJson.story, mJson.movie_id];156 let queryRes = await dbQuery("UPDATE", sql, params);157 if(!queryRes.error) {158 if(mJson.poster_img != "" && imgUrl == mJson.poster_img) {159 downloadImageToUrl(mJson.href, mJson.poster_img);160 }161 }162 console.log(" updated => " + mJson.movie_id);163 } else { console.log("no updated => "+ mJson.movie_id);}164 } else {165 let sql = "INSERT INTO "+tableName+" VALUES (?,?,?,?,?, ?,?,?,?,?, ?,?,?,?,?)";166 let params = [mJson.movie_id, mJson.title, mJson.eng_title, mJson.production_year, mJson.production_country,167 mJson.size_type, mJson.genore, mJson.production_status,mJson.poster_img, mJson.release_date,168 mJson.updated_date,mJson.memo,mJson.director,JSON.stringify(mJson.actor),mJson.story];169 let queryRes = await dbQuery("INSERT", sql, params);170 console.log(" inserted => " + mJson.movie_id);171 // console.log(queryRes);172 if(!queryRes.error) {173 if(mJson.poster_img != "") {174 downloadImageToUrl(mJson.href, mJson.poster_img);175 }176 }177 }178 179 // 180 } catch (error) {181 console.log("db ERR - ", error);182 }183}184const movieInfoByWebDriver = async (nowNum, i) => {185 const driver = await loadChromeDriver();186 // console.log(nowNum);187 try {188 await driver.get('https://www.kobis.or.kr/kobis/business/mast/mvie/searchMovieList.do');189 await driver.manage().setTimeouts(implicit_wait);190 await (driver.findElement(By.css(".slt_comm #sOrderBy > option:nth-child(4)"))).click();191 await driver.sleep(2000);192 while(true) {193 let pageBtns = await driver.findElements(By.css("#pagingForm > div > ul > li a"));194 await driver.manage().setTimeouts(implicit_wait);195 let idx = await findNumIdxInArrView(pageBtns, nowNum);196 if(idx >= 0) {197 await pageBtns[idx].click();198 await driver.sleep(2000);199 break;200 }201 let nextBtn = await driver.findElement(By.css("#pagingForm > div > a.btn.next"));202 await nextBtn.click();203 await driver.sleep(2000);204 }205 let mListView = await driver.findElements(By.css("#content > div.rst_sch > table > tbody > tr"));206 await driver.manage().setTimeouts(implicit_wait);207 let mJson = await getMovieJSON(mListView, driver, i);208 // console.log(mJson);209 if(!mJson.error) await pushMovieQuery(mJson);210 211 } catch (error) {212 console.log(error);213 } finally {214 try {215 await driver.close();216 await console.log("✨ one movie finished ✨");217 // 일반적으로 driver.close()브라우저를 닫고(드라이버 인스턴스는 그대로 driver.quit()유지됨) webdriver 인스턴스를 종료합니다.218 } catch (ter) {219 console.log(ter);220 }...

Full Screen

Full Screen

LastMinuteBet.js

Source:LastMinuteBet.js Github

copy

Full Screen

1const Env = require('../Env.js').Env;2const util = require('util');3function LastMinuteBet(matchbookApi, symfonyApi, saveData = false) {4 this.matchbookApi = matchbookApi;5 this.symfonyApi = symfonyApi;6 this.saveData = saveData;7 this.events = [];8 this.watch = function () {9 console.log("===================");10 const $this = this;11 const now = parseInt(new Date().getTime() / 1000);12 const nowTimeOut = new Date().getTime();13 let setTimeoutS = 1000;//s14 const data = [15 {name: "sport-ids", value: 24735152712200},16 {name: "after", value: (now - 1200)},17 ];18 console.log(1);19 $this.matchbookApi.getEventsView(data, function (events) {20 console.log(2);21 if (typeof events === "object" && Array.isArray(events.events)) {22 console.log(3);23 events.events = events.events.filter(x => x["allow-live-betting"] === true);24 }25 console.log(4);26 if ((typeof events === "object" && events.events.length > 0) || $this.events.length > 0) {27 console.log(5);28 let eventStart = 0;29 if (typeof events === "object" && events.events.length > 0) {30 console.log(51);31 eventStart = parseInt(new Date(events.events[0].start).getTime() / 1000);32 } else {33 console.log(52);34 events = {35 events: [],36 }37 }38 if ((eventStart - now < 70 && eventStart - now > 5) || $this.events.length > 0) {39 console.log(6);40 $this.addEventsToThisEvents(events.events, now, function () {41 console.log(7);42 $this.updateThisEvents(events.events, now, function () {43 console.log(8);44 const beforeTimeOut = new Date().getTime();45 console.log(setTimeoutS, beforeTimeOut, nowTimeOut, "before");46 setTimeoutS = setTimeoutS - (beforeTimeOut - nowTimeOut);47 console.log(setTimeoutS, "before2");48 if (setTimeoutS < 0) {49 setTimeoutS = 0;50 }51 setTimeout(function () {52 console.log(9);53 $this.watch();54 }, setTimeoutS);55 });56 });57 } else {58 console.log(10);59 setTimeoutS = 1000 * 60;60 console.log("timeOut1", setTimeoutS);61 setTimeout(function () {62 $this.watch();63 }, setTimeoutS);64 }65 } else {66 console.log(13, $this.events.length);67 if (events !== false) setTimeoutS = 60 * 1000;68 console.log("timeOut2", setTimeoutS);69 setTimeout(function () {70 $this.watch();71 }, setTimeoutS);72 }73 }, true);74 };75 this.updateThisEvents = function (events, now, callback) {76 const $this = this;77 const indexToDelete = [];78 console.log($this.events.length);79 $this.events.map(function (myEvent, indexEvent) {80 const event = events.find(x => x.id === myEvent.id);81 const time = myEvent.start - now;82 if (typeof event !== "undefined") console.log(typeof event, event.status, myEvent.name);83 else console.log(typeof event, myEvent.name);84 if (typeof event !== "undefined" && event.status === "open") {85 if (event["in-running-flag"] === true) {86 myEvent.runners.map(function (myRunner) {87 const market = event.markets[0];88 if (typeof market !== "undefined") {89 const runner = market.runners.find(x => x.id === myRunner.id);90 let push = {91 time: time,92 back: null,93 back2: null,94 lay: null,95 lay2: null,96 };97 if (typeof runner !== "undefined") {98 const backs = runner.prices.filter(x => x.side === "back");99 const lays = runner.prices.filter(x => x.side === "lay");100 if (backs.length > 0) {101 const back = backs.reduce(function (prev, current) {102 return (prev.odds > current.odds) ? prev : current103 });104 const back2 = backs.reduce(function (prev, current) {105 return (prev.odds < current.odds) ? prev : current106 });107 if (typeof back !== "undefined") {108 push.back = back.odds;109 }110 if (typeof back2 !== "undefined") {111 push.back2 = back2.odds;112 }113 }114 if (lays.length > 0) {115 const lay = lays.reduce(function (prev, current) {116 return (prev.odds < current.odds) ? prev : current117 });118 const lay2 = lays.reduce(function (prev, current) {119 return (prev.odds > current.odds) ? prev : current120 });121 if (typeof lay !== "undefined") {122 push.lay = lay.odds;123 }124 if (typeof lay2 !== "undefined") {125 push.lay2 = lay2.odds;126 }127 }128 myRunner.prices.push(push);129 } else {130 myRunner.prices.push(push);131 }132 }133 });134 }135 } else {136 if (typeof event !== "undefined") {137 console.log(indexEvent, "index to delete");138 indexToDelete.push(indexEvent);139 }140 }141 });142 indexToDelete.map(function (index) {143 const eventToSave = JSON.parse(JSON.stringify($this.events[index]));144 console.log("delete", $this.events[index].name);145 $this.events.splice(index, 1);146 $this.saveEvent(eventToSave);147 });148 callback();149 };150 this.saveEvent = function (event) {151 const $this = this;152 if ($this.saveData === true) {153 $this.symfonyApi.saveEvent(event, true);154 }155 };156 this.addEventsToThisEvents = function (events, now, callback) {157 const $this = this;158 events.map(function (event) {159 const eventStart = parseInt(new Date(event.start).getTime() / 1000);160 if (eventStart - now > 5 && eventStart - now < 70 && event["allow-live-betting"] === true) {161 if (typeof $this.events.find(x => x.id === event.id) === "undefined") {162 let newEvent = {163 id: event.id,164 name: event.name,165 start: eventStart,166 "category-id": event["category-id"],167 };168 newEvent.runners = [];169 event.markets[0].runners.map(function (runner) {170 if (runner.status === "open") {171 const newRunner = {172 id: runner.id,173 name: runner.name,174 prices: [],175 };176 newEvent.runners.push(newRunner);177 }178 });179 if (newEvent.runners.length > 0) {180 console.log(newEvent.name, "start to record soon");181 $this.events.push(newEvent);182 }183 }184 }185 });186 callback();187 };188}189module.exports = {190 LastMinuteBet,...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

...39}40async function installWallet(){41 try{42 await driver.get(`chrome-extension://${EXTENSION_ID}/home.html#initialize/welcome`);43 await driver.manage().setTimeouts({44 implicit: 3000, // 10 seconds45 });46 await driver.findElement(By.xpath('//button[text()="Get Started"]')).click();47 await driver.findElement(By.xpath('//button[text()="Import wallet"]')).click();48 await driver.findElement(By.xpath('//button[text()="No Thanks"]')).click();49 await driver.manage().setTimeouts({50 implicit: 2000, // 10 seconds51 });52 await driver.findElement(By.xpath('//input[@placeholder="Paste Secret Recovery Phrase from clipboard"]')).sendKeys(SECRET_RECOVERY_PHRASE);53 await driver.findElement(By.xpath('//input[@id="password"]')).sendKeys(NEW_PASSWORD);54 await driver.findElement(By.xpath('//input[@id="confirm-password"]')).sendKeys(NEW_PASSWORD);55 let checkboxList = await driver.findElements(By.xpath('//div[@role="checkbox"]'))56 await checkboxList[1].click();57 await driver.findElement(By.xpath('//div[@role="checkbox"]')).click();58 await driver.findElement(By.xpath('//button[@type="submit"]')).click();59 await driver.manage().setTimeouts({60 implicit: 10000, // 10 seconds61 });62 await driver.findElement(By.xpath('//button[text()="All Done"]')).click();63 await driver.get(`chrome-extension://${EXTENSION_ID}/home.html`);64 await driver.manage().setTimeouts({65 implicit: 1000, // 10 seconds66 });67 await driver.findElement(By.xpath('//button[@data-testid="popover-close"]')).click();68 69 await driver.findElement(By.className('identicon')).click();70 let account = await driver.findElement(By.className('account-menu'));71 72 let settingList = await account.findElements(By.className('account-menu__item account-menu__item--clickable'));73 await settingList[4].click();74 // await driver.wait(until.elementLocated(By.xpath('//div[@class="tab-bar"]//button[@class="tab-bar__tab pointer"]')), 30000, 'Timed out after 30 seconds', 5000);75 await driver.manage().setTimeouts({76 implicit: 1000, // 10 seconds77 });78 let tabList = await driver.findElements(By.xpath('//div[@class="tab-bar"]//button[@class="tab-bar__tab pointer"]'));79 await tabList[0].click();80 await driver.manage().setTimeouts({81 implicit: 1000, // 10 seconds82 });83 84 let showRinkeby = await driver.findElements(By.xpath('//div[@data-testid="advanced-setting-show-testnet-conversion"]//div[@class="settings-page__content-item"]//div[@class="settings-page__content-item-col"]//div[@class="toggle-button toggle-button--off"]/div'));85 await showRinkeby[2].click();86 await driver.findElement(By.className('chip__right-icon')).click();87 await driver.findElement(By.xpath('//span[text()="Rinkeby Test Network"]')).click();88 await driver.findElement(By.className('settings-page__close-button')).click();89 }catch(err){90 console.log(err.message);91 }92}93async function openOpenSeaSite(url){94 try{95 await driver.executeScript(`window.open("${url}");`);96 // await driver.get(url);97 await driver.manage().setTimeouts({98 implicit: 3000, // 10 seconds99 });100 }catch(e){101 console.log("error" + e.message);102 }103}104async function switchToOther(isOpenSea){105 try{106 let availableWindows = await driver.getAllWindowHandles()107 108 await availableWindows;109 if(isOpenSea){110 await driver.switchTo().window(availableWindows[2]);111 }else{112 await driver.switchTo().window(availableWindows[1]);113 }114 await driver.manage().setTimeouts({115 implicit: 1000, // 10 seconds116 });117 }catch(error){118 console.log(error.message);119 }120}121async function createCollection(){122 try{123 await driver.manage().setTimeouts({124 implicit: 2000, // 10 seconds125 });126 await driver.findElement(By.xpath('//a[@href="/asset/create"]')).click();127 await driver.manage().setTimeouts({128 implicit: 2000, // 10 seconds129 });130 let breakIt = true;131 while (true) {132 breakIt = true;133 try {134 // write your code here135 let walletList = await driver.findElements(By.xpath('//ul//li//button'));136 await walletList[1].click();137 } catch (e) {138 if (e.message.indexOf("element is not attached")) {139 breakIt = false;140 }141 }142 if (breakIt) {143 break;144 }145 }146 await driver.manage().setTimeouts({147 implicit: 3000, // 10 seconds148 });149 await driver.findElement(By.xpath('//button[text()="Next"]')).click();150 await driver.manage().setTimeouts({151 implicit: 1000, // 10 seconds152 });153 await driver.findElement(By.xpath('//button[text()="Connect"]')).click();154 await driver.manage().setTimeouts({155 implicit: 1000, // 10 seconds156 });157 await driver.findElement(By.xpath('//button[text()="Sign"]')).click();158 await driver.manage().setTimeouts({159 implicit: 1000, // 10 seconds160 });161 }catch(error){162 console.log(error.message);163 }164 165}166async function startProject(){167 try{168 // install metamask169 await installWallet();170 // open opensea171 await openOpenSeaSite(openSeaUrl);172 // false - switch to metamask...

Full Screen

Full Screen

backlogTest-spec.js

Source:backlogTest-spec.js Github

copy

Full Screen

...21 });22 it("There should be a btn to create a U.S ", async () => {23 try {24 await driver.get("http://localhost/backlog/1");25 await driver.manage().setTimeouts({ implicit: timing });26 const element = await driver.findElements(By.id("btnCreateUs"));27 expect(true).toBe(element.length != 0);28 } catch (error) {29 fail(error);30 }31 });32 it("Description should be required when creating new U.S", async () => {33 try {34 await driver.get("http://localhost/backlog/1");35 await driver.manage().setTimeouts({ implicit: timing });36 const backlogTbody = await driver.findElement(By.id("backlogTbody"));37 const usNumber = await backlogTbody.findElements(By.css("tr")).length;38 await driver.findElement(By.id("btnCreateUs")).click();39 await driver.manage().setTimeouts({ implicit: timing });40 await driver.findElement(By.id("submitUsForm")).click();41 await driver.manage().setTimeouts({ implicit: timing });42 const newBacklogTbody = await driver.findElement(By.id("backlogTbody"));43 const newUsNumber = await newBacklogTbody.findElements(By.css("tr")).length;44 expect(usNumber).toBe(newUsNumber);45 } catch (error) {46 fail(error);47 }48 });49 it("backlog should contains a U.S after his creation", async () => {50 try {51 await driver.get("http://localhost/backlog/1");52 await driver.manage().setTimeouts({ implicit: timing });53 await driver.findElement(By.id("btnCreateUs")).click();54 await driver.manage().setTimeouts({ implicit: timing });55 await driver.findElement(By.id("description2")).sendKeys("test description");56 await driver.findElement(By.id("submitUsForm")).click();57 await driver.manage().setTimeouts({ implicit: timing });58 const backlogTbody = await driver.findElement(By.id("backlogTbody"));59 const userStories = await backlogTbody.findElements(By.css("tr"));60 let found = false;61 for (let us of userStories) {62 let usComponents = await us.findElements(By.css("td"));63 const description = await usComponents[0].getText();64 if (description === "test description") {65 found = true;66 }67 }68 expect(found).toBe(true);69 } catch (error) {70 fail(error);71 }72 });73 it("start date and end date should be required when starting a sprint ", async () => {74 try {75 await driver.get("http://localhost/backlog/1");76 await driver.manage().setTimeouts({ implicit: timing });77 startButtons = await driver.findElements(By.className("btnShowStartSprintModal"));78 if (startButtons.length > 0)79 await startButtons[0].click();80 await driver.manage().setTimeouts({ implicit: timing });81 await driver.findElement(By.id("btnSubmitStartSprint")).click();82 await driver.manage().setTimeouts({ implicit: timing });83 const currentUrl = await driver.getCurrentUrl();84 expect(true).toBe(currentUrl.includes("http://localhost/backlog"));85 } catch (error) {86 fail(error);87 }88 });89 it("when the user click on a us, the UI to delete or to edit the us should appear", async () => {90 try {91 await driver.get("http://localhost/backlog/1");92 await driver.manage().setTimeouts({ implicit: timing });93 const backlogTbody = await driver.findElement(By.id("backlogTbody"));94 const userStories = await backlogTbody.findElements(By.css("tr"));95 if (userStories.length > 0) {96 const tds = await userStories[0].findElements(By.css("td"));97 await tds[0].click();98 await driver.manage().setTimeouts({ implicit: timing });99 const infosUs = await driver.findElements(By.id("infosUs"));100 expect(infosUs.length).toBe(1);101 } 102 } catch (error) {103 fail(error);104 }105 });106});107async function register(email, password) {108 try {109 driver = await new Builder()110 .forBrowser('firefox')111 .build();112 const url = "http://localhost/user/signup";113 await driver.get(url);114 driver.findElement(By.id("mail")).sendKeys(email);115 driver.findElement(By.id("username")).sendKeys("userProject");116 driver.findElement(By.id("password")).sendKeys(password);117 driver.findElement(By.id("passwordConfirmation")).sendKeys(password);118 await driver.findElement(By.id("btnRegister")).click();119 await driver.manage().setTimeouts({ implicit: 100 });120 } catch (error) {121 console.error(error);122 } 123}124async function login(email, password) {125 try {126 await driver.get("http://localhost/user/login");127 driver.findElement(By.id("inputLogin")).sendKeys(email);128 driver.findElement(By.id("inputPassword")).sendKeys(password);129 await driver.findElement(By.id("btnLogin")).click();130 await driver.manage().setTimeouts({ implicit: timing });131 } catch (error) {132 console.error(error);133 } 134}135async function createProject(title, description) {136 const url = "http://localhost/project/new";137 await driver.get(url);138 await driver.findElement(By.id("inputTitle")).sendKeys(title);139 await driver.findElement(By.id("inputDescription")).sendKeys(description);140 await driver.findElement(By.id("btnCreate")).click();141 await driver.manage().setTimeouts({ implicit: timing });...

Full Screen

Full Screen

test2.js

Source:test2.js Github

copy

Full Screen

...17 const pageTitle = await driver.getTitle();18 console.log('\x1b[33m%s\x1b[0m',"Lehekülje nimi on:", pageTitle);1920 //set timeout for 10 seconds21 //await driver.manage().setTimeouts({ implicit: 10000 });2223 //add item to wishlist24 await driver.manage().setTimeouts({ implicit: 10000 });25 const addToWishlist = await driver26 .findElement(27 By.xpath(28 '//*[@id="amasty-shopby-product-list"]/div[3]/ol/li[14]/div/div[3]/div/div/a'29 )30 );31 driver.executeScript('arguments[0].click();',addToWishlist);32 console.log('\x1b[33m%s\x1b[0m',"Lisasin ägedad saapad lemmikute nimekirja!");3334 // open wishlist menu35 await driver.manage().setTimeouts({ implicit: 10000 });36 const openWishlistMenu = await driver.findElement(By.xpath(`//*[@id="wishlist-link"]`));37 driver.executeScript('arguments[0].click();',openWishlistMenu);38 console.log('\x1b[33m%s\x1b[0m',"Leidsin südame ja klikin sellele");3940 //open my wishlist41 await driver.manage().setTimeouts({ implicit: 10000 });42 await driver.findElement(By.className(`action primary go-to-wishlist`)).click();43 console.log('\x1b[33m%s\x1b[0m',"Lähen vaatan oma lemmikute nimekirja");4445 //open item page46 await driver.manage().setTimeouts({ implicit: 10000 });47 await driver48 .findElement(By.className(`page hover-image hover-image-product-id-471445`))49 .click();50 console.log('\x1b[33m%s\x1b[0m',"Avan selle toote, mida osta soovin");5152 //open dropdown menu to choose size53 await driver.manage().setTimeouts({ implicit: 10000 });54 await driver55 .findElement(56 By.className(57 `selectric-wrapper selectric-super-attribute-select selectric-hover selectric-open selectric-below`58 )59 )60 .click();61 console.log('\x1b[33m%s\x1b[0m',"Hakkan suurust valima");6263 //choose the shoe size64 await driver.manage().setTimeouts({ implicit: 10000 });65 await driver66 .findElement(67 By.xpath(68 '//*[@id="product-options-wrapper"]/div/div/div/div/div[3]/div/ul/li[4]/div[1]'69 )70 )71 .click();72 console.log('\x1b[33m%s\x1b[0m',"Valisin nr 38 saapad");7374 //add product to cart75 await driver.manage().setTimeouts({ implicit: 10000 });76 await driver.findElement(By.id(`product-addtocart-button`)).click();77 console.log('\x1b[33m%s\x1b[0m',"Lisan need imelised saapad ostukorvi");7879 //navigate to cart80 await driver.manage().setTimeouts({ implicit: 10000 });81 await driver.findElement(By.className(`action showcart active`)).click();82 await driver83 .findElement(84 By.xpath('//*[@id="minicart-content-wrapper"]/div[2]/div[4]/div/a/span')85 )86 .click();87 console.log('\x1b[33m%s\x1b[0m',"Lähen oma ostukorvi vaatama");8889 //increase the quantity by 190 await driver.manage().setTimeouts({ implicit: 10000 });91 await driver.findElement(By.id(`increase-cart-qty-btn-5611753`)).click();92 console.log('\x1b[33m%s\x1b[0m',"Lisan ühed saapad veel juurde");9394 //remove item from cart95 await driver.manage().setTimeouts({ implicit: 10000 });96 await driver97 .findElement(98 By.xpath(`//*[@id="shopping-cart-table"]/tbody/tr[1]/td[6]/a/span`)99 )100 .click();101 console.log('\x1b[33m%s\x1b[0m',"Mõtlesin ümber, eemaldan need saapad ostukorvist");102103 //search for "jope"104 await driver.manage().setTimeouts({ implicit: 10000 });105 await driver106 .findElement(By.id(`search`))107 .sendKeys(whatISearchFor, Key.RETURN);108 console.log('\x1b[33m%s\x1b[0m',"Otsisin parem jopesid");109110 //sort search result by popularity111 await driver.manage().setTimeouts({ implicit: 10000 });112 await driver.findElement(By.css(`#sorter [value="bestsellers"]`)).click();113 console.log('\x1b[33m%s\x1b[0m',"Reastasin joped populaarsuse järgi");114115}116 ...

Full Screen

Full Screen

downloadEmptyImg.js

Source:downloadEmptyImg.js Github

copy

Full Screen

...11 let movieList = await checkImagesExist();12 // console.log(nowNum);13 14 await driver.get('https://www.kobis.or.kr/kobis/business/mast/mvie/searchUserMovCdList.do');15 await driver.manage().setTimeouts(implicit_wait);16 for(let mValue of movieList) {17 await driver.findElement(By.css('#searchForm > div.ins > div:nth-child(2) > div > input')).sendKeys(mValue.movie_id, Key.ENTER);18 await driver.manage().setTimeouts(implicit_wait);19 await driver.findElement(By.css('#searchForm > div.ins > div.wrap_btn > button')).click();20 await driver.manage().setTimeouts(implicit_wait);21 await driver.findElement(By.css('#content > div.rst_sch > table > tbody > tr > td:nth-child(1) > a')).click();22 await driver.manage().setTimeouts(implicit_wait);23 let href = await (await driver.findElement(By.css(".item_tab.basic > div.ovf.info.info1 > a"))).getAttribute("href");24 let urlArr = href.split("/");25 if(urlArr[urlArr.length-1] == "searchMovieList.do#") console.log("Can't found image");26 else downloadImageToUrl(href, mValue.poster_img);27 await driver.manage().setTimeouts(implicit_wait);28 await driver.get('https://www.kobis.or.kr/kobis/business/mast/mvie/searchUserMovCdList.do');29 await driver.manage().setTimeouts(implicit_wait);30 }31 32 33 } catch (error) {34 console.log(error);35 } finally {36 try {37 await driver.quit();38 await console.log("✨ one movie finished ✨");39 // 일반적으로 driver.close()브라우저를 닫고(드라이버 인스턴스는 그대로 driver.quit()유지됨) webdriver 인스턴스를 종료합니다.40 } catch (ter) {41 console.log(ter);42 }43 ...

Full Screen

Full Screen

GetAjax.js

Source:GetAjax.js Github

copy

Full Screen

1var newArray = new Object();2newArray['SetTimeouts'] = new Object();3newArray['SetIntervals'] = new Object();4newArray['Ajax'] = 0;5var setTimeouts = window._activeSetTimeouts;6for (var keyTimeouts in setTimeouts) {7 if (setTimeouts.hasOwnProperty(keyTimeouts)) {8 if (keyTimeouts > arguments[0] && setTimeouts[keyTimeouts]['delay'] < 5000) {9 newArray['SetTimeouts'][keyTimeouts] = setTimeouts[keyTimeouts];10 }11 }12}13var setIntervals = window._activeSetIntervals;14for (var keyIntervals in setIntervals) {15 if (setIntervals.hasOwnProperty(keyIntervals)) {16 if (keyIntervals > arguments[1] && setIntervals[keyIntervals]['delay'] < 5000) {17 newArray['SetIntervals'][keyIntervals] = setIntervals[keyIntervals];18 }19 }20}21var ajaxSum = 0;22if (document.readyState !== 'complete')23 ajaxSum++;24if (typeof window.activeRequests != 'undefined')25 ajaxSum += window.activeRequests;26if (typeof window.jQuery != 'undefined')27 ajaxSum += window.jQuery.active;28if (typeof window.animationCount != 'undefined')29 ajaxSum += window.animationCount;30newArray['Ajax'] = ajaxSum;31newArray['TimeNow'] = new Date().getTime();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1browser.setTimeout({ 'implicit': 5000 })2browser.setValue('input[type="text"]', 'webdriverio')3browser.click('input[value="Google Search"]')4browser.waitForVisible('h3=WebdriverIO - WebDriver bindings for Node.js', 5000)5browser.click('h3=WebdriverIO - WebDriver bindings for Node.js')6browser.getTitle().should.be.equal('WebdriverIO - WebDriver bindings for Node.js')7browser.pause(5000)8browser.setValue('input[type="text"]', 'webdriverio')9browser.click('input[value="Google Search"]')10browser.waitForExist('h3=WebdriverIO - WebDriver bindings for Node.js', 5000)11browser.click('h3=WebdriverIO - WebDriver bindings for Node.js')12browser.getTitle().should.be.equal('WebdriverIO - WebDriver bindings for Node.js')13browser.pause(5000)14browser.setValue('input[type="text"]', 'webdriverio')15browser.click('input[value="Google Search"]')16browser.waitForVisible('h3=WebdriverIO - WebDriver bindings for Node.js', 5000)17browser.click('h3=WebdriverIO - WebDriver bindings for Node.js')18browser.getTitle().should.be.equal('WebdriverIO - WebDriver bindings for Node.js')19browser.pause(5000)20browser.setValue('input[type="text"]', 'webdriverio')21browser.click('input[value="Google Search"]')22browser.waitForEnabled('h3=WebdriverIO - WebDriver bindings for Node.js', 5000)23browser.click('h3=WebdriverIO - WebDriver bindings for Node.js')24browser.getTitle().should.be.equal('WebdriverIO - WebDriver bindings for Node.js')25browser.pause(5000)26browser.setValue('input[type="text"]', 'webdriverio')27browser.click('input[value="Google Search"]')28browser.waitForText('h3=WebdriverIO - WebDriver bindings for Node.js', 5000)29browser.click('h3=WebdriverIO - WebDriver bindings for Node.js')

Full Screen

Using AI Code Generation

copy

Full Screen

1browser.setTimeout({ 'implicit': 10000 });2browser.setCookies({ name: 'test', value: '123' });3browser.setWindowSize(1000, 1000);4browser.setTimeout({ 'implicit': 10000 });5browser.setCookies({ name: 'test', value: '123' });6browser.setWindowSize(1000, 1000);7browser.setTimeout({ 'implicit': 10000 });8browser.setCookies({ name: 'test', value: '123' });9browser.setWindowSize(1000, 1000);10browser.setTimeout({ 'implicit': 10000 });11browser.setCookies({ name: 'test', value: '123' });12browser.setWindowSize(1000, 1000);13browser.setTimeout({ 'implicit': 10000 });14browser.setCookies({ name: 'test', value: '123' });15browser.setWindowSize(1000, 1000);16browser.setTimeout({ 'implicit': 10000 });17browser.setCookies({ name: 'test', value: '123' });18browser.setWindowSize(1000, 1000);19browser.setTimeout({ 'implicit': 10000 });20browser.setCookies({ name: 'test

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', function() {2 it('should pass', function () {3 browser.pause(3000);4 browser.setValue('input[type="text"]', 'WebdriverIO');5 browser.pause(3000);6 browser.click('input[value="Google Search"]');7 browser.pause(3000);8 browser.click('h3[class="r"] a');9 browser.pause(3000);10 });11});12browser.getValue('input[type="text"]', function(err, value) {13 console.log(value);14});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', function() {2 it('should pass', function () {3 browser.pause(1000);4 browser.setValue('input[type="text"]', 'WebdriverIO');5 browser.pause(1000);6 browser.click('button[name="btnG"]');7 browser.pause(1000);8 browser.pause(5000);9 browser.click('h3.r a');10 browser.pause(1000);11 browser.pause(5000);12 });13});14browser.waitUntil(function () {15 return browser.element('h3.r a').isVisible() === true;16}, 5000, 'expected text to be different after 5s');

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('WebdriverIO API Demos', function() {2 it('should set a timeout', function () {3 browser.pause(3000);4 browser.setTimeout({ 'implicit': 5000 });5 browser.pause(3000);6 });7});8exports.config = {9 capabilities: [{10 }],11 mochaOpts: {12 }13}14exports.config = {15 capabilities: [{16 }],17 mochaOpts: {18 }19}20exports.config = {

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', function() {2 it('should be able to use setTimeouts', function() {3 browser.setTimeouts(5000, 5000, 5000);4 });5});6const webdriverio = require('webdriverio');7const options = {8 desiredCapabilities: {9 }10};11 .remote(options)12 .init()13 .setTimeouts(5000, 5000, 5000)14 .end();15exports.config = {16 capabilities: [{17 }],18 mochaOpts: {19 },20 before: function (capabilities, specs) {21 require('babel-register');22 },

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test Suite', function(){2 it('Test Case', function(){3 browser.pause(5000);4 browser.saveScreenshot('screenshot.png');5 browser.pause(5000);6 })7})8exports.config = {9 capabilities: [{10 }],11 mochaOpts: {12 }13}14{15 "scripts": {16 },17 "devDependencies": {18 }19}

Full Screen

Using AI Code Generation

copy

Full Screen

1const webdriverio = require('webdriverio');2const assert = require('assert');3const options = {4 capabilities: {5 }6};7async function main() {8 const driver = await webdriverio.remote(options);9 await el1.click();10 await driver.pause(2000);11 await el2.waitForDisplayed({ timeout: 5000 });12 const text = await el2.getText();13 console.log(text);14 assert.equal(text, 'Hello World!');15 await driver.deleteSession();16}17main();

Full Screen

WebdriverIO Tutorial

Wondering what could be a next-gen browser and mobile test automation framework that is also simple and concise? Yes, that’s right, it's WebdriverIO. Since the setup is very easy to follow compared to Selenium testing configuration, you can configure the features manually thereby being the center of attraction for automation testing. Therefore the testers adopt WedriverIO to fulfill their needs of browser testing.

Learn to run automation testing with WebdriverIO tutorial. Go from a beginner to a professional automation test expert with LambdaTest WebdriverIO tutorial.

Chapters

  1. Running Your First Automation Script - Learn the steps involved to execute your first Test Automation Script using WebdriverIO since the setup is very easy to follow and the features can be configured manually.

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

  3. Browser Commands For Selenium Testing - Understand more about the barriers faced while working on your Selenium Automation Scripts in WebdriverIO, the ‘browser’ object and how to use them?

  4. Handling Alerts & Overlay In Selenium - Learn different types of alerts faced during automation, how to handle these alerts and pops and also overlay modal in WebdriverIO.

  5. How To Use Selenium Locators? - Understand how Webdriver uses selenium locators in a most unique way since having to choose web elements very carefully for script execution is very important to get stable test results.

  6. Deep Selectors In Selenium WebdriverIO - The most popular automation testing framework that is extensively adopted by all the testers at a global level is WebdriverIO. Learn how you can use Deep Selectors in Selenium WebdriverIO.

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

  8. Automated Monkey Testing with Selenium & WebdriverIO - Understand how you can leverage the amazing quality of WebdriverIO along with selenium framework to automate monkey testing of your website or web applications.

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

  10. Cross Browser Testing With WebdriverIO - Learn more with this step-by-step tutorial about WebdriverIO framework and how cross-browser testing is done with WebdriverIO.

Run Webdriverio automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful