How to use element.getTagName method in Appium

Best JavaScript code snippet using appium

elementhelper.spec.js

Source:elementhelper.spec.js Github

copy

Full Screen

...18 expect(result).to.be.eql(helper.masterPO['/home']);19 });20 it('should search for an element by its full path', async () => {21 const element = await helper.getElement('Header > Country Bar > Global Icon');22 const tag = await element.getTagName();23 expect(tag).to.be.eql('span')24 });25 it('should find element on the page and perform check', async () => {26 const element = await helper.getElement('Header > Country Bar > Global Icon');27 const result = await element.isPresent();28 expect(result).to.be.true;29 });30 it('should find an element from collection by its number', async () => {31 let el = await helper.getElement('Product List > Results Panel > Search Results #2 > Button #2');32 const text = await el.getText();33 expect(text).to.be.eql('Learn More');34 });35 it('should find an element from collection by "first"', async () => {36 let el = await helper.getElement('Product List > Results Panel > first Search Results > first Button');37 const text = await el.getText();38 expect(text).to.be.eql('Buy Now');39 });40 it('should find an element from collection by "second"', async () => {41 let el = await helper.getElement('Product List > Results Panel > second Search Results > second Button');42 const text = await el.getText();43 expect(text).to.be.eql('Learn More');44 });45 it('should find an element from collection by "last"', async () => {46 let el = await helper.getElement('Product List > Results Panel > last Search Results > last Button');47 const text = await el.getText();48 expect(text).to.be.eql('Learn More');49 });50 it('should throw an error when getting an element that is not a collection by index', async () => {51 return expect(helper.getElement('Header > Country Bar #2')).to.eventually.be.rejectedWith(Error, 'Error in getting #2 instance of [#country] - not a collection!');52 });53 it('should throw an error if there is no such child in an element', async () => {54 return expect(helper.getElement('Header > nonexistent')).to.eventually.be.rejectedWith(Error, 'No child element [nonexistent] in { selector: \'header\',\n children: { \'Country Bar\': [Object], \'Navigation Bar\': [Object] } }');55 });56 it('should complete an unfinished element chain', () => {57 const result = helper.findElementInChain(helper.masterPO['/about'], 'Copyright Links');58 expect(result).to.eql('Copyright Footer > Copyright Links Bar > Copyright Links');59 });60 it('should search for an element by an unfinished chain', async () => {61 let element = await helper.getElement('Header > Global Icon');62 const tag = await element.getTagName();63 expect(tag).to.be.eql('span')64 });65 describe('tests that change url', () => {66 afterEach(async () => {67 await browser.get('https://www.sandisk.com/home');68 });69 it('should throw an error if there is no page object for current url', async () => {70 await browser.get('https://www.sandisk.com/home/ssd/extreme-portable-ssd');71 return expect(helper.getPageObject()).to.eventually.be.rejectedWith(Error, 'No Page Object found for [/home/ssd/extreme-portable-ssd]!');72 })73 })...

Full Screen

Full Screen

elementUtils.js

Source:elementUtils.js Github

copy

Full Screen

