Best JavaScript code snippet using appium
spanner_test.js
Source:spanner_test.js
...138 const sessionsList = response.sessions;139 const sessionNames = sessionsList.map(session => session.name);140 assert(sessionNames.includes(sessionName));141 const deleteSessionRequest = {name: sessionName};142 client.deleteSession(deleteSessionRequest, err => {143 assert.ifError(err);144 done();145 });146 });147 });148 });149 });150 it('Test executeSql', done => {151 const createSessionRequest = {database: _DATABASE};152 client.createSession(createSessionRequest, (err, session) => {153 assert.ifError(err);154 const sessionName = session.name;155 assert.strictEqual(pool.channelRefs.length, 1);156 assert.strictEqual(pool.channelRefs[0].affinityCount, 1);157 assert.strictEqual(pool.channelRefs[0].activeStreamsCount, 0);158 const executeSqlRequest = {159 session: sessionName,160 sql: _TEST_SQL,161 };162 client.executeSql(executeSqlRequest, (err, resultSet) => {163 assert.ifError(err);164 assert.notStrictEqual(resultSet, null);165 const rowsList = resultSet.rows;166 const value = rowsList[0].values[0].stringValue;167 assert.strictEqual(value, 'payload');168 assert.strictEqual(pool.channelRefs.length, 1);169 assert.strictEqual(pool.channelRefs[0].affinityCount, 1);170 assert.strictEqual(pool.channelRefs[0].activeStreamsCount, 0);171 const deleteSessionRequest = {name: sessionName};172 client.deleteSession(deleteSessionRequest, err => {173 assert.ifError(err);174 assert.strictEqual(pool.channelRefs.length, 1);175 assert.strictEqual(pool.channelRefs[0].affinityCount, 0);176 assert.strictEqual(pool.channelRefs[0].activeStreamsCount, 0);177 done();178 });179 });180 });181 });182 it('Test executeStreamingSql', done => {183 const createSessionRequest = {database: _DATABASE};184 client.createSession(createSessionRequest, (err, session) => {185 assert.ifError(err);186 const sessionName = session.name;187 assert.strictEqual(pool.channelRefs.length, 1);188 assert.strictEqual(pool.channelRefs[0].affinityCount, 1);189 assert.strictEqual(pool.channelRefs[0].activeStreamsCount, 0);190 const executeSqlRequest = {191 session: sessionName,192 sql: _TEST_SQL,193 };194 const call = client.executeStreamingSql(executeSqlRequest);195 assert.strictEqual(pool.channelRefs.length, 1);196 assert.strictEqual(pool.channelRefs[0].affinityCount, 1);197 assert.strictEqual(pool.channelRefs[0].activeStreamsCount, 1);198 call.on('data', partialResultSet => {199 const value = partialResultSet.values[0].stringValue;200 assert.strictEqual(value, 'payload');201 });202 call.on('status', status => {203 assert.strictEqual(status.code, grpc.status.OK);204 assert.strictEqual(pool.channelRefs.length, 1);205 assert.strictEqual(pool.channelRefs[0].affinityCount, 1);206 assert.strictEqual(pool.channelRefs[0].activeStreamsCount, 0);207 });208 call.on('end', () => {209 const deleteSessionRequest = {name: sessionName};210 client.deleteSession(deleteSessionRequest, err => {211 assert.ifError(err);212 assert.strictEqual(pool.channelRefs.length, 1);213 assert.strictEqual(pool.channelRefs[0].affinityCount, 0);214 assert.strictEqual(pool.channelRefs[0].activeStreamsCount, 0);215 done();216 });217 });218 });219 });220 it('Test concurrent streams watermark', done => {221 const watermark = 5;222 pool.maxConcurrentStreamsLowWatermark = watermark;223 const expectedNumChannels = 3;224 const createCallPromises = [];225 for (let i = 0; i < watermark * expectedNumChannels; i++) {226 const promise = new Promise((resolve, reject) => {227 const createSessionRequest = {database: _DATABASE};228 client.createSession(createSessionRequest, (err, session) => {229 if (err) {230 reject(err);231 } else {232 const executeSqlRequest = {233 session: session.name,234 sql: _TEST_SQL,235 };236 const call = client.executeStreamingSql(executeSqlRequest);237 resolve({238 call: call,239 sessionName: session.name,240 });241 }242 });243 });244 createCallPromises.push(promise);245 }246 Promise.all(createCallPromises)247 .then(248 results => {249 assert.strictEqual(250 pool.channelRefs.length,251 expectedNumChannels252 );253 assert.strictEqual(254 pool.channelRefs[0].affinityCount,255 watermark256 );257 assert.strictEqual(258 pool.channelRefs[0].activeStreamsCount,259 watermark260 );261 // Consume streaming calls.262 const emitterPromises = results.map(263 result =>264 new Promise(resolve => {265 result.call.on('data', partialResultSet => {266 const value = partialResultSet.values[0].stringValue;267 assert.strictEqual(value, 'payload');268 });269 result.call.on('end', () => {270 const deleteSessionRequest = {name: result.sessionName};271 client.deleteSession(deleteSessionRequest, err => {272 assert.ifError(err);273 resolve();274 });275 });276 })277 );278 // Make sure all sessions get cleaned.279 return Promise.all(emitterPromises);280 },281 error => {282 done(error);283 }284 )285 .then(286 () => {287 assert.strictEqual(288 pool.channelRefs.length,289 expectedNumChannels290 );291 assert.strictEqual(pool.channelRefs[0].affinityCount, 0);292 assert.strictEqual(pool.channelRefs[0].activeStreamsCount, 0);293 done();294 },295 error => {296 done(error);297 }298 );299 });300 it('Test invalid BOUND affinity', done => {301 const getSessionRequest = {name: 'wrong_name'};302 client.getSession(getSessionRequest, err => {303 assert(err);304 assert.strictEqual(305 err.message,306 '3 INVALID_ARGUMENT: Invalid GetSession request.'307 );308 done();309 });310 });311 it('Test invalid UNBIND affinity', done => {312 const deleteSessionRequest = {name: 'wrong_name'};313 client.deleteSession(deleteSessionRequest, err => {314 assert(err);315 assert.strictEqual(316 err.message,317 '3 INVALID_ARGUMENT: Invalid DeleteSession request.'318 );319 done();320 });321 });322 });323 describe('SpannerClient generated by google-gax', () => {324 const gaxGrpc = new gax.GrpcClient({grpc});325 const protos = gaxGrpc.loadProto(326 PROTO_DIR,327 'google/spanner/v1/spanner.proto'328 );329 const SpannerClient = protos.google.spanner.v1.Spanner;330 let client;331 let pool;332 beforeEach(async () => {333 const authFactory = new GoogleAuth({334 scopes: [_OAUTH_SCOPE],335 });336 const auth = await authFactory.getClient();337 const sslCreds = grpc.credentials.createSsl();338 const callCreds = grpc.credentials.createFromGoogleCredential(auth);339 const channelCreds = grpc.credentials.combineChannelCredentials(340 sslCreds,341 callCreds342 );343 const apiDefinition = JSON.parse(fs.readFileSync(_CONFIG_FILE));344 const apiConfig = grpcGcp.createGcpApiConfig(apiDefinition);345 const channelOptions = {346 channelFactoryOverride: grpcGcp.gcpChannelFactoryOverride,347 callInvocationTransformer: grpcGcp.gcpCallInvocationTransformer,348 gcpApiConfig: apiConfig,349 };350 client = new SpannerClient(_TARGET, channelCreds, channelOptions);351 pool = client.getChannel();352 });353 it('Test session operations', done => {354 client.createSession({database: _DATABASE}, (err, session) => {355 assert.ifError(err);356 const sessionName = session.name;357 client.getSession({name: sessionName}, (err, sessionResult) => {358 assert.ifError(err);359 assert.strictEqual(sessionResult.name, sessionName);360 client.listSessions({database: _DATABASE}, (err, response) => {361 assert.ifError(err);362 const sessionsList = response.sessions;363 const sessionNames = sessionsList.map(session => session.name);364 assert(sessionNames.includes(sessionName));365 client.deleteSession({name: sessionName}, err => {366 assert.ifError(err);367 done();368 });369 });370 });371 });372 });373 it('Test executeSql', done => {374 client.createSession({database: _DATABASE}, (err, session) => {375 assert.ifError(err);376 const sessionName = session.name;377 assert.strictEqual(pool.channelRefs.length, 1);378 assert.strictEqual(pool.channelRefs[0].affinityCount, 1);379 assert.strictEqual(pool.channelRefs[0].activeStreamsCount, 0);380 const executeSqlRequest = {381 session: sessionName,382 sql: _TEST_SQL,383 };384 client.executeSql(executeSqlRequest, (err, resultSet) => {385 assert.ifError(err);386 assert.notStrictEqual(resultSet, null);387 const rowsList = resultSet.rows;388 const value = rowsList[0].values[0].stringValue;389 assert.strictEqual(value, 'payload');390 assert.strictEqual(pool.channelRefs.length, 1);391 assert.strictEqual(pool.channelRefs[0].affinityCount, 1);392 assert.strictEqual(pool.channelRefs[0].activeStreamsCount, 0);393 const deleteSessionRequest = {name: sessionName};394 client.deleteSession(deleteSessionRequest, err => {395 assert.ifError(err);396 assert.strictEqual(pool.channelRefs.length, 1);397 assert.strictEqual(pool.channelRefs[0].affinityCount, 0);398 assert.strictEqual(pool.channelRefs[0].activeStreamsCount, 0);399 done();400 });401 });402 });403 });404 it('Test executeStreamingSql', done => {405 client.createSession({database: _DATABASE}, (err, session) => {406 assert.ifError(err);407 const sessionName = session.name;408 assert.strictEqual(pool.channelRefs.length, 1);409 assert.strictEqual(pool.channelRefs[0].affinityCount, 1);410 assert.strictEqual(pool.channelRefs[0].activeStreamsCount, 0);411 const executeSqlRequest = {412 session: sessionName,413 sql: _TEST_SQL,414 };415 const call = client.executeStreamingSql(executeSqlRequest);416 assert.strictEqual(pool.channelRefs.length, 1);417 assert.strictEqual(pool.channelRefs[0].affinityCount, 1);418 assert.strictEqual(pool.channelRefs[0].activeStreamsCount, 1);419 call.on('data', partialResultSet => {420 const value = partialResultSet.values[0].stringValue;421 assert.strictEqual(value, 'payload');422 });423 call.on('status', status => {424 assert.strictEqual(status.code, grpc.status.OK);425 assert.strictEqual(pool.channelRefs.length, 1);426 assert.strictEqual(pool.channelRefs[0].affinityCount, 1);427 assert.strictEqual(pool.channelRefs[0].activeStreamsCount, 0);428 });429 call.on('end', () => {430 client.deleteSession({name: sessionName}, err => {431 assert.ifError(err);432 assert.strictEqual(pool.channelRefs.length, 1);433 assert.strictEqual(pool.channelRefs[0].affinityCount, 0);434 assert.strictEqual(pool.channelRefs[0].activeStreamsCount, 0);435 done();436 });437 });438 });439 });440 });441 });...
home.test.js
Source:home.test.js
...26// const filterButton = await client.$('#filter');27// await filterButton.click();28// const filterOption = await client.$('#filterOption');29// await filterOption.click();30// // await client.deleteSession();31// }32async function updateProfile() {33 const client = await wdio.remote(opts);34 const email = await client.$('#emailTextField');35 await email.setValue("testeProfile@gmail.com");36 const password = await client.$('#passwordTextField');37 await password.setValue("123456");38 const login = await client.$('#loginButton');39 await login.click();40 const profileButton = await client.$('#profileButton').click();41 const age = await client.$('//XCUIElementTypeApplication[@name="Hope"]/XCUIElementTypeWindow/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[3]/XCUIElementTypeOther[2]/XCUIElementTypeOther[3]/XCUIElementTypeTextField'); 42 await age.setValue("20");43 const cep = await client.$('//XCUIElementTypeApplication[@name="Hope"]/XCUIElementTypeWindow/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[3]/XCUIElementTypeOther[2]/XCUIElementTypeOther[2]/XCUIElementTypeTextField'); 44 await cep.setValue("58046700");45 const lastName = await client.$('//XCUIElementTypeApplication[@name="Hope"]/XCUIElementTypeWindow/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[3]/XCUIElementTypeOther[1]/XCUIElementTypeOther[2]/XCUIElementTypeTextField'); 46 await lastName.setValue("Teste");47 const nameProfile = await client.$('//XCUIElementTypeApplication[@name="Hope"]/XCUIElementTypeWindow/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[3]/XCUIElementTypeOther[1]/XCUIElementTypeOther[1]/XCUIElementTypeTextField'); 48 await nameProfile.setValue("Automatic");49 const emailProfile = await client.$('//XCUIElementTypeApplication[@name="Hope"]/XCUIElementTypeWindow/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[3]/XCUIElementTypeTextField'); 50 await emailProfile.setValue("automaticteste@gmail.com");51 const image = await client.$('//XCUIElementTypeApplication[@name="Hope"]/XCUIElementTypeWindow/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeImage').click();52 const biblioteca = await client.$('//XCUIElementTypeButton[@name="Biblioteca"]').click();53 const imagePicker = await client.$('//XCUIElementTypeImage[@name="Photo, August 08, 2012, 6:55 PM"]').click();54 const done = await client.$('//XCUIElementTypeStaticText[@name="Choose"]').click();55 const attData = await client.$('//XCUIElementTypeButton[@name="ATUALIZAR DADOS"]').click();56 await client.$("#label").waitForDisplayed(6000);57 58 const att = await client.$("#label").getText();59 await expect(att).to.equal('Dados atualizados com sucesso!');60 const emailExpect = await client.$('e')61}62// async function likingCard() {63// const client = await wdio.remote(opts);64// const email = await client.$('#emailTextField');65// await email.setValue("code@gmail.com");66// const password = await client.$('#passwordTextField');67// await password.setValue("123456");68// const login = await client.$('#loginButton');69// await login.click();70// const likeButton = await client.$('#likeButton');71// await likeButton.click();72// const likeButton2 = await client.$('#likeButton');73// await likeButton2.click();74// const likeButtonComunidade = await client.$('#likeButton2');75// await likeButtonComunidade.click();76 77// // await client.deleteSession();78// }79// async function likingCommunityDoubt() {80// const client = await wdio.remote(opts);81// const email = await client.$('#emailTextField');82// await email.setValue("code@gmail.com");83// const password = await client.$('#passwordTextField');84// await password.setValue("123456");85// const login = await client.$('#loginButton');86// await login.click();87// const filterCards = await client.$('filter')88// const likeButton = await client.$('#likeCommunityDoubt');89// await likeButton.click();90// const likeButton2 = await client.$('#likeCommunityDoubt');91// await likeButton2.click();92 93// // await client.deleteSession();94// }95async function addBadgeHome() {96 const client = await wdio.remote(opts);97 const email = await client.$('#emailTextField');98 await email.setValue("code@gmail.com");99 const password = await client.$('#passwordTextField');100 await password.setValue("123456");101 const login = await client.$('#loginButton');102 await login.click();103 const badge = await client.$('#badgeButton');104 await badge.click();105 const text = await client.$('#typeHere');106 await text.setValue("teste");107 const send = await client.$('#send');108 await send.click();109 const close = await client.$('#close');110 await close.click();111 112 // await client.deleteSession();113}114async function addBadgeRelapses() {115 const client = await wdio.remote(opts);116 const email = await client.$('#emailTextField');117 await email.setValue("code@gmail.com");118 const password = await client.$('#passwordTextField');119 await password.setValue("123456");120 const login = await client.$('#loginButton');121 await login.click();122 const relapses = await client.$('//XCUIElementTypeApplication[@name="Hope"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeButton[5]');123 await relapses.click();124 const badge = await client.$('#buttonRelapses');125 await badge.click();126 const text = await client.$('#typeHere');127 await text.setValue("teste");128 const send = await client.$('#send');129 await send.click();130 const close = await client.$('#close');131 await close.click();132 133 134 // await client.deleteSession();135}136async function talkToSpecialistByCommunity() {137 const client = await wdio.remote(opts);138 const email = await client.$('#emailTextField');139 await email.setValue("code@gmail.com");140 const password = await client.$('#passwordTextField');141 await password.setValue("123456");142 const login = await client.$('#loginButton');143 await login.click();144 const community = await client.$('//XCUIElementTypeApplication[@name="Hope"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeButton[3]');145 await community.click();146 const specialist = await client.$('//XCUIElementTypeApplication[@name="Hope"]/XCUIElementTypeWindow/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[9]/XCUIElementTypeOther[1]/XCUIElementTypeOther');147 await specialist.click();148 const talk = await client.$('#talkToSpecialist');149 await talk.click();150 const type = await client.$('#typeHereChat');151 await type.setValue("teste");152 const send = await client.$('#sendButton');153 await send.click();154 const backButton = await client.$('//XCUIElementTypeButton[@name="ic back"]');155 await backButton.click();156 const closebutton = await client.$('#closeButton');157 await closebutton.click();158 const home = await client.$('//XCUIElementTypeApplication[@name="Hope"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeButton[1]');159 await home.click();160 // await client.deleteSession();161}162async function notifications() {163 const client = await wdio.remote(opts);164 const email = await client.$('#emailTextField');165 await email.setValue("code@gmail.com");166 const password = await client.$('#passwordTextField');167 await password.setValue("123456");168 const login = await client.$('#loginButton');169 await login.click();170 const notifications = await client.$('//XCUIElementTypeApplication[@name="Hope"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeButton[6]');171 await notifications.click();172 const home = await client.$('//XCUIElementTypeApplication[@name="Hope"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeButton[1]');173 await home.click();174 175 176 // await client.deleteSession();177}178async function sendMessageChat() {179 const client = await wdio.remote(opts);180 const email = await client.$('#emailTextField');181 await email.setValue("code@gmail.com");182 const password = await client.$('#passwordTextField');183 await password.setValue("123456");184 const login = await client.$('#loginButton');185 await login.click();186 const chat = await client.$('//XCUIElementTypeApplication[@name="Hope"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[3]/XCUIElementTypeOther/XCUIElementTypeButton[2]');187 await chat.click();188 const buttonChat = await client.$('//XCUIElementTypeButton[@name="ic new msg"]');189 await buttonChat.click();190 const duvidas = await client.$('//XCUIElementTypeApplication[@name="Hope"]/XCUIElementTypeWindow[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther[1]/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeOther/XCUIElementTypeTable/XCUIElementTypeCell[1]/XCUIElementTypeOther[1]/XCUIElementTypeOther');191 await duvidas.click();192 const responder = await client.$('//XCUIElementTypeStaticText[@name="RESPONDER"]');193 await responder.click();194 await client.$("#typeHereChat").waitForDisplayed(100000)195 const type = await client.$('#typeHereChat');196 await type.setValue("teste");197 const send = await client.$('#sendButton');198 await send.click();199 const backButton = await client.$('//XCUIElementTypeButton[@name="ic back"]');200 await backButton.click();201 const backButton2 = await client.$('//XCUIElementTypeButton[@name="ic back"]');202 await backButton2.click();203 204 // await client.deleteSession();205}...
main.js
Source:main.js
...16 beforeEach(async function () {17 client = await wdio.remote(opts);18 });19 afterEach(async function () {20 await client.deleteSession();21 });22 it("cronology element is visible", async function () {23 await client.pause(10000);24 const xpath = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup[3]";25 const field = await client.$(xpath);26 const visible = await field.isDisplayed();27 assert(visible);28 });29});30describe("navbar is visible", function () {31 let client;32 beforeEach(async function () {33 client = await wdio.remote(opts);34 });35 afterEach(async function () {36 await client.deleteSession();37 });38 it("navbar element is visible", async function () {39 await client.pause(10000);40 const xpath = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup";41 const field = await client.$(xpath);42 const visible = await field.isDisplayed();43 assert(visible);44 });45});46describe("Navigation to patient list works", function () {47 let client;48 beforeEach(async function () {49 client = await wdio.remote(opts);50 });51 afterEach(async function () {52 await client.deleteSession();53 });54 it("navigation test", async function () {55 await client.pause(5000);56 const xpathButton = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]";57 const xpath = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[1]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.widget.TextView[1]";58 const button = await client.$(xpathButton);59 button.click();60 await client.pause(5000);61 const field = await client.$(xpath);62 const text = await field.getText();63 assert.equal(text, "Os Meus Pacientes");64 });65});66describe("check patient info", function () {67 let client;68 beforeEach(async function () {69 client = await wdio.remote(opts);70 });71 afterEach(async function () {72 await client.deleteSession();73 });74 it("mobile info test", async function () {75 await client.pause(5000);76 const xpathButton1 = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]";77 const xpathButton2 = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[1]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup[3]";78 const button1 = await client.$(xpathButton1);79 button1.click();80 await client.pause(5000);81 const button2 = await client.$(xpathButton2);82 button2.click();83 await client.pause(5000);84 const mobile = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup/android.widget.TextView[3]";85 const phone_number = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup[2]/android.view.ViewGroup/android.view.ViewGroup/android.widget.TextView[2]";86 const mobile_text = await client.$(mobile);87 const text_mobile = await mobile_text.getText();88 const mobile_number = await client.$(phone_number);89 const text_number = await mobile_number.isDisplayed();90 91 assert(text_number);92 assert.equal(text_mobile, "Mobile");93 });94});95describe("submit treatment", function () {96 let client;97 beforeEach(async function () {98 client = await wdio.remote(opts);99 });100 afterEach(async function () {101 await client.deleteSession();102 });103 it("straight to the end", async function () {104 await client.pause(5000);105 const xpathButton1 = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[2]";106 const xpathButton2 = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[1]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup[3]";107 const xPathButton3 = "/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup[1]/android.view.ViewGroup/android.view.ViewGroup/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup[6]/android.view.ViewGroup[2]";108 const button1 = await client.$(xpathButton1);109 button1.click();110 await client.pause(5000);111 const button2 = await client.$(xpathButton2);112 button2.click();113 await client.pause(5000);114 115 const button3 = await client.$(xPathButton3);...
dateTests.js
Source:dateTests.js
...51 await dateSendButton.click();52 client.setImplicitTimeout(2000);53 var toastMessage = await client.$('//android.widget.Toast')54 var value = await toastMessage.getAttribute("text")55 await client.deleteSession();56 return assert.strictEqual(value, "Date must be in form of dd/mm/yyyy or dd.mm.yyyy")57}58async function testFutureDate() {59 const client = await wdio.remote(opts)60 // Skip the name page61 const nameField = await client.$("android.widget.EditText");62 await nameField.setValue("Ata Atasoy")63 const nameSubmitButton = await client.$("android.widget.Button");64 await nameSubmitButton.click();65 client.setImplicitTimeout(3000);66 // Skip the city page67 const cityField = await client.$("android.widget.EditText")68 await cityField.setValue("Trabzon");69 const citySubmitButton = await client.$("android.widget.Button");70 await citySubmitButton.click();71 client.setImplicitTimeout(3000);72 // Send date input73 const dateField = await client.$("android.widget.EditText")74 await dateField.setValue("14.02.2050")75 const dateSendButton = await client.$("android.widget.Button")76 await dateSendButton.click();77 client.setImplicitTimeout(2000);78 var toastMessage = await client.$('//android.widget.Toast')79 var value = await toastMessage.getAttribute("text")80 await client.deleteSession();81 return assert.strictEqual(value, "Invalid Date")82}83async function testNonLeapYearInvalidDay() {84 const client = await wdio.remote(opts)85 // Skip the name page86 const nameField = await client.$("android.widget.EditText");87 await nameField.setValue("Ata Atasoy")88 const nameSubmitButton = await client.$("android.widget.Button");89 await nameSubmitButton.click();90 client.setImplicitTimeout(3000);91 // Skip the city page92 const cityField = await client.$("android.widget.EditText")93 await cityField.setValue("Trabzon");94 const citySubmitButton = await client.$("android.widget.Button");95 await citySubmitButton.click();96 client.setImplicitTimeout(3000);97 // Send date input98 const dateField = await client.$("android.widget.EditText")99 await dateField.setValue("29.02.2021")100 const dateSendButton = await client.$("android.widget.Button")101 await dateSendButton.click();102 client.setImplicitTimeout(2000);103 var toastMessage = await client.$('//android.widget.Toast')104 var value = await toastMessage.getAttribute("text")105 await client.deleteSession();106 return assert.strictEqual(value, "Invalid Date")107}108async function testLongMonthInvalidDay() {109 const client = await wdio.remote(opts)110 // Skip the name page111 const nameField = await client.$("android.widget.EditText");112 await nameField.setValue("Ata Atasoy")113 const nameSubmitButton = await client.$("android.widget.Button");114 await nameSubmitButton.click();115 client.setImplicitTimeout(3000);116 // Skip the city page117 const cityField = await client.$("android.widget.EditText")118 await cityField.setValue("Trabzon");119 const citySubmitButton = await client.$("android.widget.Button");120 await citySubmitButton.click();121 client.setImplicitTimeout(3000);122 // Send date input123 const dateField = await client.$("android.widget.EditText")124 await dateField.setValue("32.03.2021")125 const dateSendButton = await client.$("android.widget.Button")126 await dateSendButton.click();127 client.setImplicitTimeout(2000);128 var toastMessage = await client.$('//android.widget.Toast')129 var value = await toastMessage.getAttribute("text")130 await client.deleteSession();131 return assert.strictEqual(value, "Invalid Date")132}133async function testShortMonthInvalidDay() {134 const client = await wdio.remote(opts)135 // Skip the name page136 const nameField = await client.$("android.widget.EditText");137 await nameField.setValue("Ata Atasoy")138 const nameSubmitButton = await client.$("android.widget.Button");139 await nameSubmitButton.click();140 client.setImplicitTimeout(3000);141 // Skip the city page142 const cityField = await client.$("android.widget.EditText")143 await cityField.setValue("Trabzon");144 const citySubmitButton = await client.$("android.widget.Button");145 await citySubmitButton.click();146 client.setImplicitTimeout(3000);147 // Send date input148 const dateField = await client.$("android.widget.EditText")149 await dateField.setValue("31.04.2021")150 const dateSendButton = await client.$("android.widget.Button")151 await dateSendButton.click();152 client.setImplicitTimeout(2000);153 var toastMessage = await client.$('//android.widget.Toast')154 var value = await toastMessage.getAttribute("text")155 await client.deleteSession();156 return assert.strictEqual(value, "Invalid Date")157}158async function testInvalidMonth() {159 const client = await wdio.remote(opts)160 // Skip the name page161 const nameField = await client.$("android.widget.EditText");162 await nameField.setValue("Ata Atasoy")163 const nameSubmitButton = await client.$("android.widget.Button");164 await nameSubmitButton.click();165 client.setImplicitTimeout(3000);166 // Skip the city page167 const cityField = await client.$("android.widget.EditText")168 await cityField.setValue("Trabzon");169 const citySubmitButton = await client.$("android.widget.Button");170 await citySubmitButton.click();171 client.setImplicitTimeout(3000);172 // Send date input173 const dateField = await client.$("android.widget.EditText")174 await dateField.setValue("30.13.2021")175 const dateSendButton = await client.$("android.widget.Button")176 await dateSendButton.click();177 client.setImplicitTimeout(2000);178 var toastMessage = await client.$('//android.widget.Toast')179 var value = await toastMessage.getAttribute("text")180 await client.deleteSession();181 return assert.strictEqual(value, "Invalid Date")182}183async function testZeroValues() {184 const client = await wdio.remote(opts)185 // Skip the name page186 const nameField = await client.$("android.widget.EditText");187 await nameField.setValue("Ata Atasoy")188 const nameSubmitButton = await client.$("android.widget.Button");189 await nameSubmitButton.click();190 client.setImplicitTimeout(3000);191 // Skip the city page192 const cityField = await client.$("android.widget.EditText")193 await cityField.setValue("Trabzon");194 const citySubmitButton = await client.$("android.widget.Button");195 await citySubmitButton.click();196 client.setImplicitTimeout(3000);197 // Send date input198 const dateField = await client.$("android.widget.EditText")199 await dateField.setValue("00.00.0000")200 const dateSendButton = await client.$("android.widget.Button")201 await dateSendButton.click();202 client.setImplicitTimeout(2000);203 var toastMessage = await client.$('//android.widget.Toast')204 var value = await toastMessage.getAttribute("text")205 await client.deleteSession();206 return assert.strictEqual(value, "Invalid Date")207}208module.exports = {testInvalidBirthDate, testFutureDate, testNonLeapYearInvalidDay, ...
api-session-tests.js
Source:api-session-tests.js
1'use strict';2let Promise = require('bluebird');3let chai = require('chai');4let should = chai.should();5let apiClient = require('./api-client');6let helper = require('./helper');7describe('/sessions', function() {8 let user, sessions;9 before(function() {10 return helper11 .createTestUserWithSessions(12 { email: 'foo@example.org', password: '123456' },13 [{ ip: '127.0.0.1', data: { foo: 'foo' } }, { ip: '255.255.255.0', data: { bar: 'bar' } }]14 )15 .then(r => {16 user = r.user;17 sessions = r.sessions;18 });19 });20 after(function() {21 return helper.cleanTestUser(user.id);22 });23 describe('GET /sessions/:token', function() {24 let path = `/sessions/${helper.genRandomToken()}`, method = 'get';25 it('should get session by token', function() {26 return Promise27 .map(sessions, s => apiClient.getSession(s.token))28 .then(rs => {29 rs.forEach((res, i) => {30 helper.debug(res.body);31 res.should.have.status(200);32 helper.validateObject(res.body.data.session, {33 uid: { equal: user.id },34 token: { equal: sessions[i].token },35 ttl: { be: 'number' },36 data: { deepEqual: sessions[i].data }37 });38 });39 });40 });41 it('should fail 400 for invalid session token format', function() {42 return apiClient43 .getSession('foo')44 .then(res => {45 helper.debug(res.body);46 helper.shouldFail(res, 400, '40020', 'Invalid session token format');47 });48 });49 helper.testUnauthorized({ api: helper.apiV1, path, method });50 helper.testForbidden({ api: helper.apiV1, path, method });51 helper.testNotFound({ api: helper.apiV1, path, method, resource: 'session' });52 });53 describe('PUT /sessions/:token/data', function() {54 let path = `/sessions/${helper.genRandomToken()}/data`, method = 'patch';55 it('should set session data', function() {56 return apiClient.updateSessionData(sessions[0].token, { foo: 'foo', bar: 'bar' })57 .then(res => {58 helper.debug(res.body);59 res.should.have.status(200);60 });61 });62 it('should update session data', function() {63 return apiClient.updateSessionData(sessions[0].token, { foo: 'bar', bar: 'foo' })64 .then(res => {65 helper.debug(res.body);66 res.should.have.status(200);67 });68 });69 it('should delete session data by set to null', function() {70 return apiClient.updateSessionData(sessions[0].token, { foo: null, bar: null })71 .then(res => {72 helper.debug(res.body);73 res.should.have.status(200);74 });75 });76 it('should fail 400 for invalid session token format', function() {77 return apiClient78 .updateSessionData('foo', {})79 .then(res => {80 helper.debug(res.body);81 helper.shouldFail(res, 400, '40020', 'Invalid session token format')82 });83 });84 helper.testUnauthorized({ api: helper.apiV1, path, method });85 helper.testForbidden({ api: helper.apiV1, path, method });86 helper.testNotFound({ api: helper.apiV1, path, method , body: { data: { _v: 0 } }, resource: 'session' });87 });88 describe('DELETE /sessions/:token', function() {89 let path = `/sessions/${helper.genRandomToken()}`, method = 'delete';90 it('should delete session by token', function() {91 return Promise92 .map(sessions, s => apiClient.deleteSession(s.token))93 .then(rs => {94 rs.forEach(res => {95 helper.debug(res.body);96 res.should.have.status(200);97 res.body.data.should.deep.equal({ kill: 1 });98 });99 });100 });101 it('should be ok if session not found', function() {102 return apiClient.deleteSession(helper.genRandomToken())103 .then(res => {104 helper.debug(res.body);105 res.should.have.status(200);106 res.body.data.kill.should.equal(0);107 });108 });109 it('should fail 400 for invalid session token format', function() {110 return apiClient111 .deleteSession('foo')112 .then(res => {113 helper.debug(res.body);114 helper.shouldFail(res, 400, '40020', 'Invalid session token format')115 });116 });117 helper.testUnauthorized({ api: helper.apiV1, path, method });118 helper.testForbidden({ api: helper.apiV1, path, method });119 });...
webdriverCommands.js
Source:webdriverCommands.js
...8// if the searchterm (should be only the first) doesn't exist the search stops early9function isExistingSearchTerm(){10 client.getText('h1#firstHeading.firstHeading').then(function(res){11 if ( res === 'Search results') {12 client.deleteSession();13 }14 else {15 }16 isPhilosophy();17 })18}19// wikipedia annotations shouldn't be parsed as links20function containsAnumber(string){21 if ( string.match(/[0-9]+/g) !== null) {22 console.log('it contains numbers', string)23 return true24 }25 return false26}27// if the link was already visited stop28function linkAlreadyVisited(string){29 console.log("already visited", wordbank, wordbank.indexOf(string))30 if ( wordbank.indexOf(string) > 1) {31 //console.log(`you already visited that link and are running through a loop \nit took you ${hopCount} hops, through these pages \n-> ${wordbank} \nto get to get to the last page of the loop`)32 return true33 }34}35async function getLink(client) {36 let nthParagraph = 1;37 let nthLink = 1;38 let currentParagraph;39 // wikipedia has some empty paragraphs, we need to get the first ACTUAL paragraph40 async function getValidParagraph(client){41 let paragraph = await client.$(`#mw-content-text > .mw-parser-output > p:nth-of-type(${nthParagraph}`)42 let paragraphText = await paragraph.getText()43 // assuming most intro paragraphs have more than 50 chars44 if (paragraphText.length < 50) {45 nthParagraph = nthParagraph + 146 getValidParagraph(client)47 }48 else {49 currentParagraph = paragraphText50 clickValidLink(client)51 }52 }53 async function clickValidLink(client){54 const link = await client.$(`#mw-content-text > .mw-parser-output > p:nth-of-type(${nthParagraph}) > a:nth-of-type(${nthLink})`)55 const linkText = await link.getText();56 console.log("LINK IS ", linkText, nthParagraph, nthLink)57 const openingBracket = currentParagraph.indexOf('(')58 const closingBracket = currentParagraph.indexOf(')') 59 var subString = currentParagraph.indexOf(linkText)60 // dont wan't to click annotations in brackets, numbers, or links inside parentheses (at least not the first parentheses of the paragraph)61 if (linkText.includes('[') || containsAnumber(linkText) || (subString > openingBracket && subString < closingBracket) ){62 console.log('invalid link', linkText)63 nthLink = nthLink + 164 clickValidLink(client);65 }66 // link was already visited67 else if (linkAlreadyVisited(linkText)) {68 console.log("break, link already visited")69 await client.deleteSession()70 } else {71 const titleEl = await client.$('h1#firstHeading.firstHeading')72 const titleText = await titleEl.getText()73 await link.click()74 await isPhilosophy(client); 75 }76 }77 getValidParagraph(client)78}79// if the title of the page is Philosophy stop80async function isPhilosophy(client){81 const el = await client.$('h1#firstHeading.firstHeading')82 const text = await el.getText()83 if ( text !== 'Philosophy' ) {84 wordbank.push(text)85 await getLink(client);86 } 87 else {88 console.log(`congratulations, you got to Philosophy \nit took you ${hopCount} hops, through these pages \n-> ${wordbank} \nto get to Philosophy`)89 await client.deleteSession();90 }91}92async function wiki(searchTerm) { 93 client = await webdriverio.remote(options)94 await client.navigateTo('https://wikipedia.org')95 const searchInput = await client.$('input#searchInput')96 await searchInput.setValue(searchTerm)97 const searchBtn = await client.$('button[type="submit"]')98 await searchBtn.click() 99 .then(function(){100 isPhilosophy(client);101 })102}103exports.wiki = wiki;
nameTests.js
Source:nameTests.js
...22 await button.click();23 client.setImplicitTimeout(5000);24 var toastMessage = await client.$('//android.widget.Toast')25 var value = await toastMessage.getAttribute("text")26 await client.deleteSession();27 return assert.strictEqual(value, "Field cannot be empty")28}29async function testAlphabeticStart() {30 const client = await wdio.remote(opts);31 // Sending keys32 const field = await client.$("android.widget.EditText");33 await field.setValue("999Ata Atasoy");34 // Clicking a button35 const button = await client.$("android.widget.Button");36 await button.click();37 client.setImplicitTimeout(5000);38 var toastMessage = await client.$('//android.widget.Toast')39 var value = await toastMessage.getAttribute("text")40 await client.deleteSession();41 return assert.strictEqual(value, "Name should only contain alphabetic characters and spaces" + 42 " and start with an alphabetic character")43}44async function testLeadingSpaces() {45 const client = await wdio.remote(opts);46 // Sending keys47 const field = await client.$("android.widget.EditText");48 await field.setValue(" Ata Atasoy");49 // Clicking a button50 const button = await client.$("android.widget.Button");51 await button.click();52 client.setImplicitTimeout(5000);53 var toastMessage = await client.$('//android.widget.Toast')54 var value = await toastMessage.getAttribute("text")55 await client.deleteSession();56 return assert.strictEqual(value, "Name should only contain alphabetic characters and spaces" + 57 " and start with an alphabetic character")58}59async function testContainsOnlyAlphabetic() {60 const client = await wdio.remote(opts);61 // Sending keys62 const field = await client.$("android.widget.EditText");63 await field.setValue("Ata-Atasoy? Test.");64 // Clicking a button65 const button = await client.$("android.widget.Button");66 await button.click();67 client.setImplicitTimeout(5000);68 var toastMessage = await client.$('//android.widget.Toast')69 var value = await toastMessage.getAttribute("text")70 await client.deleteSession();71 return assert.strictEqual(value, "Name should only contain alphabetic characters and spaces" + 72 " and start with an alphabetic character")73}...
Appium JS example.js
Source:Appium JS example.js
...16 17 async function main () {18 const client = await wdio.remote(opts);19 20 await client.deleteSession();21 }22 23 main();24 //Test Commands25 // javascript26const field = await client.$("android.widget.EditText");27await field.setValue("Hello World!");28const value = await field.getText();29assert.strictEqual(value, "Hello World!")30//All together31// javascript32const wdio = require("webdriverio");33const assert = require("assert");34const opts = {35 path: '/wd/hub',36 port: 4723,37 capabilities: {38 platformName: "Android",39 platformVersion: "8",40 deviceName: "Android Emulator",41 app: "/path/to/the/downloaded/ApiDemos-debug.apk",42 appPackage: "io.appium.android.apis",43 appActivity: ".view.TextFields",44 automationName: "UiAutomator2"45 }46};47async function main () {48 const client = await wdio.remote(opts);49 const field = await client.$("android.widget.EditText");50 await field.setValue("Hello World!");51 const value = await field.getText();52 assert.strictEqual(value,"Hello World!");53 await client.deleteSession();54}55main();56//example of creating a test session for Windows Alarms & Clock app written in C#:57// Launch the AlarmClock app58DesiredCapabilities appCapabilities = new DesiredCapabilities();59appCapabilities.SetCapability("app", "Microsoft.WindowsAlarms_8wekyb3d8bbwe!App");60AlarmClockSession = new WindowsDriver<WindowsElement>(new Uri("http://127.0.0.1:4723"), appCapabilities);61// Control the AlarmClock app62AlarmClockSession.FindElementByAccessibilityId("AddAlarmButton").Click();63AlarmClockSession.FindElementByAccessibilityId("AlarmNameTextBox").Clear();64//example of creating a test session for Windows Notepad app:65// Launch Notepad66DesiredCapabilities appCapabilities = new DesiredCapabilities();67appCapabilities.SetCapability("app", @"C:\Windows\System32\notepad.exe");...
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6var client = webdriverio.remote(options);7 .init()8 .getTitle().then(function(title) {9 console.log('Title was: ' + title);10 })11 .end()12 .deleteSession();13var session = client.requestHandler.sessionID;14var session = client.requestHandler.sessionID;15client.deleteSession(session);16var wdio = require('webdriverio');17var options = {18 desiredCapabilities: {19 }20};21var client = wdio.remote(options);22 .init()23 .getTitle().then(function(title) {24 console.log('Title was: ' + title);25 })26 .end()27 .deleteSession();28var wdio = require('webdriverio');29var options = {30 desiredCapabilities: {31 }32};33var client = wdio.remote(options);34 .init()35 .getTitle().then(function(title) {36 console.log('Title was: ' + title);37 })38 .end()39 .deleteSession();
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6var client = webdriverio.remote(options);7 .init()8 .getTitle().then(function(title) {9 console.log('Title was: ' + title);10 })11 .end();12client.deleteSession();
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6 .remote(options)7 .init()8 .getTitle().then(function(title) {9 console.log('Title was: ' + title);10 })11 .end()12 .deleteSession()13 .catch(function(err) {14 console.log(err);15 });16var webdriverio = require('webdriverio');17var options = {18 desiredCapabilities: {19 }20};21 .remote(options)22 .init()23 .getTitle().then(function(title) {24 console.log('Title was: ' + title);25 })26 .end()27 .deleteSession()28 .catch(function(err) {29 console.log(err);30 });31var webdriverio = require('webdriverio');32var options = {33 desiredCapabilities: {34 }35};36 .remote(options)37 .init()38 .getTitle().then(function(title) {39 console.log('Title was: ' + title);40 })41 .end()42 .deleteSession()
Using AI Code Generation
1var wd = require('wd');2var desiredCaps = {3};4 .init(desiredCaps)5 .then(function() {6 return driver.deleteSession();7 })8 .then(function() {9 console.log('Session deleted successfully');10 })11 .catch(function(err) {12 console.log('Error occurred while deleting session');13 console.log(err);14 })15 .finally(function() {16 driver.quit();17 });18import io.appium.java_client.AppiumDriver;19import io.appium.java_client.MobileElement;20import io.appium.java_client.android.AndroidDriver;21import io.appium.java_client.remote.MobileCapabilityType;22import java.net.URL;23import org.openqa.selenium.remote.DesiredCapabilities;24public class DeleteSession {25 public static void main(String[] args) throws Exception {26 DesiredCapabilities caps = new DesiredCapabilities();27 caps.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");28 caps.setCapability(MobileCapabilityType.PLATFORM_VERSION, "10.0");29 caps.setCapability(MobileCapabilityType.DEVICE_NAME, "Pixel_2_API_29");30 caps.setCapability(MobileCapabilityType.AUTOMATION_NAME, "UiAutomator2");31 caps.setCapability(MobileCapabilityType.APP, "/Users/username/Downloads/ApiDemos-debug.apk");32 caps.setCapability(MobileCapabilityType.NO_RESET, true);33 driver.deleteSession();34 System.out.println("Session deleted successfully");35 }36}
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!