selenium-webdriver - 无法在页面对象类中使用 WebElements 对象
问题描述
一般来说,我是 Selenium 和 java 的新手。我正在尝试将 Page 对象模型与 Page 工厂一起使用来为应用程序的登录页面创建 Page 对象类。当我创建一个方法时,WebElement 对象错误指示以下内容:错误消息。我见过其他的 webelements 不必是静态的演示。我不知道我做错了什么。
package com.imis.pages;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import Actiondriver.ImisActionclass;
import Base.basepackage;
public class login extends basepackage {
@FindBy(xpath="//input[@id='ctl01_TemplateBody_WebPartManager1_gwpciSignIn_ciSignIn_signInUserName']")
WebElement userName;
@FindBy(xpath="//input[@id='ctl01_TemplateBody_WebPartManager1_gwpciSignIn_ciSignIn_signInPassword']")
WebElement password;
@FindBy(xpath="//input[@id='ctl01_TemplateBody_WebPartManager1_gwpciSignIn_ciSignIn_SubmitButton']")
WebElement submitButton;
public login() {
PageFactory.initElements(driver, this);
}
public static void loginpage(String uname, String pswd) {
ImisActionclass.type(userName, text);
ImisActionclass.type(pswd, password);
ImisActionclass.click(driver, submitButton);
解决方案
推荐阅读
- gatsby - Gatsby Wordpress 源插件中的内联图像
- css - 在比您的屏幕更大的屏幕上进行响应式设计 - 我该怎么做?
- swift - Swift 编译器对我的返回类型做了什么?它以某种方式铸造吗?
- google-cloud-platform - 有没有办法在函数或过程中获取 BigQuery 函数或过程名称?
- sql - 如何根据单元格值删除行?- SQL
- javascript - JSON.parse = 当另一个值等于特定值时如何返回一个值?
- ios - AudioKit v5 输出问题,使用 AVAudioSession defaultToSpeaker 时没有声音
- c# - 尝试使用模型反序列化 json 时出现问题
- terraform - 用于将 json 作为值放入地图的 Terraform 语法
- typescript - 为什么 typescript mixins 需要一个带有单个 rest 参数 any[] 的构造函数?