How to use driver.elementByLinkText method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

safari-basic-e2e-specs.js

Source:safari-basic-e2e-specs.js Github

copy

Full Screen

...130 let el = await driver.elementByClassName('border');131 (await el.elementByXPath('./form')).should.exist;132 });133 it('should be able to click links', async () => {134 let el = await driver.elementByLinkText('i am a link');135 await el.click();136 await spinTitleEquals(driver, 'I am another page title');137 });138 it('should retrieve an element attribute', async () => {139 let el = await driver.elementById('i_am_an_id');140 (await el.getAttribute('id')).should.be.equal('i_am_an_id');141 expect(await el.getAttribute('blar')).to.be.null;142 });143 it('should retrieve implicit attributes', async () => {144 let els = await driver.elementsByTagName('option');145 els.should.have.length(3);146 (await els[2].getAttribute('index')).should.be.equal('2');147 });148 it('should retrieve an element text', async () => {149 let el = await driver.elementById('i_am_an_id');150 (await el.text()).should.be.equal('I am a div');151 });152 // TODO: figure out what equality means here153 it.skip('should check if two elements are equal', async () => {154 let el1 = await driver.elementById('i_am_an_id');155 let el2 = await driver.elementByCss('#i_am_an_id');156 el1.should.be.equal(el2);157 });158 it('should return the page source', async () => {159 let source = await driver.source();160 source.should.include('<html');161 source.should.include('I am a page title');162 source.should.include('i appear 3 times');163 source.should.include('</html>');164 });165 it('should get current url', async () => {166 (await driver.url()).should.include('test/guinea-pig');167 });168 it('should get updated URL without breaking window handles', async () => {169 let el = await driver.elementByLinkText('i am an anchor link');170 await el.click();171 (await driver.url()).should.contain('#anchor');172 (await driver.windowHandles()).should.be.ok;173 });174 it('should send keystrokes to specific element', async () => {175 let el = await driver.elementById('comments');176 await el.clear();177 await el.sendKeys('hello world');178 ['how world', 'hello world'].should.include((await el.getAttribute('value')).toLowerCase());179 });180 });181 describe('element handling', function () {182 beforeEach(async () => {183 await driver.get(GUINEA_PIG_PAGE);184 });185 it('should send keystrokes to active element', async () => {186 let el = await driver.elementById('comments');187 await el.click();188 await el.type('hello world');189 ['how world', 'hello world'].should.include((await el.getAttribute('value')).toLowerCase());190 });191 it('should clear element', async () => {192 let el = await driver.elementById('comments');193 await el.sendKeys('hello world');194 (await el.getAttribute('value')).should.have.length.above(0);195 await el.clear();196 (await el.getAttribute('value')).should.be.equal('');197 });198 it('should say whether an input is selected', async () => {199 let el = await driver.elementById('unchecked_checkbox');200 (await el.isSelected()).should.not.be.ok;201 await el.click();202 (await el.isSelected()).should.be.ok;203 });204 it('should be able to retrieve css properties', async () => {205 let el = await driver.elementById('fbemail');206 (await el.getComputedCss('background-color')).should.be.equal('rgba(255, 255, 255, 1)');207 });208 it('should retrieve an element size', async () => {209 let el = await driver.elementById('i_am_an_id');210 let size = await el.getSize();211 size.width.should.be.above(0);212 size.height.should.be.above(0);213 });214 it('should get location of an element', async () => {215 let el = await driver.elementById('fbemail');216 let loc = await el.getLocation();217 loc.x.should.be.above(0);218 loc.y.should.be.above(0);219 });220 // getTagName not supported by mjwp221 it.skip('should retrieve tag name of an element', async () => {222 let el = await driver.elementById('fbemail');223 let a = await driver.elementByCss('a');224 (await el.getTagName()).should.be.equal('input');225 (await a.getTagName()).should.be.equal('a');226 });227 it('should retrieve a window size', async () => {228 let size = await driver.getWindowSize();229 size.height.should.be.above(0);230 size.width.should.be.above(0);231 });232 it('should move to an arbitrary x-y element and click on it', async () => {233 let el = await driver.elementByLinkText('i am a link');234 await driver.moveTo(el, 5, 15);235 await el.click();236 await spinTitleEquals(driver, 'I am another page title');237 });238 it('should submit a form', async () => {239 let el = await driver.elementById('comments');240 let form = await driver.elementById('jumpContact');241 await el.sendKeys('This is a comment');242 await form.submit();243 await spinWait(async () => {244 let el = await driver.elementById('your_comments');245 (await el.text()).should.be.equal('Your comments: This is a comment');246 });247 });248 it('should return true when the element is displayed', async () => {249 let el = await driver.elementByLinkText('i am a link');250 (await el.isDisplayed()).should.be.ok;251 });252 it('should return false when the element is not displayed', async () => {253 let el = await driver.elementById('invisible div');254 (await el.isDisplayed()).should.not.be.ok;255 });256 it('should return true when the element is enabled', async () => {257 let el = await driver.elementByLinkText('i am a link');258 (await el.isEnabled()).should.be.ok;259 });260 it('should return false when the element is not enabled', async () => {261 let el = await driver.elementById('fbemail');262 await driver.execute(`$('#fbemail').attr('disabled', 'disabled');`);263 (await el.isEnabled()).should.not.be.ok;264 });265 it('should return the active element', async () => {266 let testText = 'hi there';267 let el = await driver.elementById('i_am_a_textbox');268 await el.sendKeys(testText);269 let activeEl = await driver.active();270 (await activeEl.getAttribute('value')).should.be.equal(testText);271 });272 it('should properly navigate to anchor', async () => {273 let el = await driver.elementByLinkText('i am an anchor link');274 await el.click();275 let url = await driver.url();276 await driver.get(url);277 (await driver.url()).should.include('#anchor');278 });279 it('should be able to refresh', async () => {280 await driver.refresh();281 });282 });283 });284 describe('safariIgnoreFraudWarning', () => {285 describe('false', function () {286 before(async () => {287 await driver.init(_.defaults({...

