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. 安装配置adb工具及遇到的问题

    一. 下载安装 配置环境 二.遇到的问题 1.Terminal 不是内部或外部命令,也不是可运行程序或批处理文件 https://blog.csdn.net/wuqilianga/article/de ...

  2. Codeforces 580B: Kefa and Company(前缀和)

    http://codeforces.com/problemset/problem/580/B 题意:Kefa有n个朋友,要和这n个朋友中的一些出去,这些朋友有一些钱,并且和Kefa有一定的友谊值,要求 ...

  3. git操作提交方式

    git代码提交 第一次提交代码 在本地建立一个文件夹用来存储代码,相当于一个仓库进入文件夹目录输入下面命令 echo "# xxx" >> README.md (添加一 ...

  4. [BZOJ5312]冒险

    bzoj CSAcademy description 一个序列\(a_i\),支持区间与一个数,区间或一个数,求区间最大值. \(n,m\le2\times10^5\) sol 线段树每个节点上维护区 ...

  5. [BZOJ2727][HNOI2012]双十字

    bzoj luogu sol 先预处理从每个点出发向上/下/左/右能延伸多长. 考虑怎么计算答案.我们只要枚举中轴线,再枚举上方的十字交点,枚举下方的十字交点,然后算答案即可. 考虑一个左右宽的最小值 ...

  6. 黄聪:[C#]如何获取变量的名字,不是值,是名称。返回名字的字符串

    找了好久,最后在国外的论坛找到了解决办法,直接贴代码吧. 方法一: public static class MemberInfoGetting { public static string GetMe ...

  7. C++ 类成员的构造和析构顺序

    我想对面向对象有了解的童鞋应该不会对类和对象感到陌生吧 ! 对象并不是突然建立起来的,创建对象必须时必须同时创建父类以及包含于其中的对象.C++遵循如下的创建顺序: (1)如果某个类具体基类,执行基类 ...

  8. Bootstrap-CL:列表组

    ylbtech-Bootstrap-CL:列表组 1.返回顶部 1. Bootstrap 列表组 本章我们将讲解列表组.列表组件用于以列表形式呈现复杂的和自定义的内容.创建一个基本的列表组的步骤如下: ...

  9. SpringBoot入门(1)

    一.初始 ①.首先还是要创建一个maven工程 ②.然后编写Controller 让SpringBoot跑起来并不需要太多的代码,就能实现了我们平时要配置很多的功能,这是怎么做到的呢?我们就下面一个入 ...

  10. Linux安装Python虚拟环境virtualenv

    1.安装virtulenv.virtulenvwrapper包 pip install virtualenv virtualenvwrapper 2.virtualenvwrapper是virtual ...