摘要:
方式1: 线程等待:Thread.sleep(xxxx) 只要在case中加入sleep就会强制等待设置的时间后才会执行之后的命令,这种等待一般适用于调试脚本的时候。 java代码 //等待3秒 Thread.sleep(3000); //完全退出浏览器 driver.quit(); 方式2: 隐试 阅读全文
posted @ 2023-04-08 21:54
iTao0128
阅读(115)
评论(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
iTao0128
阅读(59)
评论(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
iTao0128
阅读(141)
评论(0)
推荐(0)
摘要:
1. selectByIndex() 根据索引来选取,从0开始 2. selectByValue() 根据属性value的属性值来选取 3. selectByVisibleText()根据标签之间的Text值,也就是页面显示的 注意:导入的包要正确不然会报错。 import org.openqa.s 阅读全文
posted @ 2023-04-08 21:43
iTao0128
阅读(107)
评论(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
iTao0128
阅读(18)
评论(0)
推荐(0)
摘要:
一、浏览器操作命令 启动火狐浏览器(49版本以下) System.setProperty("webdriver.firefox.bin","D:\\Firefox\\firefox.exe");WebDriver driver=new FirefoxDriver(); (谷歌和IE通过浏览器驱动启动 阅读全文
posted @ 2023-04-08 21:35
iTao0128
阅读(327)
评论(0)
推荐(0)
摘要:
java代码 JavascriptExecutor js=(JavascriptExecutor)driver; js.executeScript("document.getElementById('beginDate').value='2020-05-10'"); 阅读全文
posted @ 2023-04-08 19:20
iTao0128
阅读(19)
评论(0)
推荐(0)

浙公网安备 33010602011771号