在学习selenium2java的时候,在写收货地址相关用例的时候碰到了下拉框,刚好练习了一下select的使用,现在分享,供大家参考。
//删除添加收货地址
public static void deleteAndAddUserAdress(WebDriver driver) throws InterruptedException {
clickUser(driver);
findElementByTextAndClick(driver, "个人信息");
findElementByTextAndClick(driver, "收货地址");
clickDeleteAdress(driver);
sleep(0);
clickSure(driver);
AddAddress(driver);
String name = getTextByXpath(driver, ".//*[@id='main']/div[2]/div/div/div[1]/p[1]");
assertTrue("添加收获地址失败!", name.equals("收货人:测试收货人"));
}
下面是具体的添加收货地址的方法:
//添加收货地址
public static void AddAdress(WebDriver driver) {
findElementByIdAndClick(driver, "add-address-btn");//点击添加地址
findElementByXpathAndClearSendkeys(driver, ".//*[@id='LAY_layuipro1a']/div/div[1]/table/tbody/tr[