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. DataTable快速定制之Expression属性表达式

    本文旨在讨论使用DataColumn.Expression属性定制列,高手绕过. 这里只介绍两个经典的场景,抛砖引玉其他更多功能待各位读者自己发现吧! 场景一: DataTable里有两个列分别为每种 ...

  2. Dictionary字典类介绍

    说明     必须包含名空间System.Collection.Generic      Dictionary里面的每一个元素都是一个键值对(由二个元素组成:键和值)      键必须是唯一的,而值不 ...

  3. TVS 选型

    TVS 选型 主要用于 IO 保护 TVS 的电压不要小于正常工作的电压,不然会影响正常工作. ESD 的电压很高,但是时间很短. TVS 有节电容,用于高速线路时要注意. 有双向的,也有单向的,还有 ...

  4. 解决yum 不能更新问题 :yum 报错Loaded plugins: fastestmirror, refresh-packagekit, security

    2018-07-02       21:43:13 Yum报错 [root@db yum.repos.d]# yum makecache Loaded plugins: fastestmirror, ...

  5. centos 6.5 单实例搭建 ELK

    2018-07-02     21:32:33 ELK 单实例搭建 环境搭建 1.1我的系统版本 Distributor ID: CentOS Description:     CentOS rele ...

  6. ORA-09817: Write to audit file failed 的解决

    今天在进行awr报表导出时,用sys as sysdba 登录,不能connect,报ORA-09817: Write to audit file failed 错误,是系统空间不足的报警.df -l ...

  7. 归并排序算法-python实现

    #-*- coding: UTF-8 -*- import numpy as np def Merge(a, f, m, l): i = f j = m + 1 tmp = [] while i &l ...

  8. [html][LigerUI]使用示例

    <link href="Source/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet&quo ...

  9. [转]MVC 经验总结_EF

    && o.Name != "") .OrderByDescending(o => o.ID) .OrderBy(o => o.Name) .Select ...

  10. NP、NPC、NP-hard问题的定义

    NP-hard问题    定义:NP-hard问题是这样的问题,只要其中某个问题可以在P时间内解决,那么所有的NP问题就都可以在P时间内解决了.NP-c问题就是NP-hard问题.但注意NP-hard ...