...14 * @param {WebElement} element The WebElement to get the description of15 * @returns {Promise<Object>}16 */17export const getElementDescription = async (element) => ({18 tagName: await element.getTagName(),19 id: await element.getId(),20 css: await element.getCssValue(),21 value: await element.getAttribute('value'),22 text: await element.getText(),23 outerHTML: await element.getAttribute('outerHTML'),24});25/**26 * Ensures item in instance of a Selenium WebElement, else throws Error27 * @param {*} item The item to check28 * @returns {WebElement}29 */30export const ensureIsWebElement = (item) => {31 if (item instanceof WebElement) {32 return item;...

Full Screen

Full Screen

delegates-focus-focus-method-on-internal-element.spec.js

Source:delegates-focus-focus-method-on-internal-element.spec.js Github

copy

Full Screen

1/*2 * Copyright (c) 2018, salesforce.com, inc.3 * All rights reserved.4 * SPDX-License-Identifier: MIT5 * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT6 */7const assert = require('assert');8const URL = '/delegates-focus-focus-method-on-internal-element';9describe('Invoking the focus method on an element inside a shadow tree', () => {10 beforeEach(async () => {11 await browser.url(URL);12 });13 it('should apply focus (tabindex -1)', async () => {14 // Click the top input to give the focus event's relatedTarget a15 // non-null value so that we enter the code path that we want to test.16 const input = await browser.shadowDeep$(17 'integration-delegates-focus-focus-method-on-internal-element',18 '.head'19 );20 await input.click();21 const target = await browser.shadowDeep$(22 'integration-delegates-focus-focus-method-on-internal-element',23 'integration-button.negative'24 );25 await target.focus();26 const activeElement = await browser.activeElementShadowDeep();27 assert.strictEqual(await activeElement.getTagName(), 'button');28 });29 it('should apply focus (tabindex 0)', async () => {30 // Click the top input to give the focus event's relatedTarget a31 // non-null value so that we enter the code path that we want to test.32 const head = await browser.shadowDeep$(33 'integration-delegates-focus-focus-method-on-internal-element',34 '.head'35 );36 await head.click();37 const target = await browser.shadowDeep$(38 'integration-delegates-focus-focus-method-on-internal-element',39 'integration-button.zero'40 );41 await target.focus();42 const activeElement = await browser.activeElementShadowDeep();43 assert.strictEqual(await activeElement.getTagName(), 'button');44 });45 it('should apply focus (no tabindex)', async () => {46 // Click the top input to give the focus event's relatedTarget a47 // non-null value so that we enter the code path that we want to test.48 const head = await browser.shadowDeep$(49 'integration-delegates-focus-focus-method-on-internal-element',50 '.head'51 );52 await head.click();53 const target = await browser.shadowDeep$(54 'integration-delegates-focus-focus-method-on-internal-element',55 'integration-button.none'56 );57 await target.focus();58 const activeElement = await browser.activeElementShadowDeep();59 assert.strictEqual(await activeElement.getTagName(), 'button');60 });...

Full Screen

Full Screen

focus.test.js

Source:focus.test.js Github

copy

Full Screen

...19 expect(text).toBe("bar");20 // tabbing again makes the body active21 await driver.actions().sendKeys(TAB).perform();22 element = await driver.switchTo().activeElement();23 expect(await element.getTagName()).toBe("body");24 // tabbing again selects the first item25 await driver.actions().sendKeys(TAB).perform();26 element = await driver.switchTo().activeElement();27 text = await element.getText();28 expect(text).toBe("foo");29 });30 test("programmatic changing focus", async () => {31 await render(<div>32 <button id="foo">foo</button>33 <button id="bar">bar</button>34 </div>);35 const focus = async (element) => 36 await driver.executeScript((element) => {37 element.focus();38 }, element);39 const blur = async (element) => 40 await driver.executeScript((element) => {41 element.blur();42 }, element);43 const foo = await driver.findElement(By.id("foo"));44 const bar = await driver.findElement(By.id("bar"));45 let element;46 await focus(foo);47 element = await driver.switchTo().activeElement();48 expect(await element.getText()).toBe("foo");49 await blur(foo);50 element = await driver.switchTo().activeElement();51 expect(await element.getTagName()).toBe("body");52 await focus(bar);53 element = await driver.switchTo().activeElement();54 expect(await element.getText()).toBe("bar");55 });...

Full Screen

Full Screen

unStalenessOf.js

Source:unStalenessOf.js Github

copy

Full Screen

...3var chalk = require("chalk");4module.exports = function (element) {5 return new until.Condition('element to become not stale', function () {6 console.log(chalk.bold.yellow("Getting tag name of element..."));7 return element.getTagName().then(8 function (tagName) {9 console.log(chalk.bold.yellow("Tag name resolved as '" + tagName + "'"));10 return true;11 },12 function (e) {13 if (e.code === bot.ErrorCode.STALE_ELEMENT_REFERENCE) {14 return false;15 }16 throw e;17 });18 });...

Full Screen

Full Screen

Text.driver.js

Source:Text.driver.js Github

copy

Full Screen

1const textDriverFactory = ({ element }) => {2 return {3 exists: () => !!element,4 getTagName: () => element.tagName.toLowerCase(),5 getText: () => element.innerHTML,6 getSize: () => element.getAttribute('data-size'),7 getSkin: () => element.getAttribute('data-skin'),8 getWeight: () => element.getAttribute('data-weight'),9 isLight: () => element.getAttribute('data-light') === 'true',10 isSecondary: () => element.getAttribute('data-secondary') === 'true',11 };12};...

Full Screen

Full Screen

HTMLDivElement.js

Source:HTMLDivElement.js Github

copy

Full Screen

1/* eslint-disable class-methods-use-this */2import HTMLPairElement from './HTMLPairElement.js';3// BEGIN (write your solution here)4class HTMLDivElement extends HTMLPairElement {5 getTagName() {6 return 'div';7 }8}9// END...

Full Screen

Full Screen

elementname_test.js

Source:elementname_test.js Github

copy

Full Screen

1function testShouldReturnInput(driver) {2 driver.get(TEST_PAGES.formPage);3 var element = driver.findElement({id: 'cheese'});4 assertThat(element.getTagName(), is('input'));...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3var client = webdriverio.remote(options);4 .init()5 .getTitle().then(function(title) {6 console.log('Title was: ' + title);7 })8 .end();

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('btnG')).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('btnG')).click();19driver.wait(until.titleIs('webdriver - Google Search'), 1000);20driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var assert = require('assert');3var By = webdriver.By;4var until = webdriver.until;5var driver = new webdriver.Builder()6 .forBrowser('chrome')7 .build();8driver.findElement(By.name('q')).sendKeys('webdriver');9driver.findElement(By.name('btnG')).click();10driver.wait(until.titleIs('webdriver - Google Search'), 1000);11driver.quit();12var webdriver = require('selenium-webdriver');13var assert = require('assert');14var By = webdriver.By;15var until = webdriver.until;16var driver = new webdriver.Builder()17 .forBrowser('chrome')18 .build();19driver.findElement(By.name('q')).sendKeys('webdriver');20driver.findElement(By.name('btnG')).click();21driver.wait(until.titleIs('webdriver - Google Search'), 1000);22driver.findElement(By.css("h3.r a")).getAttribute('href').then(function(text){23 console.log(text);24});25driver.quit();26var webdriver = require('selenium-webdriver');27var assert = require('assert');28var By = webdriver.By;29var until = webdriver.until;30var driver = new webdriver.Builder()31 .forBrowser('chrome')32 .build();33driver.findElement(By.name('q')).sendKeys('webdriver');34driver.findElement(By.name('btnG')).click();35driver.wait(until.titleIs('webdriver - Google Search'), 1000);36driver.findElement(By.css("h3.r a")).getText().then(function(text){37 console.log(text);38});39driver.quit();40var webdriver = require('selenium-webdriver');41var assert = require('assert');42var By = webdriver.By;43var until = webdriver.until;44var driver = new webdriver.Builder()45 .forBrowser('chrome')46 .build();47driver.findElement(By.name('q')).sendKeys('webdriver');48driver.findElement(By.name('btnG')).click();49driver.wait(until.titleIs('webdriver - Google Search'), 1000);50driver.findElement(By.css("h3.r a")).isDisplayed().then(function(text){

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3 .remote(options)4 .init()5 .getTitle().then(function(title) {6 console.log('Title was: ' + title);7 })8 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Get tag name', function () {2 it('should get the tag name', function () {3 .elementById('buttonTestCD')4 .getTagName().should.become('android.widget.Button')5 });6});7describe('Get attribute', function () {8 it('should get the attribute', function () {9 .elementById('buttonTestCD')10 .getAttribute('name').should.become('ComputeSumButton')11 });12});13describe('Get location', function () {14 it('should get the location', function () {15 .elementById('buttonTestCD')16 .getLocation().should.become({x: 0, y: 0})17 });18});19describe('Get size', function () {20 it('should get the size', function () {21 .elementById('buttonTestCD')22 .getSize().should.become({width: 0, height: 0})23 });24});25describe('Get text', function () {26 it('should get the text', function () {27 .elementById('buttonTestCD')28 .getText().should.become('Compute Sum')29 });30});31describe('Is displayed', function () {32 it('should get the displayed status', function () {33 .elementById('buttonTestCD')34 .isDisplayed().should.become(true)35 });36});37describe('Is enabled', function () {38 it('should get the enabled status', function () {39 .elementById('buttonTestCD')40 .isEnabled().should.become(true)41 });42});43describe('Is selected', function () {44 it('should get the selected status', function () {45 .elementById('buttonTestCD')

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