[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 ...
随机推荐
- vs2005 sp1 补丁的安装问题
最近做windows mobile 6.0的手机软件开发,听说用vs2005 开发的话最少得装vs2005 sp1,于是去官网上下了VS80sp1-KB926604-X86-CHS.exe 补丁 .运 ...
- socket编程---UDP
头文件 #include <sys/types.h> #include <sys/socket.h> 函数原型 int sendto (int s, const void *b ...
- sublime 下面开发
sublime 下面开发 开发 ptyon 简单环境 1. 下载sublime 3 https://download.sublimetext.com/Sublime%20Text%20Build%20 ...
- 【monkeyrunner】monkeyrunner 实例
import time import os import re from com.android.monkeyrunner import MonkeyRunner as mr from com.and ...
- Makefile之自动变量篇
自动变量假设您编写一个编译‘.c’文件生成‘.o’文件的规则:您怎样编写命令‘CC’,使它能够操作正确的文件名?您当然不能将文件名直接写进命令中,因为每次使用隐含规则操作的文件名都不一样. 您应该使用 ...
- 智能家居入门DIY——【四、组合】
前面几篇介绍了一些传感器和代码,这篇介绍一下把它们组合起来.之所以单独列出这部分,原因在于组合更多功能的时候发现使用软串口库驱动ESP8266时由于内存过小导致发送失败甚至整个系统无法工作的情况.所以 ...
- redis与lua
内容大纲 redis里使用eval和evalsha redis管理Lua脚本 php里使用redis的lua脚本 在redis里使用lua脚本的好处 1.Lua脚本在Redis中是原子执行的,执行过 ...
- sqlite性能优化
1.数据库性能上 1.1 批量事务插入,提升数据插入的性能 由于sqlite默认每次插入都是事务,需要对文件进行读写,那么减少事务次数就能简书磁盘读写次数从而获得性能提升. 1.2 单条sql优于多条 ...
- Tensorflow笔记——神经网络图像识别(一)前反向传播,神经网络八股
第一讲:人工智能概述 第三讲:Tensorflow框架 前向传播: 反向传播: 总的代码: #coding:utf-8 #1.导入模块,生成模拟数据集 import t ...
- Bootstrap-Other:HTML编码规范
ylbtech-Bootstrap-Other:HTML编码规范 1.返回顶部 1. Bootstrap HTML编码规范 语法 用两个空格来代替制表符(tab) -- 这是唯一能保证在所有环境下获得 ...