How to use driver.elementById method in Appium

Best JavaScript code snippet using appium

follows.test.js

Source:follows.test.js Github

copy

Full Screen

...6 it("should show my follows", function* (driver, done) {7 server.get("/api/follows/tester", fixtures.myFollows());8 yield bootstrap().login().nav("dashboard/follows").launch(driver);9 10 yield driver.elementById('Dashboard');11 yield driver.elementById('friend');12 yield driver.elementById('follow2');13 done();14 });15 it("should show an empty list", function* (driver, done) {16 server.get("/api/follows/tester", { username: "tester", follows: [] });17 yield bootstrap().login().nav("dashboard/follows").launch(driver);18 yield driver.elementById('Follows');19 yield driver.elementById('No items');20 done();21 });22 it("should my friends's follows", function* (driver, done) {23 server.get("/api/follows/friend", fixtures.friendFollows());24 yield bootstrap().login().nav("dashboard/follows/friend/follows").launch(driver);25 yield driver.elementById('friend');26 yield driver.elementById('tester');27 yield driver.elementById('follow4');28 done();29 });30 it("should navigate follows recursively", function* (driver, done) {31 server.get("/api/posts/tester", fixtures.home());32 server.get("/api/posts/friend", fixtures.friend());33 server.get("/api/posts/follow4", { 34 username: "follow4", 35 posts: [ { id: 1000, username: 'follow4', content: 'post1000' }]36 });37 server.get("/api/follows/friend", fixtures.friendFollows());38 server.get("/api/follows/tester", fixtures.myFollows());39 server.get("/api/follows/follow4", { username: "follow4", follows: [ { id: 123, username: 'tester' }] });40 yield bootstrap().login().launch(driver);41 yield driver.elementById("Dashboard");42 yield driver.elementById("post1"); // my post43 // yield driver.sleep(90000000);44 yield driver.elementById("segFollows_tester").click(); // open my follows45 yield driver.elementById('friend').click(); // click on friend46 yield driver.elementById("friend"); // friend's list47 yield driver.elementById("post4"); // friend's post48 yield driver.elementById("segFollows_friend").click(); // open friend's follows49 yield driver.elementById('follow4').click(); // click on other50 yield driver.elementById("follow4"); // other's list51 yield driver.elementById("post100"); // other's post52 yield driver.elementById("segFollows_follow4").click(); // open other's follows53 yield driver.elementById('tester').click(); // click on me54 // TODO: it should NOT say "Dashboard" 55 yield driver.elementById("tester"); // my list56 yield driver.elementById("post1"); // my post57 // Now pop everything58 yield driver.elementById("back").click(); // back59 yield driver.elementById("follow4");60 yield driver.elementById("back").click(); // back61 yield driver.elementById("friend");62 yield driver.elementById("back").click(); // back63 yield driver.elementById("Dashboard");64 done();65 });...

Full Screen

Full Screen

posts.test.js

Source:posts.test.js Github

copy

Full Screen

...6 it("should show my posts", function* (driver, done) {7 server.get("/api/posts/tester", fixtures.home());8 yield bootstrap().login().nav("dashboard").launch(driver);9 10 yield driver.elementById('Dashboard');11 yield driver.elementById('post1');12 done();13 });14 it("should show an empty list", function* (driver, done) {15 server.get("/api/posts/tester", { username: "tester", posts: [] });16 yield bootstrap().login().nav("dashboard").launch(driver);17 yield driver.elementById('Dashboard');18 yield driver.elementById('No items');19 done();20 });21 it("should my friends's posts", function* (driver, done) {22 server.get("/api/posts/friend", fixtures.friend());23 yield bootstrap().login().nav("dashboard/follows/friend").launch(driver);24 yield driver.elementById('friend');25 yield driver.elementById('post3');26 done();27 });28 it("should create a new post", function* (driver, done) {29 var list = fixtures.home();30 server.get("/api/posts/tester", list);31 server.post("/api/posts",32 {id: 100, content: 'new post here', username: 'tester'}, // return this content33 {content: 'new post here'} // expect this content34 );35 yield bootstrap().login().launch(driver);36 yield driver.elementById('+').click(); // new post!37 yield driver.elementById('New Post');38 yield driver.execute("target.frontMostApp().keyboard().typeString('new post here')");39 yield driver.elementById('Submit').click();40 yield driver.elementById('Dashboard');41 yield driver.elementById('new post here'); // it's there!42 done();43 });...

Full Screen

Full Screen

login.test.js

Source:login.test.js Github

copy

Full Screen

...3 */4import it from '../helpers/appium';5describe("Authentication", () => {6 it("should sign up the user, show dashboard, logout", function* (driver, done) {7 yield driver.elementById("indexRegister");8 yield driver.elementById("indexLogin").click();9 yield driver.elementById('userName').sendKeys("15088655203");10 yield driver.elementById('password').sendKeys("wxy1313");11 yield driver.elementById('smsCaptcha').sendKeys("1111");12 yield driver.elementById('getToken').click();13 //yield driver.elementById('getToken').click();14 yield driver.elementById('doLogin').click();15 yield driver.elementById('shopPhoto').click();16 yield driver.elementById('logout').click();17 yield driver.elementById("indexLogin");18 yield driver.elementById("indexRegister");19 done();20 });21 it("register new user", function* (driver, done) {22 yield driver.elementById("indexRegister").click();23 yield driver.elementById('enter_phone').sendKeys("15088651200");24 yield driver.elementById('next').click();25 yield driver.elementById('next').click();26 yield driver.elementById('enterMSCode').sendKeys("1111");27 yield driver.elementById('next').click();28 yield driver.elementById('enterName').sendKeys("test name");29 yield driver.elementById('setSex').click();30 yield driver.elementById('确认').click();31 yield driver.elementById('enterPassword').sendKeys("wxy1111");32 yield driver.elementById('repeatPassword').sendKeys("wxy1111");33 yield driver.elementById('submit').click();34 yield driver.resetApp();35 done();36 });...

Full Screen

Full Screen

authentication.test.js

Source:authentication.test.js Github

copy

Full Screen

...7 });8 it("should sign up the user and show dashboard", function* (driver, done) {9 server.post("api/signup", fixtures.signup());10 11 var username = yield driver.elementById('Username');12 var password = yield driver.elementById('Password');13 var button = yield driver.elementById('Sign up');14 yield username.setImmediateValue("tester");15 yield password.setImmediateValue("sample");16 yield button.click();17 // make sure logged in18 yield driver.elementById('Dashboard');19 yield driver.elementById('post1');20 done();21 });22 it("should log in and out", function* (driver, done) {23 server.post("api/login", fixtures.signup());24 yield driver.elementById('Already a user? Login here.').click();25 26 var username = yield driver.elementById('Username');27 var password = yield driver.elementById('Password');28 var button = yield driver.elementById('Log in');29 yield username.setImmediateValue("tester");30 yield password.setImmediateValue("sample");31 yield button.click();32 // make sure logged in33 yield driver.elementById('Dashboard');34 yield driver.elementById('post1');35 // show settings, log out36 yield driver.elementByXPath('//UIAApplication[1]/UIAWindow[1]/UIAElement[4]').click(); // "Me"37 yield driver.elementById('Settings');38 yield driver.elementById('Log out').click();39 // back on signup40 yield driver.elementById('Already a user? Login here.');41 done();42 });...

Full Screen

Full Screen

main.test.js

Source:main.test.js Github

copy

Full Screen

...3 */4import it from '../helpers/appium';5describe("Main page", () => {6 it("show webView of material page", function* (driver, done) {7 yield driver.elementById("indexLogin").click();8 yield driver.elementById('userName').sendKeys("15088655203");9 yield driver.elementById('password').sendKeys("wxy1313");10 yield driver.elementById('smsCaptcha').sendKeys("1111");11 yield driver.elementById('getToken').click();12 yield driver.elementById('doLogin').click();13 yield driver.elementById('购买物料').click();14 yield driver.elementById('物料列表');15 yield driver.elementById('关闭').click();16 yield driver.elementById('购买物料');17 done();18 });19 it("show setting page", function* (driver, done) {20 yield driver.elementById('设置').click();21 yield driver.elementById('设置');22 done();23 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriver = require('webdriverio');2var options = {3desiredCapabilities: {4}5};6.remote(options)7.init()8.elementById('lst-ib')9.setValue('Hello world!')10.call(function() {11console.log('Done!

Full Screen

Using AI Code Generation

copy

Full Screen

1driver.init(desired).then(function() {2 return driver.elementById('elementID');3});4driver.init(desired).then(function() {5});6driver.init(desired).then(function() {7 return driver.elementByAccessibilityId('elementID');8});9driver.init(desired).then(function() {10 return driver.elementByName('elementName');11});12driver.init(desired).then(function() {13 return driver.elementByClassName('UIAButton');14});15driver.init(desired).then(function() {16 return driver.elementByCssSelector('UIAButton');17});18driver.init(desired).then(function() {19 return driver.elementByLinkText('elementLinkText');20});21driver.init(desired).then(function() {22 return driver.elementByPartialLinkText('elementPartialLinkText');23});24driver.init(desired).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 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