[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元素即可.
随机推荐
- 531. Lonely Pixel I
Given a picture consisting of black and white pixels, find the number of black lonely pixels. The pi ...
- java使用jxl,自动导出数据excle,quartz自动发送邮件
=============JAVA后台代码===================== package com.qgc.service.autoSendMsg.AutoSendMsg import ja ...
- Working with multiple environments
ASP.NET Core引入了对多个环境(例如开发,暂存和生产环境)的支持. 可以用环境变量来指示应用程序正在运行的环境,从而让app来做相应的配置. Development, Staging, Pr ...
- sqlplus登陆scott用户,以及退出连接
进入sqlplus界面 即登陆成功,PLsql也一样 退出连接:
- getpixel 取色
HWND hwnd = ::FindWindow(NULL,"<天龙八部OL>"); CRect rect; CString strTmp; if (hwnd != N ...
- jQuery学习总结(一)——jQuery基础与学习资源
前一段时间录了一套关于jQuery的视频分享给大家,可以在下载区下载到,本来想配合文字一起的,后面发现视频+帮助文档也是非常好的学习方法. 一.jQuery简介与第一个jQuery程序 1.1.jQu ...
- 使用webstorm+webpack构建简单入门级“HelloWorld”的应用&&构建使用jquery来实现
使用webstorm+webpack构建简单入门级“HelloWorld”的应用&&构建使用jquery来实现 1.首先你自己把webstorm安装完成. 请参考这篇文章进行安装和破解 ...
- Codefoces 432 C. Prime Swaps(水)
思路:从前往后想将1调整好,在调整2....这样平均每次有五次机会调整,并且有相当一部分可能都用不到五次,能够一试.ac 代码: #include<iostream> #include&l ...
- POJ 2184 Cow Exhibition (01背包变形)(或者搜索)
Cow Exhibition Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10342 Accepted: 4048 D ...
- J2SE核心开发实战(二)——字符串与包装类
字符串与包装类 一.实验简单介绍 在本章.我们将学习一些用于处理字符串的API以及包装类的相关知识. 本章知识点 字符串API 包装类及其应用 二.认识字符串类 1. 什么是字符串类 Java字符串类 ...