Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/appium_Android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- 4.x
- appium-esm-migration

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
Expand Down
24 changes: 8 additions & 16 deletions lib/helper/Appium.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
let webdriverio

import * as webdriverio from 'webdriverio'
import fs from 'fs'
import axios from 'axios'
import { v4 as uuidv4 } from 'uuid'
Expand All @@ -10,6 +9,8 @@ import { truth } from '../assert/truth.js'
import recorder from '../recorder.js'
import Locator from '../locator.js'
import ConnectionRefused from './errors/ConnectionRefused.js'
import ElementNotFound from './errors/ElementNotFound.js'
import { dontSeeElementError } from './errors/ElementAssertion.js'

const mobileRoot = '//*'
const webRoot = 'body'
Expand Down Expand Up @@ -181,7 +182,6 @@ class Appium extends Webdriver {
this.appiumV2 = config.appiumV2 || true
this.axios = axios.create()

webdriverio = require('webdriverio')
if (!config.appiumV2) {
console.log('The Appium core team does not maintain Appium 1.x anymore since the 1st of January 2022. Appium 2.x is used by default.')
console.log('More info: https://bit.ly/appium-v2-migration')
Expand Down Expand Up @@ -1549,11 +1549,9 @@ class Appium extends Webdriver {
// For mobile native apps, use safe isDisplayed wrapper
const parsedLocator = parseLocator.call(this, locator)
const res = await this._locate(parsedLocator, false)
const { truth } = require('../assert/truth')
const Locator = require('../locator')

if (!res || res.length === 0) {
return truth(`elements of ${new Locator(parsedLocator)}`, 'to be seen').negate(false)
return truth(`elements of ${Locator.build(parsedLocator)}`, 'to be seen').negate(false)
}

const selected = []
Expand All @@ -1563,7 +1561,7 @@ class Appium extends Webdriver {
}

try {
return truth(`elements of ${new Locator(parsedLocator)}`, 'to be seen').negate(selected)
return truth(`elements of ${Locator.build(parsedLocator)}`, 'to be seen').negate(selected)
} catch (err) {
throw err
}
Expand Down Expand Up @@ -1714,10 +1712,6 @@ class Appium extends Webdriver {
// For mobile native apps, use safe isDisplayed wrapper
const parsedLocator = parseLocator.call(this, locator)
const res = await this._locate(parsedLocator, true)
const ElementNotFound = require('./errors/ElementNotFound')
const { truth } = require('../assert/truth')
const { dontSeeElementError } = require('./errors/ElementAssertion')
const Locator = require('../locator')

if (!res || res.length === 0) {
throw new ElementNotFound(parsedLocator)
Expand All @@ -1730,7 +1724,7 @@ class Appium extends Webdriver {
}

try {
return truth(`elements of ${new Locator(parsedLocator)}`, 'to be seen').assert(selected)
return truth(`elements of ${Locator.build(parsedLocator)}`, 'to be seen').assert(selected)
} catch (e) {
dontSeeElementError(parsedLocator)
}
Expand Down Expand Up @@ -1784,7 +1778,6 @@ class Appium extends Webdriver {
// For mobile native apps, use safe isDisplayed wrapper
const parsedLocator = parseLocator.call(this, locator)
const aSec = sec || this.options.waitForTimeoutInSeconds
const Locator = require('../locator')

return this.browser.waitUntil(
async () => {
Expand All @@ -1801,7 +1794,7 @@ class Appium extends Webdriver {
},
{
timeout: aSec * 1000,
timeoutMsg: `element (${new Locator(parsedLocator)}) still not visible after ${aSec} sec`,
timeoutMsg: `element (${Locator.build(parsedLocator)}) still not visible after ${aSec} sec`,
},
)
}
Expand All @@ -1816,7 +1809,6 @@ class Appium extends Webdriver {
// For mobile native apps, use safe isDisplayed wrapper
const parsedLocator = parseLocator.call(this, locator)
const aSec = sec || this.options.waitForTimeoutInSeconds
const Locator = require('../locator')

return this.browser.waitUntil(
async () => {
Expand All @@ -1831,7 +1823,7 @@ class Appium extends Webdriver {

return selected.length === 0
},
{ timeout: aSec * 1000, timeoutMsg: `element (${new Locator(parsedLocator)}) still visible after ${aSec} sec` },
{ timeout: aSec * 1000, timeoutMsg: `element (${Locator.build(parsedLocator)}) still visible after ${aSec} sec` },
)
}

Expand Down
1 change: 1 addition & 0 deletions test/helper/Appium_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as codeceptjs from '../../lib/index.js'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

chai.should()
const expect = chai.expect
const assert = chai.assert
global.codeceptjs = codeceptjs.default || codeceptjs
Expand Down