`
uniquepig
  • 浏览: 91553 次
  • 性别: Icon_minigender_2
  • 来自: 成都
社区版块
存档分类
最新评论
文章列表
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; /** * @param filePath excel文件路径 * @param col 有效记录列数 * @return 表格内容(每个单元格内容均为St ...
类似于Selenium1中的isElementExsit方法。 判断当前页面中是否存在某个期望查找的元素。 方法代码: public boolean isElementExsit(WebDriver driver, By locator) { boolean flag = false; try { WebElement element=driver.findElement(locator); flag=null!=element; } catch (NoSuchElementException e) { System.out.println(" ...
在自动化测试过程中,由于javascript的使用,我们常常需要点击一些鼠标经过显示的菜单等元素,这时需要触发该元素的鼠标经过事件。使用WebDriver有以下两种实现。 1.使用Action public void moveToElement(WebDriver driver, By locator) { Actions builder = new Actions(driver); builder.moveToElement(driver.findElement(locator)).perform(); } 2.使用Sendkey public void moveToEle ...
在自动化测试过程中,有些情况下我们会遇到一些潜在的Javascript弹出框。(即某些条件下才会出现,不是固定出现),然后如果当这种弹出框出现,我们没有加以处理,WebDriver将无法进行下一步的操作,并且会抛出NoAlertPresentException的异常(从2.16版本开始)。所以,使用以下方法可以处理潜在的1个alert(javascript弹出框)。 public boolean dealPotentialAlert(WebDriver driver,boolean option) { boolean flag = false; try { Alert al ...
public static boolean waitPageRefresh(WebElement trigger) { int refreshTime = 0; boolean isRefresh = false; try { for (int i = 1; i < 60; i++) { refreshTime = i; trigger.getTagName(); Thread.sleep(1000); } } catch (StaleElementReferenceException e) { isRefre ...
Exception NoSuchElementException Solutions    1. Check the locator of your target element. 2. If the locator is current. Try to wait for page load before find element. 3. If already wait for long time and always cannot find the element, try to use another type locator. Exception  NoSuchWindowExcep ...
在webdriver官方的api中,切换窗口的方法提供的参数是nameOrHandle。引用WebDriver window(java.lang.String nameOrHandle)           Switch the focus of future commands for this driver to the window with the given name/handle. 但是在实际运用中,更多的可能是需要根据新窗口的title去切换窗口。因此封装了如下方法: public boolean switchToWindow(WebDriver driver,String win ...
类似于seleniumRC中的isTextPresent 方法 用xpath匹配所有元素(//*[contains(.,'keyword')]),判断是否存在包含期望关键字的元素。 使用时可以根据需要调整参数和返回值。 public boolean isContentAppeared(WebDriver driver,String content) { boolean status = false; try { driver.findElement(By.xpath("//*[contains(.,'" + content + "')]&quo ...
Global site tag (gtag.js) - Google Analytics