The World’s Largest Online Community for Developers

'; android - Protractor locators does not work in PageObjectModel structure - LavOzs.Com

Framework: Appium + Protractor + Cucumber + Typescript using POM model

  • I have the protractor framework for appium designed in POM structure
    • The initial page of the app will identify the locators calling in a different ts file and the functions such as tap, isDisplayed calling it in a different ts file.
    • But once it passes the initial pages in the app,say 3 pages. the locators are not identified which are calling other function, but they are identified when they are passed directly ( like driver.findelements(by.css('')).click ) this works.
    • The problem is I can't pass this code like this within the step definition .ts file always as it is not a good structure

Note: By the way, this script was working fine earlier. tried to test using a different workaround, like building the binary again, trying to run on android and ios application, downgrading or upgrading the node packages. But nothing solved the problem. has anyone faced this kind of issue. Any suggestions or solutions for this problem, please?

Code which works: (Passing the locators directly in the function, rather than from the onboarding.ts file will work)

Then(/^VIC should be selected from the state or territory drop down$/, async () => {
await browser.driver.findElement(by.css('button[sp-automation-id=\'select-state-toggle\']')).click();
await browser.driver.findElement(by.css('page-action-sheet label[sp-automation-id=\'action-sheet-option-VIC\']')).click(); });

Code which does not work: (Onboarding.ts file contains the locators defined for State and VIC same as the above code block. But reading from there it does not work.)

Then(/^VIC should be selected from the state or territory drop down$/, async () => {
await AutomationAction.tap(Onboarding.State);
await AutomationAction.tap(Onboarding.VIC); });

Code which works (The below code is called before the above code block, it's a page before calling the above pages)

Then(/^I enter the mobile number and tap next button on the your mobile number screen$/, async () => {
 MobileNo = AutomationAction.getMobileNumber("mobileNumber");
 SameMobileNo = MobileNo;
 await AutomationAction.sendKeyText(Onboarding.InputMobileNo,MobileNo);
 await AutomationAction.tap(Onboarding.Next_BTN_YourMobileNumber);


Because of the page where it is failing the automation thinks its as non-angular page and the locators used to fail or not locate them when calling it in a different function. When I introduced browser.ignoreSycnhronization=true to make Angular sync for non-angular apps/pages it worked.

how to pass the value in protractor like this element(by.model('filter.dateRange')).$('[value=“<parameter>”)
Click() function isn't working in protractor scripts
Can I fetch test data from JSON file to page object file in protractor
Error: Unable to capture screenshot - Android hybrid app using Protractor and Appium
Handling Drop Down using Protractor
Code to click a radio button does not work the second time in my Protractor script
waitForAngularEnable(true) NOT working - ScriptTimeoutError: script timeout: result was not received in
Protractor Custom Locator is getting failed to locate the element
I cannot implement an async function