Description:

Find out the DDL in Treegrid, but cannot click on it.Because the element is under a hidden element.

Have tried all below solutions:

1) theDDL.click();

2) SeleniumUtil.jsClick(driver, theDDL);

3) Actions action = new Actions(driver);

action.moveToElement(theDDL).perform();

4) JavascriptExecutor js = (JavascriptExecutor)driver;

String jsStr = "$('td>div>div:eq("+theDDL+")').click()";

js.executeScript(jsStr);

5) JavascriptExecutor js = (JavascriptExecutor)driver;

js.executeScript("arguments[0].click();", theDDL);

Solution:

In order to click the element ,change it to visible firstly.When we operate manually,actually,we first move the mouse to the row ,and then click the element.

So, when automate the click action,we also need to move the mouse to the row firstly,then the element will be visible,this is the trick.

Hover to the row of DDL, move mouse to the front of the row, then click the DDL would work.

Code:

WebElement theRow = this.findBlankBenchmarkRow();

  Assert.assertNotSame(theRow, null, "Should find out a blank benchmark row.");

  Actions action = new Actions(driver);

  System.out.println("Row size : "+theRow.getSize());

  System.out.println(("X offset : "+(theRow.getSize().width)/100));

  System.out.println(("Y offset : "+(theRow.getSize().height)/2));

  int locx=0;

  int locy=0;

  locx=(theRow.getSize().width)/100;

  locy=(theRow.getSize().height)/2;

  action.moveToElement(theRow, locx, locy).perform();

  SeleniumUtil.sleep(2);

  WebElement theDDL = theRow.findElement(By.cssSelector("td div.dash-bmk-ddl"));

  return theDDL;

[Selenium]Click element under a hidden element的更多相关文章

  1. [Selenium] The commonly used operation of element

    btnLogin.click();     //Click element SeleniumUtil.jsClick(driver, saveButtonEl);     //If click()  ...

  2. selenium之坑(StaleElementReferenceException: Message: Element not found in the cache...)

    有时候循环点击一列链接,只能点到第一个,第二个就失败了 原因是第二个已经是新页面,当然找不到之前页面的元素.就算是后退回来的,页面也是不一样的 页面长的一样不一定是同一张页面,就像两个人长的一样不一定 ...

  3. selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document

    抓取网页代码后,由于是在同一个li标签下,所以使用一次性抓取,所有的a标签,然后循环做不同的操作,但是抛出找不到元素异常. def office_page(_chrome: Chrome): sn = ...

  4. org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element

    org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element(识别不到想要的元素) 想获取 ...

  5. select2取值报错,Failed to read the 'selectionDirection' property from 'HTMLInputElement': The input element's type ('hidden') does not support selection.

    用到了 select2 组件来多选收件人,用搜狗浏览器(6.2版高速模式)在执行到如下这句时报错(Uncaught InvalidStateError: Failed to read the 'sel ...

  6. 元素无法定位问题 NoSuchElementException: Message: no such element: Unable to locate element 解决方法

    定位网页上某个按钮时,总是报错元素定位不到,具体如下:NoSuchElementException: Message: no such element: Unable to locate elemen ...

  7. Selenium click不生效 报错selenium.common.exceptions.InvalidArgumentException

    记录在使用selenium过程中踩的坑------ 在使用selenium时,用click点击网站弹出的文件上传框的"上传文件"按钮不生效,报错selenium.common.ex ...

  8. 关于xpath语句完全正确,但是页面报错: no such element: Unable to locate element: {"method":"xpath","selector":"xpath"}

    之前使用selenium-webdriver来写UI的自动化脚本,发现有一个元素一直无法定位,查看其源码,如下 利用xpathChecker验证了xpath语句的是正确的,但是控制台一直报错: no ...

  9. HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)

    IE8报错误: 用户代理: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .N ...

随机推荐

  1. 7-17 Hashing(25 分)

    The task of this problem is simple: insert a sequence of distinct positive integers into a hash tabl ...

  2. (转)关于fflush(stdin)清空输入缓存流(C/C++)

    来源:http://my.oschina.net/deanzhao/blog/79790 1. 为什么 fflush(stdin) 是错的?首先请看以下程序: #include <stdio.h ...

  3. 【idea】如何安装jetty容器,并使用。

    参考:https://www.jetbrains.com/idea/help/run-debug-configuration-jetty-server.html背景:web开发当中,我觉得服务层的代码 ...

  4. 实例化Bean的方法(基于xml配置)-http://blog.csdn.net/shymi1991/article/details/48153293

    实例化Bean的方法(基于xml配置) 标签: spring framework 2015-09-01 13:43 918人阅读 评论(0) 收藏 举报  分类: Spring FrameWork(7 ...

  5. Animation获得当前播放的第几帧

    http://blog.csdn.net/cocos2der/article/details/8728443 http://www.it165.net/pro/html/201405/13204.ht ...

  6. 深入理解java虚拟机,内存管理部分

    1,对象回收前会调用finalize()方法,尝试自救,只能调用一次 2,上面横向对比c++的析构函数,但是java有良好的内存管理,而且try/catch做得比较好 3,回收一个常量,1,对象的实例 ...

  7. centos 6.5 下 安装 git

    2018-07-02 centos安装Git有两种方式,一种通过源安装,通过如下命今,即可一键安装成功: yum -y install git 但是通过源安装的Git,目前最高版本是1.7,想要使用更 ...

  8. RK3288 开机动画旋转

    CPU:RK3288 系统:Android 5.1 如果开机动画与屏显示方向不一致,有两种方法可以更改开机动画方向. 一.RK3288默认的开机动画是由两张图片组合而成的,可以直接旋转两张图片的方向. ...

  9. linux上安装Qt4.8.6+QtCreator4.0.3

    一.Qt简介 Qt是1991年奇趣科技开发的一个跨平台的C++图形用户界面应用程序框架.它提供给应用程序开发者建立艺术级的图形用户界面所需的所有功能.Qt很容易扩展,并且允许真正地组件编程. 准备工作 ...

  10. struts2学习(1)struts2 helloWorld

    一.struts2简介: 二.helloWorld: 1)工程结构: HelloWorldAction.java: package com.cy.action; import com.opensymp ...