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. L3-014 周游世界 (30 分)

    周游世界是件浪漫事,但规划旅行路线就不一定了…… 全世界有成千上万条航线.铁路线.大巴线,令人眼花缭乱.所以旅行社会选择部分运输公司组成联盟,每家公司提供一条线路,然后帮助客户规划由联盟内企业支持的旅 ...

  2. RabbitMQ引入

    引入MQ话题 可能很多人有疑惑:MQ到底是什么?哪些场景下要使用MQ? 前段时间安装了RabbitMQ,现在就记录下自己的学习心得吧.首先看段程序: class Program { static vo ...

  3. PAT 1007 素数对猜想 C语言

    让我们定义 dn 为:dn = pn+1 - pn,其中 pi 是第i个素数.显然有 d1=1 且对于n>1有 dn 是偶数.“素数对猜想”认为“存在无穷多对相邻且差为2的素数”. 现给定任意正 ...

  4. ambassador 学习三 限速处理

    与认证类似ambassador 也是委托给三方的其他服务进行限速处理 基本的环境安装可以参考相关文档,主要还是qotm 服务 官方参考实现的简单限速服务 --- apiVersion: v1 kind ...

  5. Rails Cookie和session使用

    Rails通过cookies方法来操作cookie.这和session的操作有点相似 class CommentsController < ApplicationController def n ...

  6. docker 数据卷 ---- 进阶篇

    笔者在<Docker 基础 : 数据管理>一文中介绍了 docker 数据卷(volume) 的基本用法.随着使用的深入,笔者对 docker 数据卷的理解与认识也在不断的增强.本文将在前 ...

  7. eclipse 3.7 中英文自由切换

    最近在学习Java的开发,然后又很多的资料是对于的英文环境讲解,有的资料是对应的中文环境讲解,所以很都对不上号,郁闷啊....... 而且开发的时候,每个人都使用习惯也不相同:有的人喜欢英文界面,有的 ...

  8. js中caller和callee属性详解

    一.caller属性返回一个对函数的引用,该函数调用了当前函数.functionName.callerfunctionName 对象是所执行函数的名称.说明对于函数来说,caller 属性只有在函数执 ...

  9. CentOS 6.0 VNC远程桌面配置方法(转帖)

    问题:新装开发机,安装VNC软件后,按照下面文档配置后,无法用VNC view连接,关闭防火墙后可以连上 解决方法:说明问题出在防火墙配置上,除了允许15900端口外,还有其他要设,经过排查后,加上如 ...

  10. weex入门篇

    weex入门篇 Weex 致力于使开发者能基于当代先进的 Web 开发技术,使用同一套代码来构建 Android.iOS 和 Web 应用. weex SDK 集成了vueJS,Rax,不需要额外引入 ...