-
-
Notifications
You must be signed in to change notification settings - Fork 750
customLocator plugin not working (?) with Appium Helper #3818
-
Hey there guys, good morning/afternoon,
We are trying to implement the customLocator plugin on CodeceptJS + Appium (as helper), but it seems that it's not working as expected or maybe not working entirely with the combination given (?)
Right now this is what we have on our codecept.conf file:
const mobileConfig = {
plugins: {
customLocator: {
prefix: '=',
attribute: 'resource-id',
strategy: 'xpath',
showActual: true,
enabled: true,
}
},
helpers: {
Appium: {
appiumV2: true,
'path': '/wd/hub',
smartWait: 20000,
platform: 'Android',
host: "127.0.0.1",
port: 4723,
deviceName: "emulator-5554",
desiredCapabilities: {
....
},
waitForTimeout: 30000
},
And the actual locator is looking like this:
class OnboardingApertura {
locators = {
//inputNumero: "//*[@resource-id='phone-number-input']|//*[@name='phone-number-input']",
inputNumero: '=phone-number-input',
When we run the tests, we are being prompted with the following error:
element (android=new UiSelector().text("=phone-number-input")) still not present on page after 30 sec
Which leads us to think that maybe the customLocator is not being taken into consideration at all 🤔 , since it's translating it automatically to text search which is the "default" way to search the locators when no other prefix/locator allocator is given (id, class, etc).
Are we actually doing something wrong or is the customLocator not working yet with Appium helper?
Best regards and thanks as always
Beta Was this translation helpful? Give feedback.
All reactions
-
👀 1
Replies: 1 comment
-
Not sure if you have this, but don't see in your post:
What if we want to locators prefixed with = to match elements with exact text value. We can do that too:
// inside a plugin or a bootstrap script:
codeceptjs.locator.addFilter((providedLocator, locatorObj) => {
if (typeof providedLocator === 'string') {
// this is a string
if (providedLocator[0] === '=') {
locatorObj.value = `.//*[text()="${providedLocator.substring(1)}"]`;
locatorObj.type = 'xpath';
}
}
});
Beta Was this translation helpful? Give feedback.