How to use this.getAtomsElement method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

web.js

Source:web.js Github

copy

Full Screen

...142 let script = `document.cookie = ${JSON.stringify(webCookie)}`;143 await this.executeAtom('execute_script', [script, []]);144};145extensions.findWebElementOrElements = async function (strategy, selector, many, ctx) {146 let atomsElement = this.getAtomsElement(ctx);147 let element;148 let doFind = async () => {149 element = await this.executeAtom(`find_element${many ? 's' : ''}`, [strategy, selector, atomsElement], true);150 return !_.isNull(element);151 };152 try {153 await this.implicitWaitForCondition(doFind);154 } catch (err) {155 if (err.message && err.message.match(/Condition unmet/)){156 // condition was not met setting res to empty array157 element = [];158 } else {159 throw err;160 }161 }162 if (many) {163 return element;164 } else {165 if (!element || _.size(element) === 0) {166 throw new errors.NoSuchElementError();167 }168 return element;169 }170};171extensions.webFlickElement = async function (el, xoffset, yoffset) {172 let atomsElement = await this.useAtomsElement(el);173 let {x, y} = await this.executeAtom('get_top_left_coordinates', [atomsElement]);174 let {width, height} = await this.executeAtom('get_size', [atomsElement]);175 // translate to proper coordinates176 x = x + (width / 2);177 y = y + (height / 2);178 let from = await this.translateWebCoords({x, y});179 let to = await this.translateWebCoords({x: x + xoffset, y: y + yoffset});180 let args = {from, to};181 let command = `au.flick(${JSON.stringify(args)})`;182 await this.uiAutoClient.sendCommand(command);183};184extensions.mobileWebNav = async function (navType) {185 this.remote.allowNavigationWithoutReload();186 await this.executeAtom('execute_script', [`history.${navType}();`, null]);187};188extensions.nativeWebTap = async function (el) {189 let atomsElement = this.useAtomsElement(el);190 let {x, y} = await this.executeAtom('get_top_left_coordinates', [atomsElement]);191 let {width, height} = await this.executeAtom('get_size', [atomsElement]);192 x = x + (width / 2);193 y = y + (height / 2);194 this.curWebCoords = {x, y};195 await this.clickWebCoords();196 // make sure real tap actually has time to register197 await B.delay(500);198};199extensions.clickWebCoords = async function () {200 let coords = await this.translateWebCoords(this.curWebCoords);201 await this.clickCoords(coords);202};203extensions.translateWebCoords = async function (coords) {204 logger.debug(`Translating coordinates (${JSON.stringify(coords)}) to web coordinates`);205 let wvCmd = 'au.getElementsByType(\'webview\')';206 let webviewIndex = this.webContextIndex();207 // add static offset for safari in landscape mode208 let yOffset = this.curOrientation === 'LANDSCAPE' ? this.landscapeWebCoordsOffset : 0;209 // absolutize web coords210 let webviews = await this.uiAutoClient.sendCommand(wvCmd);211 if (webviews.length < 1) {212 throw new errors.UnknownError.code('Could not find any webviews to click inside!');213 }214 if (_.isUndefined(webviews[webviewIndex])) {215 logger.warn(`Could not find webview at index ${webviewIndex}, taking ` +216 `last available one for clicking purposes`);217 webviewIndex = webviews.length - 1;218 }219 let wvId = webviews[webviewIndex].ELEMENT;220 let locCmd = `au.getElement('${wvId}').rect()`;221 let rect = await this.uiAutoClient.sendCommand(locCmd);222 let wvPos = {x: rect.origin.x, y: rect.origin.y};223 let realDims = {w: rect.size.width, h: rect.size.height};224 let cmd = '(function () { return {w: document.width, h: document.height}; })()';225 let {w, h} = await this.remote.execute(cmd);226 let wvDims = {w, h};227 if (wvDims && realDims && wvPos) {228 let xRatio = realDims.w / wvDims.w;229 let yRatio = realDims.h / wvDims.h;230 let serviceBarHeight = 20;231 if (parseFloat(this.opts.platformVersion) >= 8) {232 // ios8 includes the service bar height in the app233 serviceBarHeight = 0;234 }235 let newCoords = {236 x: wvPos.x + Math.round(xRatio * coords.x)237 , y: wvPos.y + yOffset + Math.round(yRatio * coords.y) - serviceBarHeight238 };239 logger.debug(`Converted web coords ${JSON.stringify(coords)} ` +240 `into real coords ${JSON.stringify(newCoords)}`);241 return newCoords;242 }243};244helpers.clickCoords = async function (coords) {245 if (this.useRobot) {246 // var tapUrl = this.args.robotUrl + "/tap";247 // request.post({url:tapUrl, form: {x:coords.x, y:coords.y}}, cb);248 /*TODO*/throw new errors.NotYetImplementedError();249 } else {250 let opts = coords;251 opts.tapCount = 1;252 opts.duration = 0.3;253 opts.touchCount = 1;254 let command = `au.complexTap(${JSON.stringify(opts)})`;255 await this.uiAutoClient.sendCommand(command);256 }257};258helpers.executeAtom = async function (atom, args, alwaysDefaultFrame = false) {259 let frames = alwaysDefaultFrame === true ? [] : this.curWebFrames;260 let promise = this.remote.executeAtom(atom, args, frames);261 return await this.waitForAtom(promise);262};263helpers.executeAtomAsync = async function (atom, args, responseUrl) {264 await this.remote.executeAtomAsync(atom, args, this.curWebFrames, responseUrl);265 // save the resolve and reject methods of the promise to be waited for266 let promise = new B((resolve, reject) => {267 this.asyncPromise = {resolve, reject};268 });269 return await this.waitForAtom(promise);270};271helpers.waitForAtom = async function (promise) {272 // need to check for alert while the atom is being executed.273 // so notify ourselves when it happens274 let done = false;275 let error = null;276 promise.then((res) => {277 done = true;278 return res;279 })280 .catch((err) => {281 logger.warn(`Error received while executing atom: ${err.message}`);282 // error gets swallowed, so save and check later283 done = true;284 error = err;285 });286 // try ten times to check alert, if we are not done yet287 // for (let i = 0; i < 10; i++) {288 // // check if the promise has been resolved289 // if (done) break;290 // await B.delay(500);291 // if (done) break;292 // // check if there is an alert293 // if (await this.checkForAlert()) {294 // // we found an alert, and should just return control295 // return '';296 // }297 // }298 let res = await promise;299 if (error) {300 throw error;301 }302 return this.parseExecuteResponse(res);303};304helpers.checkForAlert = async function () {305 if (!_.isNull(this.uiAutoClient)) {306 logger.debug('atom did not return yet, checking to see if ' +307 'we are blocked by an alert');308 let present = await this.uiAutoClient.sendCommand('au.alertIsPresent()');309 if (!present) {310 logger.debug('No alert found.');311 } else {312 logger.debug('Found an alert, returning control to client');313 }314 return present;315 }316};317helpers.getAtomsElement = function (wdId) {318 let atomsId;319 try {320 atomsId = this.webElementIds[parseInt(wdId, 10) - ELEMENT_OFFSET];321 } catch (e) {322 return null;323 }324 if (_.isUndefined(atomsId)) {325 return null;326 }327 return {ELEMENT: atomsId};328};329helpers.useAtomsElement = function (el) {330 if (parseInt(el, 10) < ELEMENT_OFFSET) {331 logger.debug(`Element with id '${el}' passed in for use with ` +332 `atoms, but it's out of our internal scope. Adding ${ELEMENT_OFFSET}.`);333 el = (parseInt(el, 10) + ELEMENT_OFFSET).toString();334 }335 let atomsElement = this.getAtomsElement(el);336 if (atomsElement === null) {337 throw new errors.UnknownError(`Error converting element ID for using in WD atoms: ${el}`);338 }339 return atomsElement;340};341helpers.convertElementForAtoms = function (args) {342 let newArgs = [];343 for (let arg of args) {344 if (!_.isNull(arg) && !_.isUndefined(arg.ELEMENT)) {345 let atomsElement = this.getAtomsElement(arg.ELEMENT);346 if (atomsElement === null) {347 throw new errors.UnknownError(`Error converting element ID for using in WD atoms: ${arg.ELEMENT}`);348 }349 newArgs.push(atomsElement);350 }351 }352 return newArgs;353};354helpers.parseExecuteResponse = function (res) {355 if (_.isNull(res) || _.isUndefined(res)) return null;356 let wdElement = null;357 if (!_.isArray(res)) {358 if (!_.isUndefined(res.ELEMENT)) {359 wdElement = this.parseElementResponse(res);...

Full Screen

Full Screen

common.js

Source:common.js Github

copy

Full Screen

...264 logger.debug("Element with id " + elementId + " passed in for use with " +265 "atoms, but it's out of our internal scope. Adding 5000");266 elementId = (parseInt(elementId, 10) + 5000).toString();267 }268 var atomsElement = this.getAtomsElement(elementId);269 if (atomsElement === null) {270 failCb(null, {271 status: status.codes.UnknownError.code272 , value: "Error converting element ID for using in WD atoms: " + elementId273 });274 } else {275 cb(atomsElement);276 }277};278exports.convertElementForAtoms = function (args, cb) {279 for (var i = 0; i < args.length; i++) {280 if (args[i] !== null && typeof args[i].ELEMENT !== "undefined") {281 var atomsElement = this.getAtomsElement(args[i].ELEMENT);282 if (atomsElement === null) {283 cb(true, {284 status: status.codes.UnknownError.code285 , value: "Error converting element ID for using in WD atoms: " + args[i].ELEMENT286 });287 return;288 }289 args[i] = atomsElement;290 }291 }292 cb(null, args);293};294exports.jwpError = function (err, code, cb) {295 if (typeof code === "function") {...

Full Screen

Full Screen

element.js

Source:element.js Github

copy

Full Screen

...4const commands = {}, extensions = {};5commands.elementDisplayed = async function elementDisplayed (el) {6 el = util.unwrapElement(el);7 if (this.isWebContext()) {8 const atomsElement = this.getAtomsElement(el);9 return await this.executeAtom('is_displayed', [atomsElement]);10 }11 return await this.proxyCommand(`/element/${el}/displayed`, 'GET');12};13commands.elementEnabled = async function elementEnabled (el) {14 el = util.unwrapElement(el);15 if (this.isWebContext()) {16 const atomsElement = this.getAtomsElement(el);17 return await this.executeAtom('is_enabled', [atomsElement]);18 }19 return await this.proxyCommand(`/element/${el}/enabled`, 'GET');20};21commands.elementSelected = async function elementSelected (el) {22 el = util.unwrapElement(el);23 if (this.isWebContext()) {24 const atomsElement = this.getAtomsElement(el);25 return await this.executeAtom('is_selected', [atomsElement]);26 }27 return await this.proxyCommand(`/element/${el}/selected`, 'GET');28};29commands.getName = async function getName (el) {30 el = util.unwrapElement(el);31 if (this.isWebContext()) {32 const atomsElement = this.getAtomsElement(el);33 const script = 'return arguments[0].tagName.toLowerCase()';34 return await this.executeAtom('execute_script', [script, [atomsElement]]);35 }36 return await this.proxyCommand(`/element/${el}/name`, 'GET');37};38commands.getNativeAttribute = async function getNativeAttribute (attribute, el) {39 if (attribute === 'contentSize') {40 // don't proxy requests for the content size of a scrollable element41 return await this.getContentSize(el);42 }43 el = util.unwrapElement(el);44 // otherwise let WDA handle attribute requests45 let value = await this.proxyCommand(`/element/${el}/attribute/${attribute}`, 'GET');46 // Transform the result for the case when WDA returns an integer representation for a boolean value47 if ([0, 1].includes(value)) {48 value = !!value;49 }50 // The returned value must be of type string according to https://www.w3.org/TR/webdriver/#get-element-attribute51 return (_.isNull(value) || _.isString(value)) ? value : JSON.stringify(value);52};53commands.getAttribute = async function getAttribute (attribute, el) {54 el = util.unwrapElement(el);55 if (!this.isWebContext()) {56 return await this.getNativeAttribute(attribute, el);57 }58 const atomsElement = this.getAtomsElement(el);59 return await this.executeAtom('get_attribute_value', [atomsElement, attribute]);60};61commands.getProperty = async function getProperty (property, el) {62 el = util.unwrapElement(el);63 if (!this.isWebContext()) {64 return await this.getNativeAttribute(property, el);65 }66 const atomsElement = this.getAtomsElement(el);67 return await this.executeAtom('get_attribute_value', [atomsElement, property]);68};69commands.getText = async function getText (el) {70 el = util.unwrapElement(el);71 if (!this.isWebContext()) {72 return await this.proxyCommand(`/element/${el}/text`, 'GET');73 }74 let atomsElement = this.getAtomsElement(el);75 return await this.executeAtom('get_text', [atomsElement]);76};77commands.getElementRect = async function getElementRect (el) {78 if (this.isWebContext()) {79 // Mobile safari doesn't support rect80 const {x, y} = await this.getLocation(el);81 const {width, height} = await this.getSize(el);82 return {x, y, width, height};83 }84 el = util.unwrapElement(el);85 return await this.getNativeRect(el);86};87extensions.getNativeRect = async function getNativeRect (el) {88 return await this.proxyCommand(`/element/${el}/rect`, 'GET');89};90commands.getLocation = async function getLocation (el) {91 el = util.unwrapElement(el);92 if (this.isWebContext()) {93 const atomsElement = await this.getAtomsElement(el);94 let loc = await this.executeAtom('get_top_left_coordinates', [atomsElement]);95 if (this.opts.absoluteWebLocations) {96 const script = 'return [' +97 'Math.max(window.pageXOffset,document.documentElement.scrollLeft,document.body.scrollLeft),' +98 'Math.max(window.pageYOffset,document.documentElement.scrollTop,document.body.scrollTop)];';99 const [xOffset, yOffset] = await this.execute(script);100 loc.x += xOffset;101 loc.y += yOffset;102 }103 return loc;104 }105 const rect = await this.getElementRect(el);106 return {x: rect.x, y: rect.y};107};108commands.getLocationInView = async function getLocationInView (el) {109 return await this.getLocation(el);110};111commands.getSize = async function getSize (el) {112 el = util.unwrapElement(el);113 if (this.isWebContext()) {114 return await this.executeAtom('get_size', [this.getAtomsElement(el)]);115 }116 const rect = await this.getElementRect(el);117 return {width: rect.width, height: rect.height};118};119/**120 * Prepares the input value to be passed as an argument to WDA.121 *122 * @param {string|Array<string>|number} inp The actual text to type.123 * Acceptable values of `inp`:124 * ['some text']125 * ['s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't']126 * 'some text'127 * 1234128 * @throws {Error} If the value is not acceptable for input129 * @returns {Array<string>} The preprocessed value130 */131function prepareInputValue (inp) {132 if (![_.isArray, _.isString, _.isFinite].some((f) => f(inp))) {133 throw new Error(`Only strings, numbers and arrays are supported as input arguments. ` +134 `Received: ${JSON.stringify(inp)}`);135 }136 // make it into a string, so then we assure137 // the array items are single characters138 if (_.isArray(inp)) {139 inp = inp.join('');140 } else if (_.isFinite(inp)) {141 inp = `${inp}`;142 }143 // The `split` method must not be used on the string144 // to properly handle all Unicode code points145 return [...inp].map((k) => {146 if (['\uE006', '\uE007'].includes(k)) { // RETURN or ENTER147 return '\n';148 }149 if (['\uE003', '\ue017'].includes(k)) { // BACKSPACE or DELETE150 return '\b';151 }152 return k;153 });154}155commands.setValueImmediate = async function setValueImmediate (value, el) {156 // WDA does not provide no way to set the value directly157 this.log.info('There is currently no way to bypass typing using XCUITest. Setting value through keyboard');158 await this.setValue(value, el);159};160commands.setValue = async function setValue (value, el) {161 el = util.unwrapElement(el);162 if (!this.isWebContext()) {163 await this.proxyCommand(`/element/${el}/value`, 'POST', {164 value: prepareInputValue(value),165 });166 return;167 }168 const atomsElement = this.getAtomsElement(el);169 await this.executeAtom('click', [atomsElement]);170 await this.executeAtom('type', [atomsElement, value]);171};172commands.keys = async function keys (value) {173 await this.proxyCommand('/wda/keys', 'POST', {174 value: prepareInputValue(value),175 });176};177commands.clear = async function clear (el) {178 el = util.unwrapElement(el);179 if (this.isWebContext()) {180 const atomsElement = this.getAtomsElement(el);181 await this.executeAtom('clear', [atomsElement]);182 return;183 }184 await this.proxyCommand(`/element/${el}/clear`, 'POST');185};186commands.getContentSize = async function getContentSize (el) {187 if (this.isWebContext()) {188 throw new errors.NotYetImplementedError('Support for getContentSize for web context is not yet implemented. Please contact an Appium dev');189 }190 const type = await this.getAttribute('type', el);191 if (type !== 'XCUIElementTypeTable' &&192 type !== 'XCUIElementTypeCollectionView') {193 throw new Error(`Can't get content size for type '${type}', only for ` +194 `tables and collection views`);...

Full Screen

Full Screen

screenshots.js

Source:screenshots.js Github

copy

Full Screen

...36};37commands.getElementScreenshot = async function getElementScreenshot (el) {38 el = util.unwrapElement(el);39 if (this.isWebContext()) {40 const atomsElement = this.getAtomsElement(el);41 return await this.executeAtom('getElementScreenshot', [atomsElement]);42 }43 const data = await this.proxyCommand(`/element/${el}/screenshot`, 'GET');44 if (!_.isString(data)) {45 this.log.errorAndThrow(`Unable to take a screenshot of the element ${el}. WDA returned '${JSON.stringify(data)}'`);46 }47 return data;48};49commands.getViewportScreenshot = async function getViewportScreenshot () {50 let statusBarHeight = await this.getStatusBarHeight();51 const screenshot = await this.getScreenshot();52 // if we don't have a status bar, there's nothing to crop, so we can avoid53 // extra calls and return straightaway54 if (statusBarHeight === 0) {...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require('webdriverio');2const opts = {3 capabilities: {4 }5};6async function main() {7 const client = await wdio.remote(opts);8 const atomsElement = await client.getAtomsElement('test');9 console.log(atomsElement);10}11main();12[debug] [JSONWP Proxy] Got response with status 200: {"value":{"ELEMENT":"E1A9F9A9-8C6B-4A26-BE6A-1F0D8A0E7E1A","element-6066-11e4-a52e-4f735466cecf":"E1A9F9A9-8C6B-4A26-BE6A-1F0D8A0E7E1A"},"sessionId":"CB5B5D5F-0B9F-4BBA-BE4D-DBA0B4A7A4D1","status":0}

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('selenium-webdriver');2var driver = new webdriver.Builder()3 .withCapabilities({4 })5 .build();6driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');7driver.findElement(webdriver.By.name('btnK')).click();8driver.sleep(10000).then(function() {9 driver.quit();10});11info: [debug] [JSONWP Proxy] Got response with status 200: "{\"value\":0,\"sessionId\":\"8C7D5C5B-0E6B-4F8D-B6B0-6B9F6E9C6C3D\",\"status\":0}"

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var driver = wd.promiseChainRemote({3});4driver.init({5}).then(function() {6 return driver.getAtomsElement('target.frontMostApp().mainWindow().buttons()[0]');7}).then(function(element) {8 return driver.click(element);9}).then(function() {10 console.log('Element clicked');11}).catch(function(error) {12 console.log(error);13});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { remote } = require('webdriverio')2async function main () {3 const browser = await remote({4 capabilities: {5 }6 })7 const atomsElement = await browser.getAtomsElement('name', 'Buttons')8 await browser.elementClick(atomsElement.ELEMENT)9 await browser.deleteSession()10}11main()12const { remote } = require('webdriverio')13async function main () {14 const browser = await remote({15 capabilities: {16 }17 })18 const atomsElement = await browser.getAtomsElement('name', 'Buttons')19 console.log(atomsElement)20 await browser.deleteSession()21}22main()23[debug] [MJSONWP] Calling AppiumDriver.createSession() with args: [{"platformName":"iOS","platformVersion":"11.2","deviceName":"iPhone 8","app":"/Users/kazuaki/Library/Developer/Xcode/DerivedData/UICatalog-ajwqjzrjzqgqkzgkzvqzjzjzqyvw/Build/Products/Debug-iphonesimulator/UICatalog.app","automationName":"XCUITest"},null,null]

Full Screen

Using AI Code Generation

copy

Full Screen

1const { remote } = require('webdriverio')2const opts = { path: '/wd/hub', port: 4723, capabilities: { platformName: 'iOS', platformVersion: '14.4', deviceName: 'iPhone 11 Pro Max', app: '/Users/username/Library/Developer/Xcode/DerivedData/WebDriverAgent-brdadhpuduowllgivnnvuygpwhzy/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app' } }3async function main () {4 const client = await remote(opts)5 const element = await client.$('~Test Element')6 const atomsElement = await client.execute('return this.getAtomsElement(arguments[0]);', element.elementId)7 console.log(atomsElement)8 await client.deleteSession()9}10main()11const { remote } = require('webdriverio');12const opts = { path: '/wd/hub', port: 4723, capabilities: { platformName: 'iOS', platformVersion: '14.4', deviceName: 'iPhone 11 Pro Max', app: '/Users/username/Library/Developer/Xcode/DerivedData/WebDriverAgent-brdadhpuduowllgivnnvuygpwhzy/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app' } }13async function main () {14 const client = await remote(opts)15 const element = await client.$('~Test Element')16 const atomsElement = await client.execute('return this.getAtomsElement(arguments[0]);', element.elementId)17 console.log(atomsElement)18 await client.deleteSession()19}20main()21const { remote } = require('webdriverio');22const opts = { path: '/wd/hub', port: 4723, capabilities: { platformName: 'iOS', platformVersion: '14.4', deviceName: 'iPhone 11 Pro Max', app: '/Users/username/Library/Developer/Xcode/DerivedData/WebDriverAgent-brdadhpuduowllgivnnvuygpwhzy/Build/Products/Debug-iphonesimulator/WebDriverAgentRunner-Runner.app' } }23async function main () {24 const client = await remote(opts)25 const element = await client.$('~Test

Full Screen

Using AI Code Generation

copy

Full Screen

1const { remote } = require('webdriverio');2const { XCUITestDriver } = require('appium-xcuitest-driver');3const driver = new XCUITestDriver();4(async () => {5 const session = await remote({6 capabilities: {

Full Screen

Using AI Code Generation

copy

Full Screen

1var getAtomsElement = this.getAtomsElement.bind(this);2var atomsElement = await getAtomsElement(elementId);3return atomsElement;4commands.getAtomsElement = async function (elementId) {5let atomsElement = await this.findNativeElementOrElements('accessibility id', elementId, true);6return atomsElement;7}8[debug] [JSONWP Proxy] Got response with status 200: {"value":{"ELEMENT":"0C000000-0000-0000-7A6E-000000000000"},"sessionId":"9F9F9F9F-9F9F-9F9F-9F9F-9F9F9F9F9F9F","status":0}9[debug] [MJSONWP] Responding to client with driver.findElement() result: {"ELEMENT":"0C000000-0000-0000-7A6E-000000000000"}

Full Screen

Using AI Code Generation

copy

Full Screen

1const wdio = require('webdriverio');2const options = {3 desiredCapabilities: {4 }5};6const client = wdio.remote(options);7 .init()8 .element('accessibility id', 'Your element id')9 .then((res) => {10 return client.getAtomsElement(res.value);11 })12 .then((res) => {13 return client.getElementRect(res.value);14 })15 .then((res) => {16 console.log(res.value);17 })18 .catch((err) => {19 console.log(err);20 })21 .end();22{ x: 0,23 height: 667 }

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var desired = {3};4var atomsElement;5 .init(desired)6 .then(() => {7 return driver.elementByAccessibilityId('id');8 })9 .then((element) => {10 return element.getAtomsElement();11 })12 .then((atomsElement) => {13 return atomsElement.isDisplayed();14 })15 .then((isDisplayed) => {16 console.log(isDisplayed);17 })18 .fin(function () { return driver.quit(); })19 .done();20import io.appium.java_client.ios.IOSDriver;21import io.appium.java_client.ios.IOSElement;22import org.openqa.selenium.remote.DesiredCapabilities;23import java.net.URL;24public class test {25 public static void main(String[] args) throws Exception {26 DesiredCapabilities capabilities = new DesiredCapabilities();27 capabilities.setCapability("platformName", "iOS");28 capabilities.setCapability("platformVersion", "9.3");29 capabilities.setCapability("deviceName", "iPhone Simulator");30 capabilities.setCapability("app", "path/to/your.app");31 capabilities.setCapability("automationName", "XCUITest");32 IOSElement element = (IOSElement) driver.findElementByAccessibilityId("id");

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