1. 创建项目 →创建包名→创建页面类 如下:
2.实现代码如下 百度举例;
package POMDemo;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class BaiduPage {
//元素定位//登录链接
@FindBy(xpath=".//*[@id='u1']/a[7]")
WebElement login_link;
//选择用户名登录方式
@FindBy(xpath=".//*[@id='TANGRAM__PSP_10__footerULoginBtn']")
WebElement Ulogin;
//定位用户名文本框
@FindBy(id="TANGRAM__PSP_10__userName")
WebElement username_link;
//定位密码文本框
@FindBy(id="TANGRAM__PSP_10__password")
WebElement password_link;
//登录按钮
@FindBy(id="TANGRAM__PSP_10__subm