赛普拉斯页面对象模型问题:当我运行链接到 PageObject 的测试时收到错误消息

问题描述

问题: 当我运行以下代码时,我在 cypress 中收到一条错误消息。 错误消息“_HomePage.default.getNameBox 不是函数

代码

enter image description here

enter image description here

[![enter image description here][1]][1]
 

解决方法

变量名称中的大写字母有一些问题。

代替这个

const Homepage = new HomePage();    // Homepage is the instance
HomePage.getNameBox()               // uses the class not the instance

约定是在实例的开头使用一个小字符

const homePage = new HomePage();
homePage.getNameBox()               // uses the instance

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...