In learning selenium 2 java, I encountered a drop-down box when I wrote the use case of the receiving address. I just practiced the use of select. Now I share it for your reference.
//Delete Add Receiving Address public static void deleteAndAddUserAdress(WebDriver driver) throws InterruptedException { clickUser(driver); findElementByTextAndClick(driver, "Personal information"); findElementByTextAndClick(driver, "Receiving address"); clickDeleteAdress(driver); sleep(0); clickSure(driver); AddAddress(driver); String name = getTextByXpath(driver, ".//*[@id='main']/div[2]/div/div/div[1]/p[1]"); assertTrue("Failed to add harvest address!", name.equals("Consignee:Test consignee")); }
The following is a specific way to add the receiving address:
//Add Receiving Address public static void AddAdress(WebDriver driver) { findElementByIdAndClick(driver, "add-address-btn");//Click Add Address findElementByXpathAndClearSendkeys(driver, ".//* [@id='LAY_layuipro1a']/div/div[1]/table/tbody/tr[1]/td[2]/div/input,""Test consignee";//Add consignee" findElementByXpathAndClearSendkeys(driver, ".//*[@id='LAY_layuipro1a']/div/div[1]/table/tbody/tr[2]/td[2]/div/input "," 13120454218 "; / / input cell phone number //Selection of provinces, cities and counties, and detailed addresses Select province = new Select(findElementByid(driver, "province-select")); province.selectByIndex(1); Select city = new Select(findElementByid(driver, "city-select")); city.selectByIndex(1); Select area = new Select(findElementByid(driver, "area-select")); area.selectByIndex(1); findElementByClassnameAndClearSendkeys(driver, "textarea", "I'm the test address."); clickSave(driver); }
Selection of previous articles
- One line of java code prints a heart
- Linux performance monitoring software netdata Chinese version
- Interface Test Code Coverage (jacoco) Scheme Sharing
- Performance testing framework
- How to Enjoy Performance Testing on Linux Command Line Interface
- Graphic HTTP Brain Map
- Writing to everyone about programming thinking
- How to Test Probabilistic Business Interface
- httpclient handles multi-user simultaneous online
- Ten Steps to Become a Great Java Developer
- Automatically convert swagger documents into test code
- Five lines of code to build static blogs
- How httpclient handles 302 redirection