How to use driver.findElements method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

login_sel.js

Source:login_sel.js Github

copy

Full Screen

...34 resolve({status : "ok", msg : "already logged"})35 return36 }37 if((await driver.getCurrentUrl()).indexOf("accounts.google.com/ServiceLogin/signinchooser") >= 0){38 let li = await driver.findElements(By.css('form li > div'))39 if(li.length > 2){40 await li[li.length-2].click()41 }42 else{43 let li = await driver.findElements(By.css('form ul > li > div[data-identifier="'+email+'"]'))[0]44 if(li){45 await li.click()46 }47 }48 await utils.sleep(7000)49 }50 if((await driver.getCurrentUrl()).indexOf('accounts.google.com/signin/v2/sl/pwd') > -1){51 let id = await driver.findElements(By.css('#profileIdentifier'))[0]52 if(id){53 await id.click()54 await utils.sleep(15000)55 let li = await driver.findElements(By.css('form li > div'))56 if(li.length > 2){57 await li[li.length-2].click()58 }59 else{60 let li = await driver.findElements(By.css('form ul > li > div[data-identifier="'+email+'"]'))[0]61 if(li){62 await li.click()63 }64 }65 await utils.sleep(15000)66 }67 }68 if ((await driver.getCurrentUrl()).indexOf("accounts.google.com/signin/v2/identifier") > -1) { // co truong nhap nhap thang password69 const emailInput = (await driver.findElements(By.css("#identifierId")))[0]70 await emailInput.sendKeys(email,Key.ENTER)71 await utils.sleep(15000)72 if ((await driver.getCurrentUrl()).indexOf("accounts.google.com/signin/v2/identifier") > -1) {73 const msgEle = (await driver.findElements(By.css("div[aria-live='assertive']")))[0]74 const text = await msgEle.getText();75 resolve({status: "error", msg: "Invalid email: " + text.trim()})76 return77 }78 }79 if ((await driver.getCurrentUrl()).indexOf("accounts.google.com/ServiceLogin") > -1) { //email ff 1080 let emailInput = (await driver.findElements(By.css("#Email")))[0]81 if(!emailInput){82 emailInput = (await driver.findElements(By.css("#identifierId")))[0]83 }84 await emailInput.sendKeys(email,Key.ENTER)85 await utils.sleep(7000)86 const msgEle = (await driver.findElements(By.css("#errormsg_0_Email")))[0]87 if (msgEle != null) {88 const text = await msgEle.getText();89 if (text != "") {90 resolve({status: "error", msg: "Invalid email: " + text.trim()})91 return92 }93 }94 let passwordInput = (await driver.findElements(By.css("#Passwd")))[0]95 if(!passwordInput){96 passwordInput = (await driver.findElements(By.css("input[name='password']")))[0]97 }98 await passwordInput.sendKeys(password,Key.ENTER)99 await utils.sleep(15000)100 await checkCaptcha(driver, password)101 const msgElePass = (await driver.findElements(By.css("#errormsg_0_Passwd")))[0]102 if (msgElePass != null) {103 const textPass = await msgElePass.getText();104 if (textPass != "") {105 resolve({status : "error", msg : "Invalid Password: " + text.trim()})106 return107 }108 }109 }else {110 const passwordInput = (await driver.findElements(By.css("input[name='password']")))[0]111 await passwordInput.sendKeys(password, Key.ENTER)112 await utils.sleep(15000)113 await checkCaptcha(driver, password)114 if ((await driver.getCurrentUrl()).indexOf("accounts.google.com/signin/v2/sl/pwd") > -1) {115 const msgEle = (await driver.findElements(By.css("div[aria-live='assertive']")))[0]116 const text = await msgEle.getText()117 resolve({status : "error", msg : "Invalid Password: " + text.trim()})118 return119 }120 }121 await checkCaptcha(driver, password)122 if ((await driver.getCurrentUrl()).indexOf("accounts.google.com/signin/selectchallenge") > -1 || (await driver.getCurrentUrl()).indexOf("https://accounts.google.com/signin/v2/challenge/selection") > -1) {123 if((await driver.findElements(By.css("[data-challengetype='12']")))[0] && emailRecovery && emailRecovery.length > 0){124 await driver.findElement(By.css("[data-challengetype='12']")).click()125 }126 else if((await driver.findElements(By.css("[data-challengetype='13']")))[0] && recoverPhone && recoverPhone.length > 0){127 await driver.findElement(By.css("[data-challengetype='13']")).click()128 }129 else{130 resolve({status : "err", msg : "unknown challengetype"})131 return132 }133 await utils.sleep(12000)134 }135 if ((await driver.getCurrentUrl()).indexOf("challenge/kpe") > -1){136 let emailInput = (await driver.findElements(By.css("input[name='email']")))[0]137 if (emailInput != null) {138 await emailInput.sendKeys(emailRecovery, Key.ENTER)139 }else {140 emailInput = (await driver.findElements(By.css("input[type='email']")))[0]141 if (emailInput != null) {142 await emailInput.sendKeys(emailRecovery, Key.ENTER)143 }144 }145 await utils.Sleep(13000)146 }147 if ((await driver.getCurrentUrl()).indexOf("challenge/kpp") > -1){148 let phoneInput = (await driver.findElements(By.css("input#phoneNumberId")))[0]149 if (phoneInput != null) {150 await phoneInput.sendKeys(recoverPhone, Key.ENTER)151 }else {152 phoneInput = (await driver.findElements(By.css("input[type='tel']")))[0]153 if (phoneInput != null) {154 await phoneInput.sendKeys(recoverPhone, Key.ENTER)155 }156 }157 await utils.sleep(13000)158 }159 if ((await driver.getCurrentUrl()).indexOf("deniedsigninrejected") > -1) {160 resolve({status : "err", msg : "BLOCKED"})161 return162 }163 if((await driver.getCurrentUrl()).indexOf("youtube.com/channel_switcher") > -1) {164 let channel = (await driver.findElements(By.css('a[role="button"]')))[0]165 if(channel) channel.click()166 await utils.sleep(12000)167 }168 if (169 (await driver.getCurrentUrl()).indexOf("accounts.google.com/signin/newfeatures") > -1 ||170 (await driver.getCurrentUrl()).indexOf("myaccount.google.com/signinoptions") > -1 ||171 (await driver.getCurrentUrl()).indexOf("RecycledEmailInterstitial") > -1 ||172 (await driver.getCurrentUrl()).indexOf("youtube.com/") > -1173 ) {174 resolve({status : "ok"})175 return176 }177 resolve({status : "err", msg : "Unknown error: " + (await driver.getCurrentUrl())})178 }catch (e) {179 if (180 (await driver.getCurrentUrl()).indexOf("accounts.google.com/signin/newfeatures") > -1 ||181 (await driver.getCurrentUrl()).indexOf("myaccount.google.com/signinoptions") > -1 ||182 (await driver.getCurrentUrl()).indexOf("RecycledEmailInterstitial") > -1 ||183 (await driver.getCurrentUrl()).indexOf("youtube.com/") > -1184 ) {185 resolve({status : "ok"})186 return187 }188 resolve({status : "err", msg : "LOGIN EXCEPTION " + (await driver.getCurrentUrl()) + " " + e.toString()})189 }190 })191}192function checkCaptcha(driver, password) {193 return new Promise(async resolve => {194 try{195 const checkCaptcha1 = (await driver.findElements(By.css("#captchaimg")))[0]196 const checkCaptcha2 = (await driver.findElements(By.css(".captcha-img")))[0]197 if (checkCaptcha1 != null || checkCaptcha2 != null) {198 let captchaResult = await getCaptchaResult(driver)199 if (captchaResult.err) {200 resolve({status : "error", msg : "Captcha detected: " + captchaResult.err})201 return202 }203 let passwordInput = (await driver.findElements(By.css("input[name='password']")))[0]204 if(passwordInput != null) {205 await passwordInput.sendKeys(password)206 }else {207 passwordInput = (await driver.findElements(By.css("#Passwd")))[0]208 if (passwordInput != null) {209 await passwordInput.sendKeys(password)210 }211 }212 let captchaInput = (await driver.findElements(By.css("input#ca")))[0]213 if (captchaInput != null) {214 await captchaInput.sendKeys(captchaResult.data)215 }else {216 captchaInput = (await driver.findElements(By.css("input#logincaptcha")))[0]217 if (captchaInput != null) {218 await captchaInput.sendKeys(captchaResult.data)219 }220 }221 if (captchaInput != null) {222 await captchaInput.sendKeys(Key.ENTER);223 }224 await utils.sleep(4000)225 resolve({status : "ok"})226 }else {227 console.log('no captcha')228 resolve({status : "ok"})229 }230 }231 catch (e) {232 console.log('error','checkCaptcha',e)233 resolve({status : "error", msg : "checkCaptcha error: " + e.toString()})234 }235 })236}237async function getCaptchaResult(driver) {238 return new Promise(async resolve => {239 let imgUrl = ""240 let captchaTag = (await driver.findElements(By.css('#captchaimg')))[0]241 if (captchaTag != undefined && captchaTag != null) {242 imgUrl = (await driver.findElements(By.css('#captchaimg')))[0]243 imgUrl = imgUrl?imgUrl.getAttribute("src"):''244 }else {245 captchaTag = await driver.$(".captcha-img img")246 if (captchaTag != undefined && captchaTag != null) {247 imgUrl = (await driver.findElements(By.css('.captcha-img img')))[0]248 imgUrl = imgUrl?imgUrl.getAttribute("src"):''249 }250 }251 if(imgUrl.indexOf("https://accounts.google.com") == -1) {252 imgUrl = "https://accounts.google.com" + imgUrl253 }254 console.log("Captcha URL := ", imgUrl)255 request.get(imgUrl, function (error, response, body) {256 if (!error && response.statusCode == 200) {257 let captchaBase64 = new Buffer(body).toString('base64')258 resolve(resolveCaptcha(captchaBase64))259 }else {260 resolve({err : error})261 }...

Full Screen

Full Screen

from-import-ui.spec.js

Source:from-import-ui.spec.js Github

copy

Full Screen

...64 await optOutButton.click()65 await driver.delay(largeDelayMs)66 })67 it('imports a seed phrase', async () => {68 const [seedTextArea] = await driver.findElements(By.css('textarea.first-time-flow__textarea'))69 await seedTextArea.sendKeys(testSeedPhrase)70 await driver.delay(regularDelayMs)71 const [password] = await driver.findElements(By.id('password'))72 await password.sendKeys('correct horse battery staple')73 const [confirmPassword] = await driver.findElements(By.id('confirm-password'))74 confirmPassword.sendKeys('correct horse battery staple')75 const tosCheckBox = await driver.findElement(By.css('.first-time-flow__checkbox'))76 await tosCheckBox.click()77 const [importButton] = await driver.findElements(By.xpath(`//button[contains(text(), 'Import')]`))78 await importButton.click()79 await driver.delay(regularDelayMs)80 })81 it('clicks through the success screen', async () => {82 await driver.findElement(By.xpath(`//div[contains(text(), 'Congratulations')]`))83 const doneButton = await driver.findElement(By.xpath(`//button[contains(text(), '${enLocaleMessages.endOfFlowMessage10.message}')]`))84 await doneButton.click()85 await driver.delay(regularDelayMs)86 })87 })88 describe('Show account information', () => {89 it('shows the correct account address', async () => {90 const accountDetailsButton = await driver.findElement(By.css('.account-details__details-button'))91 await accountDetailsButton.click()92 await driver.findVisibleElement(By.css('.qr-wrapper'))93 await driver.delay(regularDelayMs)94 const [address] = await driver.findElements(By.css('input.qr-ellip-address'))95 assert.equal(await address.getAttribute('value'), testAddress)96 const accountModalClose = await driver.findElement(By.css('.account-modal-close'))97 await accountModalClose.click()98 await driver.delay(largeDelayMs)99 })100 it('shows a QR code for the account', async () => {101 const accountDetailsButton = await driver.findElement(By.css('.account-details__details-button'))102 await accountDetailsButton.click()103 await driver.findVisibleElement(By.css('.qr-wrapper'))104 const detailModal = await driver.findElement(By.css('span .modal'))105 await driver.delay(regularDelayMs)106 const accountModalClose = await driver.findElement(By.css('.account-modal-close'))107 await accountModalClose.click()108 await driver.wait(until.stalenessOf(detailModal))109 await driver.delay(regularDelayMs)110 })111 })112 describe('Log out and log back in', () => {113 it('logs out of the account', async () => {114 const accountIdenticon = await driver.findElement(By.css('.account-menu__icon .identicon'))115 await accountIdenticon.click()116 await driver.delay(regularDelayMs)117 const [logoutButton] = await driver.findElements(By.css('.account-menu__logout-button'))118 assert.equal(await logoutButton.getText(), 'Log out')119 await logoutButton.click()120 await driver.delay(regularDelayMs)121 })122 it('accepts the account password after lock', async () => {123 const passwordField = await driver.findElement(By.id('password'))124 await passwordField.sendKeys('correct horse battery staple')125 await passwordField.sendKeys(Key.ENTER)126 await driver.delay(largeDelayMs)127 })128 })129 describe('Add an account', () => {130 it('switches to localhost', async () => {131 const networkDropdown = await driver.findElement(By.css('.network-name'))132 await networkDropdown.click()133 await driver.delay(regularDelayMs)134 const [localhost] = await driver.findElements(By.xpath(`//span[contains(text(), 'Localhost')]`))135 await localhost.click()136 await driver.delay(largeDelayMs)137 })138 it('choose Create Account from the account menu', async () => {139 const accountMenuButton = await driver.findElement(By.css('.account-menu__icon'))140 await accountMenuButton.click()141 await driver.delay(regularDelayMs)142 const [createAccount] = await driver.findElements(By.xpath(`//div[contains(text(), 'Create Account')]`))143 await createAccount.click()144 await driver.delay(regularDelayMs)145 })146 it('set account name', async () => {147 const [accountName] = await driver.findElements(By.css('.new-account-create-form input'))148 await accountName.sendKeys('2nd account')149 await driver.delay(regularDelayMs)150 const [createButton] = await driver.findElements(By.xpath(`//button[contains(text(), 'Create')]`))151 await createButton.click()152 await driver.delay(regularDelayMs)153 })154 it('should show the correct account name', async () => {155 const [accountName] = await driver.findElements(By.css('.account-details__account-name'))156 assert.equal(await accountName.getText(), '2nd account')157 await driver.delay(regularDelayMs)158 })159 })160 describe('Switch back to original account', () => {161 it('chooses the original account from the account menu', async () => {162 const accountMenuButton = await driver.findElement(By.css('.account-menu__icon'))163 await accountMenuButton.click()164 await driver.delay(regularDelayMs)165 const [originalAccountMenuItem] = await driver.findElements(By.css('.account-menu__name'))166 await originalAccountMenuItem.click()167 await driver.delay(regularDelayMs)168 })169 })170 describe('Send ETH from inside MetaMask', () => {171 it('starts a send transaction', async function () {172 const sendButton = await driver.findElement(By.xpath(`//button[contains(text(), 'Send')]`))173 await sendButton.click()174 await driver.delay(regularDelayMs)175 const inputAddress = await driver.findElement(By.css('input[placeholder="Search, public address (0x), or ENS"]'))176 await inputAddress.sendKeys('0x2f318C334780961FB129D2a6c30D0763d9a5C970')177 const inputAmount = await driver.findElement(By.css('.unit-input__input'))178 await inputAmount.sendKeys('1')179 // Set the gas limit180 const configureGas = await driver.findElement(By.css('.advanced-gas-options-btn'))181 await configureGas.click()182 await driver.delay(regularDelayMs)183 const gasModal = await driver.findElement(By.css('span .modal'))184 const save = await driver.findElement(By.xpath(`//button[contains(text(), 'Save')]`))185 await save.click()186 await driver.wait(until.stalenessOf(gasModal))187 await driver.delay(regularDelayMs)188 // Continue to next screen189 const nextScreen = await driver.findElement(By.xpath(`//button[contains(text(), 'Next')]`))190 await nextScreen.click()191 await driver.delay(regularDelayMs)192 })193 it('confirms the transaction', async function () {194 const confirmButton = await driver.findElement(By.xpath(`//button[contains(text(), 'Confirm')]`))195 await confirmButton.click()196 await driver.delay(regularDelayMs)197 })198 it('finds the transaction in the transactions list', async function () {199 await driver.wait(async () => {200 const confirmedTxes = await driver.findElements(By.css('.transaction-list__completed-transactions .transaction-list-item'))201 return confirmedTxes.length === 1202 }, 10000)203 const txValues = await driver.findElements(By.css('.transaction-list-item__amount--primary'))204 assert.equal(txValues.length, 1)205 assert.ok(/-1\s*ETH/.test(await txValues[0].getText()))206 })207 })208 describe('Imports an account with private key', () => {209 it('choose Create Account from the account menu', async () => {210 const accountMenuButton = await driver.findElement(By.css('.account-menu__icon'))211 await accountMenuButton.click()212 await driver.delay(regularDelayMs)213 const [importAccount] = await driver.findElements(By.xpath(`//div[contains(text(), 'Import Account')]`))214 await importAccount.click()215 await driver.delay(regularDelayMs)216 })217 it('enter private key', async () => {218 const privateKeyInput = await driver.findElement(By.css('#private-key-box'))219 await privateKeyInput.sendKeys(testPrivateKey2)220 await driver.delay(regularDelayMs)221 const importButtons = await driver.findElements(By.xpath(`//button[contains(text(), 'Import')]`))222 await importButtons[0].click()223 await driver.delay(regularDelayMs)224 })225 it('should show the correct account name', async () => {226 const [accountName] = await driver.findElements(By.css('.account-details__account-name'))227 assert.equal(await accountName.getText(), 'Account 4')228 await driver.delay(regularDelayMs)229 })230 it('should show the imported label', async () => {231 const [importedLabel] = await driver.findElements(By.css('.account-details__keyring-label'))232 assert.equal(await importedLabel.getText(), 'IMPORTED')233 await driver.delay(regularDelayMs)234 })235 })236 describe('Imports and removes an account', () => {237 it('choose Create Account from the account menu', async () => {238 const accountMenuButton = await driver.findElement(By.css('.account-menu__icon'))239 await accountMenuButton.click()240 await driver.delay(regularDelayMs)241 const [importAccount] = await driver.findElements(By.xpath(`//div[contains(text(), 'Import Account')]`))242 await importAccount.click()243 await driver.delay(regularDelayMs)244 })245 it('enter private key', async () => {246 const privateKeyInput = await driver.findElement(By.css('#private-key-box'))247 await privateKeyInput.sendKeys(testPrivateKey3)248 await driver.delay(regularDelayMs)249 const importButtons = await driver.findElements(By.xpath(`//button[contains(text(), 'Import')]`))250 await importButtons[0].click()251 await driver.delay(regularDelayMs)252 })253 it('should open the remove account modal', async () => {254 const [accountName] = await driver.findElements(By.css('.account-details__account-name'))255 assert.equal(await accountName.getText(), 'Account 5')256 await driver.delay(regularDelayMs)257 const accountMenuButton = await driver.findElement(By.css('.account-menu__icon'))258 await accountMenuButton.click()259 await driver.delay(regularDelayMs)260 const accountListItems = await driver.findElements(By.css('.account-menu__account'))261 assert.equal(accountListItems.length, 5)262 const removeAccountIcons = await driver.findElements(By.css('.remove-account-icon'))263 await removeAccountIcons[1].click()264 await driver.delay(tinyDelayMs)265 await driver.findElement(By.css('.confirm-remove-account__account'))266 })267 it('should remove the account', async () => {268 const removeButton = await driver.findElement(By.xpath(`//button[contains(text(), 'Remove')]`))269 await removeButton.click()270 await driver.delay(regularDelayMs)271 const [accountName] = await driver.findElements(By.css('.account-details__account-name'))272 assert.equal(await accountName.getText(), 'Account 1')273 await driver.delay(regularDelayMs)274 const accountListItems = await driver.findElements(By.css('.account-menu__account'))275 assert.equal(accountListItems.length, 4)276 })277 })278 describe('Connects to a Hardware wallet', () => {279 it('choose Connect Hardware Wallet from the account menu', async () => {280 const [connectAccount] = await driver.findElements(By.xpath(`//div[contains(text(), 'Connect Hardware Wallet')]`))281 await connectAccount.click()282 await driver.delay(regularDelayMs)283 })284 it('should open the TREZOR Connect popup', async () => {285 const trezorButton = await driver.findElements(By.css('.hw-connect__btn'))286 await trezorButton[1].click()287 await driver.delay(regularDelayMs)288 const connectButtons = await driver.findElements(By.xpath(`//button[contains(text(), 'Connect')]`))289 await connectButtons[0].click()290 await driver.delay(regularDelayMs)291 const allWindows = await driver.getAllWindowHandles()292 assert.equal(allWindows.length, 2)293 })294 })...

Full Screen

Full Screen

smg-ts_test07.js

Source:smg-ts_test07.js Github

copy

Full Screen

...17 // Замечание: на Ubuntu в WebStorm (в Chrome) стабильность выполнения теста 78%18 // на Win7 в VS Code (в Chrome) - выполняется в 100% случаев19 await driver.manage().setTimeouts( { implicit: 32000 } )20 await driver.findElement(By.css("li#app- a[href*=\"app\"]")).click() // = Appearence = Внешний вид21 await driver.findElements(By.tagName("h1")) // h122 await driver.findElement(By.css("li#app- a[href*=\"log\"]")).click() // Logotype23 await driver.findElements(By.tagName("h1")) // h124 await driver.findElement(By.css("li#app- a[href*=\"cat\"]")).click() // = Catalog25 await driver.findElements(By.tagName("h1")) // h126 await driver.findElement(By.css("li#app- a[href*=\"duc\"]")).click() // Product Groups pro uct rod duc27 await driver.findElements(By.tagName("h1")) // h128 await driver.findElement(By.css("li#app- a[href*=\"opt\"]")).click() // Option Groups opti opt29 await driver.findElements(By.tagName("h1")) // h130 await driver.findElement(By.css("li#app- a[href*=\"man\"]")).click() // Manufacturers31 await driver.findElements(By.tagName("h1")) // h132 await driver.findElement(By.css("li#app- a[href*=\"upp\"]")).click() // Suppliers33 await driver.findElements(By.tagName("h1")) // h134 await driver.findElement(By.css("li#app- a[href*=\"del\"]")).click() // Delivery Statuses35 await driver.findElements(By.tagName("h1")) // h136 await driver.findElement(By.css("li#app- a[href*=\"sol\"]")).click() // Sold Out Statuses37 await driver.findElements(By.tagName("h1")) // h138 await driver.findElement(By.css("li#app- a[href*=\"qua\"]")).click() // Quantity Units39 await driver.findElements(By.tagName("h1")) // h140 await driver.findElement(By.css("li#app- a[href*=\"csv\"]")).click() // CSV Import/Export41 await driver.findElements(By.tagName("h1")) // h142 await driver.findElement(By.css("li#app- a[href*=\"cou\"]")).click() // = Countries43 await driver.findElements(By.tagName("h1")) // h144 await driver.findElement(By.css("li#app- a[href*=\"cur\"]")).click() // Currencies45 await driver.findElements(By.tagName("h1")) // h146 await driver.findElement(By.css("li#app- a[href$=\"ers\"]")).click() // = Customers cus47 await driver.findElements(By.tagName("h1")) // h148 await driver.findElement(By.css("li#app- a[href*=\"csv\"]")).click() // CSV Import/Export49 await driver.findElements(By.tagName("h1")) // h150 await driver.findElement(By.css("li#app- a[href*=\"newsl\"]")).click() // Newsletter51 await driver.findElements(By.tagName("h1")) // h152 await driver.findElement(By.css("li#app- a[href*=\"geo\"]")).click() // = Geo Zones53 await driver.findElements(By.tagName("h1")) // h154 await driver.findElement(By.css("li#app- a[href*=\"lan\"]")).click() // = Languages55 await driver.findElements(By.tagName("h1")) // h156 await driver.findElement(By.css("li#app- a[href*=\"tor\"]")).click() // Storage Encoding57 await driver.findElements(By.tagName("h1")) // h158 await driver.findElement(By.css("li#app- a[href*=\"mod\"]")).click() // = Modules59 await driver.findElements(By.tagName("h1")) // h160 await driver.findElement(By.css("li#app- a[href$=\"mer\"]")).click() // Customer mer61 await driver.findElements(By.tagName("h1")) // h162 await driver.findElement(By.css("li#app- a[href*=\"shi\"]")).click() // Shipping63 await driver.findElements(By.tagName("h1")) // h164 await driver.findElement(By.css("li#app- a[href*=\"pay\"]")).click() // Payment65 await driver.findElements(By.tagName("h1")) // h166 await driver.findElement(By.css("li#app- a[href*=\"tot\"]")).click() // Order Total67 await driver.findElements(By.tagName("h1")) // h168 await driver.findElement(By.css("li#app- a[href*=\"ucc\"]")).click() // Order Success69 await driver.findElements(By.tagName("h1")) // h170 await driver.findElement(By.css("li#app- a[href*=\"cti\"]")).click() // Order Action71 await driver.findElements(By.tagName("h1")) // h172 await driver.findElement(By.css("li#app- a[href*=\"ders\"]")).click() // = Orders73 await driver.findElements(By.tagName("h1")) // h174 await driver.findElement(By.css("li#app- a[href*=\"stat\"]")).click() // Order Statuses75 await driver.findElements(By.tagName("h1")) // h176 await driver.findElement(By.css("li#app- a[href*=\"pag\"]")).click() // = Pages77 await driver.findElements(By.tagName("h1")) // h178 await driver.findElement(By.css("li#app- a[href*=\"rep\"]")).click() // = Reports79 await driver.findElements(By.tagName("h1")) // h180 await driver.findElement(By.css("li#app- a[href*=\"mon\"]")).click() // Monthly Sales81 await driver.findElements(By.tagName("h1")) // h182 await driver.findElement(By.css("li#app- a[href*=\"produ\"]")).click() // Most Sold Products83 await driver.findElements(By.tagName("h1")) // h184 await driver.findElement(By.css("li#app- a[href*=\"hop\"]")).click() // Most Shopping Customers85 await driver.findElements(By.tagName("h1")) // h186 await driver.findElement(By.css("li#app- a[href*=\"tti\"]")).click() // = Settings87 await driver.findElements(By.tagName("h1")) // h188 await driver.findElement(By.css("li#app- a[href*=\"inf\"]")).click() // Store Info89 await driver.findElements(By.tagName("h1")) // h190 await driver.findElement(By.css("li#app- a[href*=\"ult\"]")).click() // Defaults91 await driver.findElements(By.tagName("h1")) // h192 await driver.findElement(By.css("li#app- a[href*=\"gen\"]")).click() // General93 await driver.findElements(By.tagName("h1")) // h194 await driver.findElement(By.css("li#app- a[href*=\"lis\"]")).click() // Listings95 await driver.findElements(By.tagName("h1")) // h196 await driver.findElement(By.css("li#app- a[href*=\"ima\"]")).click() // Images97 await driver.findElements(By.tagName("h1")) // h198 await driver.findElement(By.css("li#app- a[href*=\"che\"]")).click() // Checkout99 await driver.findElements(By.tagName("h1")) // h1100 await driver.findElement(By.css("li#app- a[href*=\"adv\"]")).click() // Advanced101 await driver.findElements(By.tagName("h1")) // h1102 await driver.findElement(By.css("li#app- a[href*=\"sec\"]")).click() // Security103 await driver.findElements(By.tagName("h1")) // h1104 await driver.findElement(By.css("li#app- a[href*=\"sli\"]")).click() // = Slides105 await driver.findElements(By.tagName("h1")) // h1106 await driver.findElement(By.css("li#app- a[href*=\"tax\"]")).click() // = Tax107 await driver.findElements(By.tagName("h1")) // h1108 await driver.findElement(By.css("li#app- a[href*=\"sse\"]")).click() // Tax Classes109 await driver.findElements(By.tagName("h1")) // h1110 await driver.findElement(By.css("li#app- a[href*=\"rat\"]")).click() // Tax Rates111 await driver.findElements(By.tagName("h1")) // h1112 await driver.findElement(By.css("li#app- a[href*=\"nsl\"]")).click() // = Translations113 await driver.findElements(By.tagName("h1")) // h1114 await driver.findElement(By.css("li#app- a[href*=\"sca\"]")).click() // Scan Files115 await driver.findElements(By.tagName("h1"))116 await driver.findElement(By.css("li#app- a[href*=\"csv\"]")).click() // CSV Import/Export117 await driver.findElements(By.tagName("h1"))118 await driver.findElement(By.css("li#app- a[href*=\"use\"]")).click() // = Users119 await driver.findElements(By.tagName("h1"))120 await driver.findElement(By.css("li#app- a[href*=\"vqm\"]")).click() // = VQmods121 await driver.findElements(By.tagName("h1"))122 })123 after(() => driver && driver.quit())124 })...

Full Screen

Full Screen

browser_steps.js

Source:browser_steps.js Github

copy

Full Screen

...7 return this.driver.get('http://localhost:3000/');8 });9 /* Scenario: Initialization */10 Then('I should see {int} graphics card slider with {int} rigs containing {int} GPUs each', function (expectedSliders, expectedRigs, expectedCards) {11 this.driver.findElements(By.className('GraphicsCardSlider')).then(sliders => {12 assert.equal(sliders.length, expectedSliders);13 sliders[0].findElements(By.className('GraphicsCardSlider-rig')).then(rigs => {14 assert.equal(rigs.length, expectedRigs);15 for (var i=0; i < rigs.length; i++) {16 rigs[i].findElements(By.className('GraphicsCardSlider-card')).then(cards => {17 assert.equal(cards.length, expectedCards);18 });19 }20 });21 });22 });23 Then('I should see {int} graphics cards pre-selected', function (preselectedCards) {24 this.driver.findElements(By.css('div.GraphicsCardSlider-card.selected')).then(selectedCards => {25 assert.equal(selectedCards.length, preselectedCards);26 });27 });28 /* Scenario: Changing slider value (hover) */29 When('I hover the mouse cursor over the {int} card slot', function (cardSlot) {30 this.driver.findElements(By.className('GraphicsCardSlider-card')).then(cards => {31 return this.driver.actions().mouseMove(cards[cardSlot-1], {x:5,y:5}).perform();32 });33 });34 Then('I should see the slider fill up to the {int} card slot', function (cardSlot) {35 this.driver.findElements(By.css('div.GraphicsCardSlider-card.selected')).then(selectedCards => {36 assert.equal(selectedCards.length, cardSlot);37 });38 });39 Then('I should see a tooltip with {int} graphics cards selected', function (cardSlot) {40 this.driver.findElements(By.css('div.GraphicsCardSlider-tooltip.show')).then(visibleTooltips => {41 assert.equal(visibleTooltips.length, 1);42 visibleTooltips[0].isDisplayed().then(displayed => {43 assert.equal(displayed, true);44 return visibleTooltips[0].getText();45 }).then(tooltipText => {46 assert.equal(tooltipText, cardSlot.toString());47 });48 })49 });50 /* Scenario: Changing slider value (click) */51 When('I click on the {int} card slot', function (cardSlot) {52 this.driver.findElements(By.className('GraphicsCardSlider-card')).then(cards => {53 return cards[cardSlot-1].click();54 });55 });56 Then('I should see {int} in the {string} field', function (cards, labelText) {57 var labelSelector = "//*[contains(text(),'" + labelText + "')]";58 this.driver.findElements(By.xpath(labelSelector)).then(label => {59 assert.equal(label.length, 1);60 return label[0].getAttribute('for');61 }).then(inputFieldId => {62 if (inputFieldId) {63 return this.driver.findElements(By.id(inputFieldId));64 } else {65 assert.fail("No 'for' attribute found on label element.");66 }67 }).then(inputField => {68 assert.equal(inputField.length,1);69 return inputField[0].getAttribute('value');70 }).then(inputFieldValue => {71 assert.equal(parseInt(inputFieldValue),cards);72 });73 });74 /* Scenario: Slider updates when value in text field */75 When('I enter {int} in the {string} field', function (cards, labelText) {76 var labelSelector = "//*[contains(text(),'" + labelText + "')]";77 this.driver.findElements(By.xpath(labelSelector)).then(label => {78 assert.equal(label.length, 1);79 return label[0].getAttribute('for');80 }).then(inputFieldId => {81 if (inputFieldId) {82 return this.driver.findElements(By.id(inputFieldId));83 } else {84 assert.fail("No 'for' attribute found on label element.");85 }86 }).then(inputField => {87 inputField[0].clear().then(() => {88 return inputField[0].sendKeys(cards.toString());89 });90 });91 });...

Full Screen

Full Screen

profile-spec.js

Source:profile-spec.js Github

copy

Full Screen

...17 $('.new-post').click();18 browser.driver.findElement(by.css('.post-forms > form > textarea')).sendKeys("New posts test");19 browser.driver.findElement(by.css('.post-forms > form > button')).click();20 browser.driver.sleep(500);21 browser.driver.findElements(by.css('.post')).then(function(posts){22 expect(posts[0].findElement(by.css('.post-text')).getText()).toEqual("New posts test");23 });24 browser.driver.sleep(500);25 });26 it('create comment', function() {27 browser.driver.findElements(by.css('.new-comment')).then(function(buttons){28 buttons[0].click();29 });30 browser.driver.findElement(by.css('.comment-forms > form > textarea')).sendKeys("New comment test");31 browser.driver.findElement(by.css('.comment-forms > form > button')).click();32 browser.driver.sleep(500);33 browser.driver.findElements(by.css('.comment')).then(function(comments){34 expect(comments[0].findElement(by.css('.comment-text')).getText()).toEqual("New comment test");35 });36 });37 it('add rating to post', function() {38 browser.driver.findElements(by.css('.like')).then(function(buttons){39 buttons[0].click();40 });41 browser.driver.sleep(100);42 browser.driver.findElements(by.css('.like')).then(function(ratings){43 expect(ratings[0].getText()).toEqual("1");44 });45 browser.driver.findElements(by.css('.like')).then(function(buttons){46 buttons[0].click();47 });48 browser.driver.findElements(by.css('.dislike')).then(function(buttons){49 buttons[0].click();50 });51 browser.driver.sleep(100);52 browser.driver.findElements(by.css('.like')).then(function(ratings){53 expect(ratings[0].getText()).toEqual("1");54 });55 browser.driver.findElements(by.css('.dislike')).then(function(ratings){56 expect(ratings[0].getText()).toEqual("0");57 });58 });59 it('delete comment', function() {60 browser.driver.findElements(by.css('.edit-comment')).then(function(buttons){61 buttons[0].click();62 });63 browser.driver.sleep(500);64 elem = $('.comment')65 expect(elem).toEqual(0);66 });67 it('delete post', function() {68 browser.driver.findElements(by.css('.edit-post')).then(function(buttons){69 buttons[0].click();70 });71 browser.driver.sleep(500);72 browser.driver.findElements(by.css('.post')).then(function(posts){73 expect(posts[0].getText()).not.toEqual("New posts test");74 });75 });76 it('show full size avatar', function() {77 browser.driver.findElements(by.css('.large-image')).then(function(images){78 expect(images[0].isDisplayed()).toEqual(false);79 $('.avatar').click();80 expect(images[0].isDisplayed()).toEqual(true);81 browser.driver.findElements(by.css('.img-hide')).then(function(buttons){82 buttons[0].click();83 });84 expect(images[0].isDisplayed()).toEqual(false);85 });86 });87 afterAll(function() {88 browser.get('/ant-eater');89 browser.driver.sleep(500);90 browser.actions().mouseMove($('.dropdown')).perform();91 browser.driver.findElements(by.css('.dropdown-menu > a')).then(function(nav){92 nav[1].click();93 });94 browser.driver.sleep(500);95 });...

