Selenium Find Element
Console -> Inspect Element -> View HTML DOM

get Attribute Name and Value that can find the test element.
Popular elements identification attributes are ID, Name, Class, Linktext, partiallinkText,tagName,xpath,CSS
package pageobjects; import helpers.Log; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.How; import org.openqa.selenium.support.PageFactory; public class LoginPage extends BaseClass{ public LoginPage(WebDriver driver){ super(driver); } @FindBy(how=How.ID, using="email") public static WebElement email; @FindBy(how=How.CLASS_NAME, using="alert-danger") public static WebElement error_message; @FindBy(how=How.CSS, using=".selector,.hover") public static WebElement div_heading; @FindBy(how=How.LINK_TEXT, using="Sign in") public static WebElement sign_in; @FindBy(how=How.XPATH, using="//*a[@title='Dresses']") public static WebElement menu_dresses; } ") public static WebElement error_message; @FindBy(how=How.CSS, using=".selector,.hover") public static WebElement div_heading; @FindBy(how=How.LINK_TEXT, using="Sign in") public static WebElement sign_in; @FindBy(how=How.XPATH, using="//*a[@title='Dresses']") public static WebElement menu_dresses; }

浙公网安备 33010602011771号