package test;
import org.junit.Before;
import org.junit.Test;
import com.thoughtworks.selenium.*;
public class Query extends SeleneseTestBase {
@Before
public void setUp() throws Exception {
setUp("http://www.jd.com/", "*firefox");
selenium.setSpeed("1000");
selenium.windowMaximize();
selenium.setTimeout("60000");
}
@Test
public void testRegister() throws Exception {//购买和取消购买功能
selenium.open("/");
selenium.type("key","selenium");
selenium.click("//input[@value='搜索' and @type='button']");//搜索
selenium.waitForPageToLoad("60000");
assertTrue(selenium.isTextPresent("Selenium自动化测试指南"));//验证是否存在
selenium.click("//li[@bookid='11321029']/div[@class='btns']/a[1]");
String[] titles = selenium.getAllWindowTitles(); //得到所有窗口的标题
selenium.selectWindow("title="+titles[titles.length-1]);
assertTrue(selenium.isTextPresent("商品已成功加入购物车!"));
selenium.click("GotoShoppingCart");//放进购物车
selenium.click("toSettlement");
selenium.type("loginname", "username");
selenium.type("nloginpwd","password");
selenium.click("loginsubmitframe");//登录
selenium.click("order-submit");
assertTrue(selenium.isTextPresent("感谢您,订单提交成功!"));//验证提交订单成功
selenium.click("link=我的订单");
selenium.click("link=取消订单");
selenium.click("//div[@class='btns']/a[1]");
selenium.click("radio_option367");
}
}
商品查询,登录,购买和取消
最新推荐文章于 2019-10-14 21:13:06 发布