zoukankan      html  css  js  c++  java
  • 自动化框架FluentLenium学习

    github地址:https://github.com/FluentLenium/FluentLenium

    常用的页面控件操作方法(element需要先通过css selector找到):

    [button]              button.click();

    1 @FindBy(css = "#searchBtn")
    2 private FluentWebElement searchBtn;

    [input]              fill("input[name='name']").with(name);

    [checkbox]          find("input[type=checkbox]").click();

    [radionbutton]      find("input[type=radio]").click();

    [file upload]      element.getElement().sendKeys(filePath);

    [selector]                 fillSelect("select[name='year']").withText("2014");

    [select checkbox]      //下拉复选框

    这种情况没有直接的方法使用,一般是点击两次达到复选的结果,封装的方法如下:

    1 protected void multiSelect(String selector, List<String> texts) {
    2     find(selector + " + div .multiselect").click();
    3     for (String text : texts) {
    4         await().atMost(5, TimeUnit.SECONDS).until(selector + " + div .multiselect-container").areDisplayed();
    5         find(selector + " + div .multiselect-container").find(".checkbox", withText(text)).click();
    6     }
    7 }

     [时间控件]

    如果时间控件是可以直接输入的话,可以用[input]控件的方法.

    但是如果不能直接输入,必须得点击选择的话,可以使用js来赋值,如下:

    1 executeScript("document.getElementsByName('startTime')[0].value=" + """ + startTime + """ + ";");

     [下载]

    下载需要先设置Firefox浏览器的属性,如下:

    1 FirefoxProfile firefoxProfile = new FirefoxProfile();
    2 String userHome = System.getProperty("user.home");
    3 firefoxProfile.setPreference("browser.download.dir", userHome + "/Downloads");
    4 firefoxProfile.setPreference("browser.download.folderList", 2);
    5 firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf, " +
    6         "application/octet-stream, application/vnd.ms-excel, text/csv, application/zip");
    7 firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false);
    8 return new FirefoxDriver(firefoxProfile);
  • 相关阅读:
    python --函数
    Python基本数据类型
    初识python
    【 D3.js 高级系列 — 8.0 】 标线
    【 D3.js 高级系列 — 7.0 】 标注地点
    Azure SQL 数据库最新版本现已提供预览版
    Azure SQL 数据库新服务级别现已正式发布
    聚焦 SQL 数据库活动异地复制
    Azure SQL 数据库:服务级别与性能问答
    Azure SQL 数据库:新服务级别问答
  • 原文地址:https://www.cnblogs.com/shevche/p/4194588.html
Copyright © 2011-2022 走看看