Full Screen

Full Screen

basics-base.js

Source:basics-base.js Github

copy

Full Screen

...160 size.width.should.be.above(0);161 }).nodeify(done);162 });163 it('should move to an arbitrary x-y element and click on it', function (done) {164 driver.elementByLinkText('i am a link')165 .moveTo(5, 15)166 .click()167 .then(function () { return spinTitle("I am another page title", driver); })168 .nodeify(done);169 });170 it('should submit a form', function (done) {171 driver172 .elementById('comments')173 .sendKeys('This is a comment')174 .submit()175 .then(function () {176 return spinWait(function () {177 return driver178 .elementById('your_comments')...

Full Screen

Full Screen

safari-window-e2e-specs.js

Source:safari-window-e2e-specs.js Github

copy

Full Screen

...63 await B.delay(3000);64 await spinTitleEquals(driver, 'I am a page title');65 });66 it('should be able to go back and forward', async () => {67 let link = await driver.elementByLinkText('i am a link');68 await link.click();69 await driver.elementById('only_on_page_2');70 await driver.back();71 await driver.elementById('i_am_a_textbox');72 await driver.forward();73 await driver.elementById('only_on_page_2');74 await driver.back();75 });76 // broken on real devices, see https://github.com/appium/appium/issues/516777 it('should be able to open js popup windows with safariAllowPopups set to true @skip-real-device', async () => {78 let link = await driver.elementByLinkText('i am a new window link');79 await link.click();80 await spinTitleEquals(driver, 'I am another page title', 30);81 });82 });83 describe('frames', function () {84 beforeEach(async () => {85 await driver.get(GUINEA_PIG_FRAME_PAGE);86 });87 it('should switch to frame by name', async () => {88 await driver.frame('first');89 (await driver.title()).should.be.equal('Frameset guinea pig');90 let h1 = await driver.elementByTagName('h1');91 (await h1.text()).should.be.equal('Sub frame 1');92 });...

Full Screen

Full Screen

safari-nativewebtap-e2e-specs.js

Source:safari-nativewebtap-e2e-specs.js Github

copy

Full Screen

...35 await killAllSimulators();36 });37 it('should be able to tap on an element', async function () {38 await driver.get(GUINEA_PIG_PAGE);39 let el = await driver.elementByLinkText('i am a link to page 3');40 await el.click();41 await spinTitleEquals(driver, 'Another Page: page 3', spinRetries);42 });43 it('should be able to tap on an element when the app banner is up', async function () {44 await driver.get(GUINEA_PIG_APP_BANNER_PAGE);45 let el = await driver.elementByLinkText('i am a link to page 3');46 await el.click();47 await spinTitleEquals(driver, 'Another Page: page 3', spinRetries);48 });49 it('should be able to tap on an element after scrolling', async function () {50 await driver.get(GUINEA_PIG_SCROLLABLE_PAGE);51 await driver.execute('mobile: scroll', {direction: 'down'});52 let el = await driver.elementByLinkText('i am a link to page 3');53 await el.click();54 await spinTitleEquals(driver, 'Another Page: page 3', spinRetries);55 });56 describe('with tabs -', function () {57 beforeEach(async function () {58 await driver.get(GUINEA_PIG_PAGE);59 });60 before(async function () {61 await driver.get(GUINEA_PIG_PAGE);62 // open a new tab and go to it63 let el = await driver.elementByLinkText('i am a new window link');64 await el.click();65 });66 it('should be able to tap on an element', async function () {67 await driver.get(GUINEA_PIG_PAGE);68 let el = await driver.elementByLinkText('i am a link to page 3');69 await el.click();70 await spinTitleEquals(driver, 'Another Page: page 3', spinRetries);71 await driver.back();72 // try again, just to make sure73 el = await driver.elementByLinkText('i am a link to page 3');74 await el.click();75 await spinTitleEquals(driver, 'Another Page: page 3', spinRetries);76 });77 it('should be able to tap on an element after scrolling', async function () {78 await driver.get(GUINEA_PIG_SCROLLABLE_PAGE);79 await driver.execute('mobile: scroll', {direction: 'down'});80 let el = await driver.elementByLinkText('i am a link to page 3');81 await el.click();82 await spinTitleEquals(driver, 'Another Page: page 3', spinRetries);83 });84 it('should be able to tap on an element after scrolling, when the url bar is present', async function () {85 await driver.get(GUINEA_PIG_SCROLLABLE_PAGE);86 await driver.execute('mobile: scroll', {direction: 'down'});87 let el = await driver.elementByLinkText('i am a link to page 3');88 await el.click();89 await spinTitleEquals(driver, 'Another Page: page 3', spinRetries);90 // going back will reveal the full url bar91 await driver.back();92 await B.delay(500);93 // make sure we get the correct position again94 el = await driver.elementByLinkText('i am a link to page 3');95 await el.click();96 await spinTitleEquals(driver, 'Another Page: page 3', spinRetries);97 });98 });99 });100 }101 // Full tests take a *long* time so skip unless necessary to check conversion102 // // xcode 8.3103 // const deviceNames = ['iPhone 5', 'iPhone 5s',104 // 'iPhone 6', 'iPhone 6 Plus',105 // 'iPhone 6s', 'iPhone 6s Plus',106 // 'iPhone 7', 'iPhone 7 Plus',107 // 'iPhone SE',108 // 'iPad Air', 'iPad Air 2',...

Full Screen

Full Screen

windows-frame-specs.js

Source:windows-frame-specs.js Github

copy

Full Screen

1"use strict";2var env = require('../../../helpers/env')3 , setup = require("../../common/setup-base")4 , webviewHelper = require("../../../helpers/webview")5 , loadWebView = webviewHelper.loadWebView6 , spinTitle = webviewHelper.spinTitle;7describe('safari - windows and frames (' + env.DEVICE + ') @skip-ios6"', function () {8 var driver;9 var desired = {10 browserName: 'safari',11 nativeWebTap: true,12 safariAllowPopups: true13 };14 setup(this, desired).then(function (d) { driver = d; });15 describe('within webview', function () {16 beforeEach(function (done) {17 loadWebView("safari", driver).nodeify(done);18 });19 it("should throw nosuchwindow if there's not one", function (done) {20 driver21 .window('noexistman')22 .should.be.rejectedWith(/status: 23/)23 .nodeify(done);24 });25 it("should be able to open and close windows @skip-ios8", function (done) {26 // unfortunately, iOS8 doesn't respond to the close() method on window27 // the way iOS7 does28 driver29 .elementById('blanklink').click()30 .then(function () { return spinTitle("I am another page title", driver); })31 .windowHandles()32 .then(function (handles) {33 return driver34 .sleep(2000).close().sleep(3000)35 .windowHandles()36 .should.eventually.be.below(handles.length);37 }).then(function () { return spinTitle("I am a page title", driver); })38 .nodeify(done);39 });40 it('should be able to go back and forward', function (done) {41 driver42 .elementByLinkText('i am a link')43 .click()44 .elementById('only_on_page_2')45 .back()46 .elementById('i_am_a_textbox')47 .forward()48 .elementById('only_on_page_2')49 .nodeify(done);50 });51 // broken on real devices, see https://github.com/appium/appium/issues/516752 it("should be able to open js popup windows with safariAllowPopups set to true @skip-real-device", function (done) {53 driver54 .elementByLinkText('i am a new window link')55 .click()56 .then(function () { return spinTitle("I am another page title", driver, 30); })57 .nodeify(done);58 });59 });60});61describe('safari - windows and frames (' + env.DEVICE + ') @skip-ios6 - without safariAllowPopups', function () {62 var driver;63 var desired = {64 browserName: 'safari',65 safariAllowPopups: false66 };67 setup(this, desired).then(function (d) { driver = d; });68 beforeEach(function (done) {69 loadWebView("safari", driver).nodeify(done);70 });71 it("should not be able to open js popup windows with safariAllowPopups set to false", function (done) {72 driver73 .execute("window.open('/test/guinea-pig2.html', null);")74 .then(function () { return spinTitle("I am another page title", driver, 15); })75 .should.eventually.be.rejectedWith("Title never became 'I am another")76 .nodeify(done);77 });...

Full Screen

Full Screen

jetpack-compose-e2e-specs.js

Source:jetpack-compose-e2e-specs.js Github

copy

Full Screen

...28 await e.isDisplayed().should.eventually.be.true;29 let elementWithDescription = await driver.elementByAccessibilityId('desc');30 await elementWithDescription.text().should.eventually.equal('Click to see dialog');31 await elementWithDescription.isDisplayed().should.eventually.be.true;32 let clickableText = await driver.elementByLinkText('Click to see dialog');33 await clickableText.click();34 await driver.elementByLinkText('Congratulations! You just clicked the text successfully');35 await driver.settings().should.eventually.eql({ driver: 'compose' });36 });37 it('should find element by xpath', async function () {38 await driver.updateSettings({ driver: 'espresso' });39 let el = await driver.elementByXPath("//*[@text='Clickable Component']");40 await driver.moveTo(el);41 await el.click();42 await driver.updateSettings({ driver: 'compose' });43 let e = await driver.elementByXPath("//*[@view-tag='lol']//*[@content-desc='desc']");44 await e.text().should.eventually.equal('Click to see dialog');45 });46 it('should find elements', async function () {47 await driver.updateSettings({ driver: 'espresso' });48 let el = await driver.elementByXPath("//*[@text='Horizontal Carousel']");...

Full Screen

Full Screen

element.js

Source:element.js Github

copy

Full Screen

...21 yield driver.quit();22 });23 it('should click and get text', function*() {24 yield driver.get(baseUrl + "guinea-pig.html");25 var anchor = yield driver.elementByLinkText("i am a link");26 (yield anchor.text()).should.equal("i am a link");27 yield anchor.click();28 (yield driver.title()).should.equal("I am another page title");29 });30 it('should work getting els from els', function*() {31 yield driver.back();32 var div = yield driver.elementById('the_forms_id');33 var anchor = yield div.elementByTagName('p');34 var input = yield anchor.elementByTagName('input');35 var text = yield input.getAttribute('value');36 text.should.equal("i has no focus");37 });38 origIt('should fail when an element is not there', function(done) {39 driver.run(function*() {40 var e;41 try {42 yield driver.elementById('donotexistman');43 } catch (err) {44 e = err;45 }46 e.message.should.include("7");47 yield driver.elementByTagName("nowaydude");48 }).nodeify(function(err) {49 should.exist(err);50 err.message.should.include("NoSuchElement");51 done();52 });53 });54 it('should defer findElement if requested', function*() {55 yield driver.get(baseUrl + "guinea-pig.html");56 yield driver.elementByLinkText("i am a link").click();57 (yield driver.title()).should.equal("I am another page title");58 yield driver.back();59 var text = yield driver.elementByTagName('body').elementById('the_forms_id')60 .elementByTagName('input').getValue();61 text.should.equal("i has no focus");62 });...

Full Screen

Full Screen

jetpack-compose-attributes-e2e-specs.js

Source:jetpack-compose-attributes-e2e-specs.js Github

copy

Full Screen

...26 let taggedElement = await driver.elementByTagName('lol');27 await taggedElement.getAttribute('view-tag').should.eventually.equal('lol');28 });29 it(`should get the 'text' of a View`, async function () {30 let el = await driver.elementByLinkText('Click to see dialog');31 await el.getAttribute('text').should.eventually.equal('Click to see dialog');32 });33 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var desired = {4};5driver.init(desired).then(function () {6}).then(function () {7 return driver.elementByLinkText('Images');8}).then(function (el) {9 return el.click();10}).then(function () {11 return driver.title();12}).then(function (title) {13 assert.ok(title.indexOf('Images') !== -1);14}).fin(function () {15 return driver.quit();16}).done();17{18 "scripts": {19 },20 "dependencies": {21 }22}

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .elementByLinkText('Gmail')9 .click()10 .getTitle().then(function(title) {11 console.log('Title was: ' + title);12 })13 .end();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var asserters = wd.asserters;3var desired = {4};5var browser = wd.promiseChainRemote('localhost', 4723);6 .init(desired)7 .elementByLinkText('Appium').click()8 .sleep(5000)9 .quit();10from appium import webdriver11desired_caps = {}12driver.find_element_by_link_text('Appium').click()13driver.quit()14#code to use driver.find_element(:link_text, 'Appium') method of Appium Xcuitest Driver15desired_caps = {}16driver = Appium::Driver.new({caps: desired_caps})17driver.find_element(:link_text, 'Appium').click()

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var capabilities = {3};4 .init(capabilities)5 .then(function() {6 return driver.elementByLinkText('testlink');7 })8 .then(function(element) {9 console.log(element);10 })11 .fin(function() { return driver.quit(); })12 .done();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var desired = require('./desired');4describe('WebdriverIO', function () {5 this.timeout(300000);6 var driver;7 before(function () {8 driver = wd.promiseChainRemote('localhost', 4723);9 desired.platformName = 'iOS';10 desired.platformVersion = '10.2';11 desired.deviceName = 'iPhone 6';12 desired.browserName = 'Safari';13 desired.autoWebview = true;14 return driver.init(desired);15 });16 after(function () {17 return driver.quit();18 });19 it('should find a link and click on it', function () {20 .elementByLinkText('Docs')21 .click();22 });23});24module.exports = {25};26driver.findElement(By.linkText("link text")).click();27driver.findElement(By.linkText("link text")).click();28driver.findElement(By

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var desired = {4};5 .init(desired)6 .elementByLinkText('Buttons')7 .click()8 .sleep(3000)9 .quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3driver.init({4}).then(function(){5 return driver.elementByLinkText("Click me to see an alert");6}).then(function(el){7 return el.click();8}).then(function(){9 return driver.elementByName("OK");10}).then(function(el){11 return el.click();12}).then(function(){13 return driver.quit();14}).done();15var wd = require('wd');16var assert = require('assert');17driver.init({18}).then(function(){19 return driver.elementByLinkText("Click me to see an alert");20}).then(function(el){21 return el.click();22}).then(function(){23 return driver.elementByName("OK");24}).then(function(el){25 return el.click();26}).then(function(){

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 Xcuitest Driver automation tests on LambdaTest cloud grid

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

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful