[Selenium] The commonly used operation of element
btnLogin.click(); //Click element
SeleniumUtil.jsClick(driver, saveButtonEl); //If click() is not applicable ,try this one
txtEmail.clear(); //Clear text box before send keys to it
txtEmail.sendKeys(“jenny.zhang@morningstar.com”); //Send keys to text box
emailEl.getAttribute("title"); //Get attribute value of element
hoverEl.getText(); //Get text of element
SeleniumUtil.scrollIntoView(driver, el); //Scroll the element into view if the function needs scroll bar or mouse wheel when manual testing
//Click a hidden element
action.moveToElement(pencilIcon).click();
//Before click an element under a hidden element
locx=(theRow.getSize().width)/100;
locy=(theRow.getSize().height)/2;
action.moveToElement(theRow, locx, locy);
//Get text of hidden element
String dataPointName = (String) ((JavascriptExecutor) driver).executeScript(
"return jQuery(arguments[0]).text();", element);
//Ctrl+click
Actions a = new Actions(driver);
a.keyDown(Keys.CONTROL).perform();
for(int i = 0;i<quantity;i++){
WebElement securityEl = securitiesList.get(i);
SeleniumUtil.scrollIntoView(driver, securityEl);
securityEl.click();
}
a.keyUp(Keys.CONTROL).perform();
//Drag and drop
Point targetWidgetPos = targetWidgetEl.getLocation();
Point widgetPos = widgetEl.getLocation();
int offsetX = targetWidgetPos.getX() - widgetPos.getX();
int offsetY = targetWidgetPos.getY() - widgetPos.getY();
SeleniumUtil.dragAndDropOffset(driver, titleEl, offsetX, offsetY);
[Selenium] The commonly used operation of element的更多相关文章
- selenium之坑(StaleElementReferenceException: Message: Element not found in the cache...)
有时候循环点击一列链接,只能点到第一个,第二个就失败了 原因是第二个已经是新页面,当然找不到之前页面的元素.就算是后退回来的,页面也是不一样的 页面长的一样不一定是同一张页面,就像两个人长的一样不一定 ...
- selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
抓取网页代码后,由于是在同一个li标签下,所以使用一次性抓取,所有的a标签,然后循环做不同的操作,但是抛出找不到元素异常. def office_page(_chrome: Chrome): sn = ...
- Selenium Xpath Tutorials - Identifying xpath for element with examples to use in selenium
Xpath in selenium is close to must required. XPath is element locator and you need to provide xpath ...
- selenium使用过程中遇到的“element not visiable”错误
PS:本博客selenium分类不会记载selenium打开浏览器,定位元素,操作页面元素,切换到iframe,处理alter.confirm和prompt对话框这些在网上随处可见的信息:本博客此分类 ...
- selenium在chrome上运行报 Element is not clickable at point (1096, 26)
Firefox上正常运行的脚本在chrome上提示Element is not clickable at point (1096, 26).分析原因,首先肯定不是因为页面元素不存在而无法点击.也不是要 ...
- selenium之 坑(StaleElementReferenceException: Message: Element not found in the cache...)
今天给大家分享一个selenium中经常会有人遇到的坑: selenium.common.exceptions.StaleElementReferenceException: Message: Ele ...
- selenium webdriver使用过程中出现Element is not currently visible and so may not be interacted with的处理方法
参考文章: http://blog.csdn.net/passionboyxie/article/details/28661107 http://www.spasvo.com/ceshi/open/k ...
- selenium中,8种 find element 方法
-*- coding;utf-8 -*- from selenium import webdriver dr = webdriver.Chrome() dr.get("https://www ...
- Selenium 错误处理之:stale element reference: element is not attached to the page document
出现该错误的原因是页面在获取到DOM元素之后到引用元素之间页面进行了刷新,所以需要再次获取该DOM元素即可.
随机推荐
- [bzoj3709][PA2014]Bohater_贪心
bzoj-3709 PA-2014 Bohater 题目大意:在一款电脑游戏中,你需要打败n只怪物(从1到n编号).为了打败第i只怪物,你需要消耗d[i]点生命值,但怪物死后会掉落血药,使你恢复a[i ...
- 安装Django时解决的问题-mysql及访问(附pycharm激活)
1.做些软链接和virtualenv的基本使用: ln -s /data/linkdood/im/vrv/python36/bin/python3.6 /usr/bin/python3 ln -s / ...
- Java面向对象练习题
1.猜数字游戏: 一个类A有两个成员变量v.num,v有一个初值100. 定义一个方法guess,对A类的成员变量v,用num进行猜. 如果大了则提示大了,小了则提示小了.等于则提示猜测成功. 在ma ...
- linux crontab 定时器
crontab -e 编辑定时器 crontab -l 显示当前定时器 crontab -r 删除当前定时器 格式 * * * * * command 第一列表示分钟1-59 第二列表示小时1-23 ...
- 使用MVP模式重构代码
之前写了两篇关于MVP模式的文章,主要讲得都是一些概念,这里谈谈自己在Android项目中使用MVP模式的真实感受,并以实例的形式一起尝试来使用MVP模式去重构我们现有的代码. 有兴趣的童鞋可以先去阅 ...
- paramiko使用exec_command执行rm -rf删除目录的坑
paramiko删除目录后的上传操作请参考步骤1.2.3的说明 try: ssh = SSHClient(ip,user) sftpClient = ssh.getSftpClient() outpu ...
- github/gitlab ssh-keys全局唯一
我们知道,通过在gitlab.github上设置ssh-key,可以直接拉取代码:git clone …… 公司为了代码安全,会对代码访问权限进行控制,不同人有不同代码的访问权限. 有时候,为了临时获 ...
- uwsgi 热启动
uwsgi文件每次启动都要kill进程,这样非常麻烦,理想的情况是须要改动文件就自己主动生效,经查阅资料.发现uwsgi是自带该功能的,该功能的配置节例如以下 <uwsgi> <py ...
- C#如何实现挂机锁
首先在主窗体中设置一个子窗体的实例,然后当点击挂机之后,隐藏当前窗体,同时显示子窗体. 把子窗体的背景窗体设置如下属性(主要是背景随便改成一个图片,然后FormBorderStyle改成None, ...
- memchached你知道和不知道的事