量角器定位器在 PageObjectModel 结构中不起作用



框架:Appium + 量角器 + 黄瓜 + 使用 POM 模型的打字稿

  • 我有用POM结构设计的appium量角器框架
    • 应用程序的初始页面将标识在不同 ts 文件中调用的定位器,以及 tap、isDisplay等功能在不同的 ts 文件中调用它。
    • 但是一旦它通过了应用程序中的初始页面,比如说 3 页。 定位器没有被识别出来,它们在直接传递时被识别(如driver.findelements(by.css(''((.click(。
    • 问题是我不能总是在步骤定义.ts文件中像这样传递这段代码,因为它不是一个好的结构

注意:顺便说一下,此脚本之前工作正常。 尝试使用不同的解决方法进行测试,例如再次构建二进制文件,尝试在Android和iOS应用程序上运行,降级或升级节点包。但没有什么能解决问题。有没有人遇到过这种问题。请问这个问题有什么建议或解决方案吗?

有效的代码:(直接在函数中传递定位器,而不是从onboarding.ts文件传递定位器将起作用(

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

不起作用的代码:(Onboarding.ts 文件包含为 State 和 VIC 定义的定位器,与上述代码块相同。但是从那里阅读是行不通的。

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

有效的代码(下面的代码在上面的代码块之前调用,它是调用上述页面之前的页面(

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

}(;

由于页面失败,自动化认为它是非角度页面,而定位器在不同函数中调用它时曾经失败或找不到它们。当我引入browser.ignoreSycnhronization=true来为非角度应用程序/页面进行Angular同步时,它起作用了。

相关内容

最新更新