1. <table id="_paid_19" class="GOMainTable" cellspacing="0" cellpadding="0">
  2. <tbody>
  3. <tr>
  4. <tr>
  5. <td style="overflow:hidden;">
  6. <div class="GOBodyMid" style="overflow: hidden; width: 625px; height: 334px;">
  7. <div class="GOPageOne">
  8. <table class="GOSection" cellspacing="0" cellpadding="0">
  9. <tbody>
  10. <tr>
  11. <tr class="GODataRow " style="height: 26px;" onmousemove="Grids[3].ARow=Grids[3].Rows["AR1"];Grids[3].ASec=0;">
  12. <td style="width:0px;height:0px"></td>
  13. <td class=" GOClassReadOnly highlight-tbl HoverClass GOText GOCell HideCol3displayName" colspan="2" style="">Automation Smoke test Template</td>
  14. <td class=" GOClassReadOnly highlight-tb HoverClass GOHtml GOCell HideCol3editPencil" colspan="2" style="">
  15. <div class="edit-Pencil"></div>
  16. </td>
  17. <td class=" GOClassReadOnly highlight-tb b_r HoverClass GOHtml GOCell HideCol3deleteIcon" colspan="2" style="">
  18. <td class=" GOClassReadOnly highlight-tb b_r HoverClass GODate GOCell HideCol3dateModified" colspan="2" style="">8/11/2014</td>
  19. <td class=" GOClassReadOnly highlight-tb b_r HoverClass GOText GOCell HideCol3owner" colspan="2" style="">Rachel Lv</td>
  20. <td class=" GOClassReadOnly highlight-tbr HoverClass GOText GOCell HideCol3permission" colspan="2" style="">Read Only</td>
  21. <td class=" HoverClass GOHtml GOCellEmpty GOEmpty HideCol3_ConstWidth"> </td>
  22. </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.

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

  1. Actions action =new Actions(driver);
  2. WebElement pencilIcon = page.getPencilIcon(templateName);
  3. action.moveToElement(pencilIcon).click();
  4.  
  5. WebElement menu = page.getMenu();
  6. action.moveToElement(menu).build().perform();
  7. Assert.assertTrue(menu.isDisplayed(),"Cannot find the menu");
  8.  
  9. WebElement open = page.getOpenMenu();
  10. 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. test20181020 B君的第二题

    题意 分析 考场70分 一看就是裸的kmp,直接打上去. #include<cstdlib> #include<cstdio> #include<cmath> #i ...

  2. Javascript-自己定义对象转换成JSon后怎样再转换回自己定义对象

    man是自己定义的对象,使用var tim = JSON.stringify(man); var newman=JSON.parse(tim)后newman的类型是"object" ...

  3. FastAdmin 环境变量 env 配置

    FastAdmin 环境变量 env 配置 目前 FastAdmin 支持环境变量 env 配置. 目前支持以下环境变量 app.debug app.trace database.type datab ...

  4. 转- 集群NAS技术架构

    集群NAS技术架构 标签: 集群存储负载均衡扩展服务器网络 原贴:http://blog.csdn.net/liuaigui/article/details/6422700 作者刘爱贵 1 什么是集群 ...

  5. C++11奇怪的语法

    1. istream_iterator 简而言之,istream_iterator像操作容器一样操作istream.例如下面代码,从std::cin构造std::istream_iteream< ...

  6. leetcode131

    深度优先遍历(DFS),先判断前一个部分是否是回文,如果是,则将其加进集合中,然后继续判断后面的回文串. 在回溯的时候,将之前加入集合的串删除,重新选择回文串.每到达一次叶子节点,得到一组结果. pu ...

  7. Tomcat 性能监控工具jvisualvm, JConsole

    配置: 重启Tomcat

  8. 智能指针--C++

    智能指针(一):STL auto_ptr实现原理 智能指针实际上是一个类(class),里面封装了一个指针.它的用处是啥呢? 指针与内存 说到指针自然涉及到内存.我们如果是在堆栈(stack)中分配了 ...

  9. eclipse怎么自定义工具栏

    1.点击透视图按钮---->右键---->Customize: 2.勾选或者去掉相关项目:

  10. 【333】Python3.6 格式化文本

    看如下例子进行体会: min_temperature = 0 max_temperature = 300 step = 20 # \t: A tab print('Fahrenheit\tCelsiu ...