Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

customLocator plugin not working (?) with Appium Helper #3818

Unanswered
clundstedt-m asked this question in Q&A
Discussion options

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

You must be logged in to vote

Replies: 1 comment

Comment options

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';
 }
 }
});

https://codecept.io/locators/#custom-locators

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /