zoukankan      html  css  js  c++  java
  • selenium 学习笔记 ---新手学习记录(8) 问题总结(java)

    1.获取执行js代码后的返回值

    //获取滚动距离
    String jl="return $('#chapterul li').height();";
    Long jlhq=(Long)((JavascriptExecutor)driver).executeScript(jl);
    //int jlint=Integer.getInteger(jlhq);
    System.out.println("课程之间的距离为:"+jlhq);
    System.out.println("课程播放到第几个的链接:"+driver.getCurrentUrl());

     2.鼠标移动,悬浮鼠标 在元素出悬浮

     //移动鼠标
      WebElement target=driver.findElement(By.id("ft_7"));
    Actions action=new Actions(driver);
      //action.moveToElement(target);
    //action.clickAndHold(target);
    //action.moveToElement(target, 5, 5);
     //action.moveByOffset(300, 30);
     if(target.isDisplayed()){
        System.out.println("action=================");
       //移动鼠标 
         action.moveToElement(target,20,20).build().perform();
      }
    

     3.元素不可见原因,目前自己知道的有如下几种

    元素不可见:目前我知道的1.没有该元素 2.有但是没有显示出来,隐藏了 3. 元素被浏览器遮挡了 4.元素没有加载出来,就执行了 5.有多个重命名的 
    

     4.操作多个元素

     List<WebElement> elements5 = driver.findElement(By.id("chapterul")).findElements(By.tagName("li"));
    
    int esize=elements5.size();
    
  • 相关阅读:
    Redis
    多线程相关
    selenium操作浏览器的基本方法
    selenium之 webdriver与三大浏览器版本映射表(更新至v2.29)
    selenium安装及官方文档
    Python(3)_python对Json进行操作
    python类中的self参数和cls参数
    python3中shuffle函数
    Python3中assert断言
    python2和python3中range的区别
  • 原文地址:https://www.cnblogs.com/kllay/p/5228043.html
Copyright © 2011-2022 走看看