Full Screen

Full Screen

index.integration.js

Source:index.integration.js Github

copy

Full Screen

...12 const title = await driver.getTitle();13 expect(title).toEqual("Awesome counter app");14 });15 it("has data from the server", async () => {16 const elements = await driver.findElements(By.tagName("h4"));17 const text = await elements[0].getText();18 expect(text).toEqual("GraphQL returned hello world with a response of 200");19 });20 it("finds buttons", async () => {21 const elements = await driver.findElements(By.tagName("button"));22 expect(elements.length).toEqual(2);23 });24 it("should find total count", async () => {25 const elements = await driver.findElements(By.tagName("span"));26 const text = await elements[0].getText();27 expect(text).toContain("0");28 });29 it("should identify platform web", async () => {30 const elements = await driver.findElements(By.tagName("span"));31 const text = await elements[0].getText();32 expect(text).toContain("web");33 });34 it("should increment with click on increment button", async () => {35 const [increment] = await driver.findElements(By.tagName("button"));36 increment.click();37 const [count] = await driver.findElements(By.tagName("span"));38 const text = await count.getText();39 expect(text).toContain("1");40 });41 it("should decrement with click on decrement button", async () => {42 const els = await driver.findElements(By.tagName("button"));43 const decrement = els[1];44 decrement.click();45 const [count] = await driver.findElements(By.tagName("span"));46 const text = await count.getText();47 expect(text).toContain("-1");48 });49 it("should allow to be decremented to negative values", async () => {50 const els = await driver.findElements(By.tagName("button"));51 const decrement = els[1];52 decrement.click();53 decrement.click();54 const [count] = await driver.findElements(By.tagName("span"));55 const text = await count.getText();56 expect(text).toContain("-2");57 });58 it("should follow multiple interactions", async () => {59 const [up, down] = await driver.findElements(By.tagName("button"));60 down.click();61 down.click();62 up.click();63 up.click();64 down.click();65 up.click();66 up.click();67 down.click();68 up.click();69 up.click();70 const [count] = await driver.findElements(By.tagName("span"));71 const text = await count.getText();72 expect(text).toContain("2");73 });...

