<table id="_paid_19" class="GOMainTable" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<tr>
<td style="overflow:hidden;">
<div class="GOBodyMid" style="overflow: hidden; width: 625px; height: 334px;">
<div class="GOPageOne">
<table class="GOSection" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<tr class="GODataRow " style="height: 26px;" onmousemove="Grids[3].ARow=Grids[3].Rows["AR1"];Grids[3].ASec=0;">
<td style="width:0px;height:0px"></td>
<td class=" GOClassReadOnly highlight-tbl HoverClass GOText GOCell HideCol3displayName" colspan="2" style="">Automation Smoke test Template</td>
<td class=" GOClassReadOnly highlight-tb HoverClass GOHtml GOCell HideCol3editPencil" colspan="2" style="">
<div class="edit-Pencil"></div>
</td>
<td class=" GOClassReadOnly highlight-tb b_r HoverClass GOHtml GOCell HideCol3deleteIcon" colspan="2" style="">
<td class=" GOClassReadOnly highlight-tb b_r HoverClass GODate GOCell HideCol3dateModified" colspan="2" style="">8/11/2014</td>
<td class=" GOClassReadOnly highlight-tb b_r HoverClass GOText GOCell HideCol3owner" colspan="2" style="">Rachel Lv</td>
<td class=" GOClassReadOnly highlight-tbr HoverClass GOText GOCell HideCol3permission" colspan="2" style="">Read Only</td>
<td class=" HoverClass GOHtml GOCellEmpty GOEmpty HideCol3_ConstWidth"> </td>
</tr>

场景:需要找到Table中的某一行,然后找到这行的铅笔图标,点这个铅笔图标会出来下拉菜单,然后在下拉菜单中点击Open

刚开始写脚本的时候,按照以往的方式会报这样的错误:"Element is not currently visible and so may not be interacted with"

这个元素在界面上是可见的,也通过正则表达式唯一匹配到了,可是在Click的时候就是不行。

后来查阅资料,发现这个元素的父元素是hidden的。

原文如下:

Selenium determines an element is visible or not by the following criteria (use a DOM inspector to determine what css applies to your element, make sure you look at computed style):

  • visibility != hidden
  • display != none (is also checked against every parent element)
  • opacity != 0 (this is not checked for clicking an element)
  • height and width are both > 0
  • for an input, the attribute type != hidden

Your element is matching one of those criteria. If you do not have the ability to change the styling of the element, here is how you can forcefully do it by using Actions in the code.

后来我是这样解决的,可以成功运行了。

Actions action =new Actions(driver);
WebElement pencilIcon = page.getPencilIcon(templateName);
action.moveToElement(pencilIcon).click(); WebElement menu = page.getMenu();
action.moveToElement(menu).build().perform();
Assert.assertTrue(menu.isDisplayed(),"Cannot find the menu"); WebElement open = page.getOpenMenu();
open.click();

[Selenium]How to click on a hidden link ,move to the drop down menu and click submenu的更多相关文章

  1. Python+Selenium练习篇之5-利用partial link text定位元素

    本文介绍如何通过partial link text来定位页面元素.看到这个,有点和前一篇文字link text有点类似.字面意思,确实和link text相类似,partial link text就是 ...

  2. Python 中 selenium 库

    目录 selenium 基础语法 一. 环境配置 1. 安装环境 2. 配置参数 3. 常用参数搭配 4. 分浏览器启动 二. 基本语法 1. 元素定位 2. 控制浏览器操作 3. 操作元素的方法 3 ...

  3. 关于IOS浏览器:document,body的click事件触发规则

    今天做了个手机页面,点击某个按钮->弹出菜单,再点击菜单以外的任意位置->关闭菜单,在其他浏览器里面没有问题,但是在IOS浏览器中并不会关闭. 网上解决这个bug的帖子很多,这篇帖子主要是 ...

  4. click事件触发也有失灵的时候?

    今天做了个手机页面,点击某个按钮->弹出菜单,再点击菜单以外的任意位置->关闭菜单,在其他浏览器里面没有问题,但是在IOS浏览器中并不会关闭. 网上解决这个bug的帖子很多,这篇帖子主要是 ...

  5. Python爬虫利器四之PhantomJS的用法

    前言 大家有没有发现之前我们写的爬虫都有一个共性,就是只能爬取单纯的html代码,如果页面是JS渲染的该怎么办呢?如果我们单纯去分析一个个后台的请求,手动去摸索JS渲染的到的一些结果,那简直没天理了. ...

  6. [转]Code! MVC 5 App with Facebook, Twitter, LinkedIn and Google OAuth2 Sign-on (C#)

    本文转自:https://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-o ...

  7. How to: Debug X++ Code Running in .NET Business Connector [AX 2012]

    This topic has not yet been rated - Rate this topic  http://msdn.microsoft.com/EN-US/library/bb19006 ...

  8. Performance js

    转贴:https://10up.github.io/Engineering-Best-Practices/javascript/#performance Performance Writing per ...

  9. [Selenium]Click element under a hidden element

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

随机推荐

  1. 【C#】App_LocalResources实现多语言

    介绍 如果您创建的网页将由使用不同语言的用户阅读,则必须为这些读者提供用他们自己的语言查看网页的方法.一种方法是分别用各语言重新创建页面,但这种方法可能需要大量工作量.容易出错并且在更改原始页时很难维 ...

  2. bzoj 4006 [JLOI2015]管道连接——斯坦纳树

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4006 除了模板,就是记录 ans[ s ] 表示 s 合法的最小代价.合法即保证 s 里同一 ...

  3. hive 处理小文件,减少map数

    1.hive.merge.mapfiles,True时会合并map输出.2.hive.merge.mapredfiles,True时会合并reduce输出.3.hive.merge.size.per. ...

  4. moodle搭建相关的笔记

    关于moodle内网外网访问问题的解决方案(转) http://blog.chinaunix.net/uid-656828-id-3106027.html

  5. Windows应用程序的VC链接器设置

    Windows应用程序的VC链接器设置 /*转载请注明出自 听风独奏 www.GbcDbj.com */ Windows应用程序分为GUI(Graphical User Interface)和CUI( ...

  6. MySQL性能调优 – 你必须了解的15个重要变量

    1.DEFAULT_STORAGE_ENGINE 如果你已经在用MySQL 5.6或者5.7,并且你的数据表都是InnoDB,那么表示你已经设置好了.如果没有,确保把你的表转换为InnoDB并且设置d ...

  7. C#计数器

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  8. Mysql5.7忘记root密码及mysql5.7修改root密码的方法

    转自:http://www.jb51.net/article/77858.htm 关闭正在运行的 MySQL : ? 1 [root@www.woai.it ~]# service mysql sto ...

  9. Oracle 和 MySQL的区别(不完整)

    1. Oracle对单双引号要求的很死,一般不准用双引号,不然会报错.MySQL 单双引号都可以. 2. 事务提交方式:Oracle 默认手动提交,MySQL 默认自动提交. 3. 分页:MySQL有 ...

  10. Java遍历一个目录下的所有文件

    Java遍历一个目录下的所有文件   Java工具中为我们提供了一个用于管理文件系统的类,这个类就是File类,File类与其他流类不同的是,流类关心的是文件的内容,而File类关心的是磁盘上文件的存 ...