摘要: Web测试项目中经常进行浏览器兼容性相关的测试工作,因为兼容性测试的工作重复性相当高,所以导致手工测试效率低下测试人员积极性降低。TestNG提供了并发执行测试用例的功能,可以让测试用例以并发的形式执行,实现测试不同浏览器的兼容性测试。 下面代码中分别使用Chrome、Firefox和IE浏览器,T 阅读全文
posted @ 2023-04-08 21:54 Mr_sven 阅读(21) 评论(0) 推荐(0) 编辑
摘要: 方式1: 线程等待:Thread.sleep(xxxx) 只要在case中加入sleep就会强制等待设置的时间后才会执行之后的命令,这种等待一般适用于调试脚本的时候。 java代码 //等待3秒 Thread.sleep(3000); //完全退出浏览器 driver.quit(); 方式2: 隐试 阅读全文
posted @ 2023-04-08 21:54 Mr_sven 阅读(55) 评论(0) 推荐(0) 编辑
摘要: Actions类 一、鼠标右击、双击 Java代码 //定位百度首页右上角 新闻 WebElement Xw=driver.findElement(By.xpath("//*[@id='u1']/a[1]")); //new Actions对象 Actions RightClick=new Acti 阅读全文
posted @ 2023-04-08 21:51 Mr_sven 阅读(31) 评论(0) 推荐(0) 编辑
摘要: 一、访问网页地址:get(url) Java代码 String url="http://www.baidu.com"; driver.get(url); 二、刷新当前网页:navigate().refresh() java代码 String url="http://www.baidu.com"; d 阅读全文
posted @ 2023-04-08 21:45 Mr_sven 阅读(75) 评论(0) 推荐(0) 编辑
摘要: 1. selectByIndex() 根据索引来选取,从0开始 2. selectByValue() 根据属性value的属性值来选取 3. selectByVisibleText()根据标签之间的Text值,也就是页面显示的 注意:导入的包要正确不然会报错。 import org.openqa.s 阅读全文
posted @ 2023-04-08 21:43 Mr_sven 阅读(81) 评论(0) 推荐(0) 编辑
摘要: HTML源码 <td>sendkeys上传</td> <div id='pf'><input type='file' id='postfile'/></div> java代码 WebElement pf=driver.findElement(By.xpath("//*[@id='pf']/input 阅读全文
posted @ 2023-04-08 21:39 Mr_sven 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 一、浏览器操作命令 启动火狐浏览器(49版本以下) System.setProperty("webdriver.firefox.bin","D:\\Firefox\\firefox.exe");WebDriver driver=new FirefoxDriver(); (谷歌和IE通过浏览器驱动启动 阅读全文
posted @ 2023-04-08 21:35 Mr_sven 阅读(283) 评论(0) 推荐(0) 编辑
摘要: java代码 JavascriptExecutor js=(JavascriptExecutor)driver; js.executeScript("document.getElementById('beginDate').value='2020-05-10'"); 阅读全文
posted @ 2023-04-08 19:20 Mr_sven 阅读(12) 评论(0) 推荐(0) 编辑