Full Screen

Full Screen

gallery-spec.js

Source:gallery-spec.js Github

copy

Full Screen

...10 inputs[1].sendKeys("Truepass1");11 });12 browser.driver.findElement(by.css('.login-form > button')).click()13 browser.driver.sleep(1000);14 browser.driver.findElements(by.css('.main-menu > ul > a')).then(function(nav){15 nav[5].click()16 });17 browser.driver.sleep(500);18 });19 it('images count', function() {20 expect(browser.getCurrentUrl()).toBe(url);21 elem = $('.one-img')22 expect(elem).toEqual(9);23 });24 it('show full size image', function() {25 browser.driver.findElements(by.css('.large-image')).then(function(images){26 expect(images[0].isDisplayed()).toEqual(false);27 browser.driver.findElements(by.css('.icon > p > img')).then(function(imgs){28 imgs[3].click();29 elem = imgs[3];30 });31 expect(images[0].isDisplayed()).toEqual(true);32 images[0].findElements(by.tagName('img')).then(function(e) {33 expect(e[0].getAttribute('src')).toEqual(elem.getAttribute('src'));34 });35 browser.driver.findElements(by.css('.img-hide')).then(function(buttons){36 buttons[0].click();37 });38 expect(images[0].isDisplayed()).toEqual(false);39 });40 });41 it('nav next', function() {42 browser.driver.findElements(by.css('.large-image')).then(function(images){43 expect(images[0].isDisplayed()).toEqual(false);44 browser.driver.findElements(by.css('.icon > p > img')).then(function(imgs){45 imgs[3].click();46 elem = imgs[4];47 });48 expect(images[0].isDisplayed()).toEqual(true);49 browser.driver.findElements(by.css('.img-nav > .next')).then(function(nav){50 nav[0].click();51 });52 images[0].findElements(by.tagName('img')).then(function(e) {53 expect(e[0].getAttribute('src')).toEqual(elem.getAttribute('src'));54 });55 browser.driver.findElements(by.css('.img-hide')).then(function(buttons){56 buttons[0].click();57 });58 expect(images[0].isDisplayed()).toEqual(false);59 });60 });61 afterAll(function() {62 browser.get('/ant-eater');63 browser.driver.sleep(500);64 browser.actions().mouseMove($('.dropdown')).perform();65 browser.driver.findElements(by.css('.dropdown-menu > a')).then(function(nav){66 nav[1].click();67 });68 browser.driver.sleep(500);69 });...

Full Screen

Full Screen

By.js

Source:By.js Github

copy

Full Screen

...13 driver.quit();14 });15 describe('#className', function() {16 it('can be used', function() {17 driver.findElements(By.className('navbar')).length.should.equal(1);18 });19 });20 describe('#cssSelector', function() {21 it('can be used', function() {22 driver.findElements(By.cssSelector('body')).length.should.equal(1);23 });24 });25 describe('#id', function() {26 it('can be used', function() {27 driver.findElements(By.id('content')).length.should.equal(1);28 });29 });30 describe('#linkText', function() {31 it('can be used', function() {32 driver.findElements(By.linkText('GitHub')).length.should.equal(1);33 });34 });35 describe('#name', function() {36 it('can be used', function() {37 driver.findElements(By.name('viewport')).length.should.equal(1);38 });39 });40 describe('#partialLinkText', function() {41 it('can be used', function() {42 driver.findElements(43 By.partialLinkText('Download')44 ).length.should.equal(1);45 });46 });47 describe('#tagName', function() {48 it('can be used', function() {49 driver.findElements(By.tagName('div')).length.should.be.above(1);50 });51 });52 describe('#xpath', function() {53 it('can be used', function() {54 driver.findElements(By.xpath('//div')).length.should.be.above(1);55 });56 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var By = webdriver.By;3var until = webdriver.until;4var driver = new webdriver.Builder()5 .forBrowser('chrome')6 .build();7driver.findElement(By.name('q')).sendKeys('webdriver');8driver.findElement(By.name('btnK')).click();9driver.wait(until.titleIs('webdriver - Google Search'), 1000);10driver.quit();11var webdriver = require('selenium-webdriver');12var By = webdriver.By;13var until = webdriver.until;14var driver = new webdriver.Builder()15 .forBrowser('chrome')16 .build();17driver.findElement(By.name('q')).sendKeys('webdriver');18driver.findElement(By.name('btnK')).click();19driver.wait(until.titleIs('webdriver - Google Search'), 1000);20driver.quit();21var webdriver = require('selenium-webdriver');22var By = webdriver.By;23var until = webdriver.until;24var driver = new webdriver.Builder()25 .forBrowser('chrome')26 .build();27driver.findElement(By.name('q')).sendKeys('webdriver');28driver.findElement(By.name('btnK')).click();29driver.wait(until.titleIs('webdriver - Google Search'), 1000);30driver.quit();31var webdriver = require('selenium-webdriver');32var By = webdriver.By;33var until = webdriver.until;34var driver = new webdriver.Builder()35 .forBrowser('chrome')36 .build();37driver.findElement(By.name('q')).sendKeys('webdriver');38driver.findElement(By.name('btnK')).click();39driver.wait(until.titleIs('webdriver - Google Search'), 1000);40driver.quit();41var webdriver = require('selenium-webdriver');42var By = webdriver.By;43var until = webdriver.until;44var driver = new webdriver.Builder()45 .forBrowser('chrome')46 .build();47driver.findElement(By.name('q')).sendKeys('

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder().forBrowser('chrome').build();3driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');4driver.findElement(webdriver.By.name('btnG')).click();5driver.wait(function() {6 return driver.getTitle().then(function(title) {7 return title === 'webdriver - Google Search';8 });9}, 1000);10driver.quit();11var webdriver = require('selenium-webdriver');12var driver = new webdriver.Builder().forBrowser('firefox').build();13driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');14driver.findElement(webdriver.By.name('btnG')).click();15driver.wait(function() {16 return driver.getTitle().then(function(title) {17 return title === 'webdriver - Google Search';18 });19}, 1000);20driver.quit();21var webdriver = require('selenium-webdriver');22var driver = new webdriver.Builder().forBrowser('internet explorer').build();23driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');24driver.findElement(webdriver.By.name('btnG')).click();25driver.wait(function() {26 return driver.getTitle().then(function(title) {27 return title === 'webdriver - Google Search';28 });29}, 1000);30driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2}).build();3driver.findElement(webdriver.By.id('myButton')).click();4driver.findElements(webdriver.By.id('myButton')).then(function(elements) {5 console.log('Found ' + elements.length + ' elements with id "myButton"');6});7driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.findElements(By.id("com.jayway.calculator:id/button_0")).then(function(elements){2 console.log("Number of elements found: "+elements.length);3 for(var i=0; i<elements.length; i++){4 elements[i].click();5 }6});7driver.quit();

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 Appium Android Driver 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