zoukankan      html  css  js  c++  java
  • selenium之常用

    ----------------------------------js滚动条----------------------------------
    String js1 = "return document.documentElement.scrollHeight;"; // 滑动条的位置值
    String js2 = "scroll(0,10000);"; 
    ((JavascriptExecutor)webDriver).executeScript(js2);//执行js代码,返回浏览器滚动高度 
    try{ 
    Thread.sleep(3000); //等待浏览器加载 } 
    catch (InterruptedException e) { 
    e.printStackTrace(); 
    
     
     } 
    
     
    ((JavascriptExecutor)webDriver).executeScript(js1);//执行js代码,滚动10000像素 
     
     
    ----------------------------------设置firefox自动下载---------------------------------- 
    FirefoxProfile profile = new FirefoxProfile();  
    profile.setPreference("browser.download.downloadDir", "c:\data");  
    profile.setPreference("browser.download.folderList", 2); //browser.download.folderList 设置Firefox的默认 下载 文件夹。0是桌面;1是“我的下载”;2是自定义  
    profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream, application/vnd.ms-excel, text/csv, application/zip");  
    driver = new FirefoxDriver(profile); 
    ----------------------------------获取元素宽度---------------------------------- 
    String width = message.getCssValue("width"); 
    
    Dimension size=drvier.findElement(By.tagName("img")).getSize();
    int width=size.getWidth();
    int height=size.getHeight();
  • 相关阅读:
    Log4net<转载>
    XSD使用《转载》
    assemble文件中配置
    常用工具《收藏》
    mysql查看所有存储过程,函数,视图,触发器,表《转》
    log4g net 配置
    XSLT使用<转载>
    C#操作xml之xpath语法<收藏>
    如何做镜像服务器
    Android开发之旅:环境搭建及HelloWorld
  • 原文地址:https://www.cnblogs.com/season-xie/p/5330816.html
Copyright © 2011-2022 走看看