Study everyday from now on!
Seleium方法
上一篇 /
下一篇 2013-05-16 16:55:54
/ 个人分类:Selenium
使用selenium 这个对象来进行测试 1 获取标 : assertEquals("Insert title here", selenium.getTitle());
2 判断页面是否存在一个user.email元素 :assertTrue(selenium.isElementPresent("xpath=//input[@name='user.email']"));
3 得到文本框里的文字: assertEquals(selenium.getValue("xpath=//input[@name='user.username']"),"xxxaas");
4 测试check box : assertTrue(selenium.isChecked("xpath=//input[(@name='user.sex')and(@value='男')]"));
5 点击提交按钮 : selenium.click("xpath=//input[@type='button']");
6 等待页面载入 : selenium.waitForPageToLoad("2000");
7 验证指定文本出现在提交给用户的页面上: assertTrue(selenium.isTextPresent("验证码输入有误,请核实后再输入"));
8 判断下拉框里选择了哪个选项 :assertEquals(selenium.getSelectedIndex("xpath=//SELECT[@name='HATIMING']"), "1");
9 如何测试一些错误消息的显示? assertTrue(selenium.getBodyText().indexOf("错误消息")>=0);
getBodyText 返回的时浏览器页面上的文字,不回包含html 代码的,如果要显示html 代码,用下面这个:selenium.getHtmlSource();
收藏
举报
TAG: