[Selenium]How to click on a hidden link ,move to the drop down menu and click submenu
<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的更多相关文章
- Python+Selenium练习篇之5-利用partial link text定位元素
本文介绍如何通过partial link text来定位页面元素.看到这个,有点和前一篇文字link text有点类似.字面意思,确实和link text相类似,partial link text就是 ...
- Python 中 selenium 库
目录 selenium 基础语法 一. 环境配置 1. 安装环境 2. 配置参数 3. 常用参数搭配 4. 分浏览器启动 二. 基本语法 1. 元素定位 2. 控制浏览器操作 3. 操作元素的方法 3 ...
- 关于IOS浏览器:document,body的click事件触发规则
今天做了个手机页面,点击某个按钮->弹出菜单,再点击菜单以外的任意位置->关闭菜单,在其他浏览器里面没有问题,但是在IOS浏览器中并不会关闭. 网上解决这个bug的帖子很多,这篇帖子主要是 ...
- click事件触发也有失灵的时候?
今天做了个手机页面,点击某个按钮->弹出菜单,再点击菜单以外的任意位置->关闭菜单,在其他浏览器里面没有问题,但是在IOS浏览器中并不会关闭. 网上解决这个bug的帖子很多,这篇帖子主要是 ...
- Python爬虫利器四之PhantomJS的用法
前言 大家有没有发现之前我们写的爬虫都有一个共性,就是只能爬取单纯的html代码,如果页面是JS渲染的该怎么办呢?如果我们单纯去分析一个个后台的请求,手动去摸索JS渲染的到的一些结果,那简直没天理了. ...
- [转]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 ...
- 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 ...
- Performance js
转贴:https://10up.github.io/Engineering-Best-Practices/javascript/#performance Performance Writing per ...
- [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 ...
随机推荐
- 2016-2017-220155329 《Java程序设计》第8周学习总结
学号 2016-2017-220155329 <Java程序设计>第8周学习总结 教材学习内容总结 了解NIO NIO使用频道来衔接数据节点,在处理数据时,NIO可以让你设定缓冲区容量,在 ...
- vi/vim使用进阶: 在VIM中使用GDB调试 – 使用vimgdb
vi/vim使用进阶: 在VIM中使用GDB调试 – 使用vimgdb << 返回vim使用进阶: 目录 本节所用命令的帮助入口: :help vimgdb 在UNIX系统最初设计时,有一 ...
- windows下Java调用mysql的客户端备份和恢复
这种东西没啥好聊的,其实就是Java执行dos界面下的命令,不过有些要注意就是了,真实dos下面的命令和java调用的windows系统的接口其实还是有一点不同. /** * @param hostI ...
- DecimalFormat格式化数字
DecimalFormat格式化数字 DecimalFormat类也是Format的一个子类,主要作用是格式化数字.当然,在格式化数字时要比直接使用NumberFormat更加 方便,因为可以直接指定 ...
- hadoop之 YARN配置参数剖析—RM与NM相关参数
参数均需要在yarn-site.xml中配置: 1. ResourceManager相关配置参数 (1) yarn.resourcemanager.address 参数解释:ResourceManag ...
- macdown在mac OS 中的配置
macdown 用命令行打开.md文件 执行两条命令即可. sudo echo "open -a MacDown \$*" > /usr/local/bin/macdown ...
- mysql表复制create table like和create table as比较
CREATE TABLE A LIKE B 此种方式在将表B复制到A时候会将表B完整的字段结构和索引复制到表A中来. CREATE TABLE A AS SELECT x,x,x,xx FROM B ...
- Android Studio中 ADB WIFI插件进行无线调试实践
首先要确保电脑和手机在同一个局域网中.具体步骤如下 1.Android Studio中安装ADB WIFI插件.安装成功后重启Android Studio.(没有安装过插件的同仁,请自己搜索) 2.手 ...
- JZ2440 裸机驱动 第5章 GPIO接口
本章目标: 掌握嵌入式开发的步骤:编程.编译.烧写程序.运行 通过GPIO的操作了解软件如何控制硬件 5.1 GPIO硬件介绍 S3C2440A有130个多功能输入/输出口引脚 ...
- linux 线程的同步 三 (内存信号量的使用)
信号量.同步这些名词在进程间通信时就已经说过,在这里它们的意思是相同的,只不过是同步的对象不同而已.但是下面介绍的信号量的接口是用于线程的信号量,注意不要跟用于进程间通信的信号量混淆,关于用于进程间通 ...