您的位置:首页 > 运维架构

[Selenium] The commonly used operation of element

2015-04-23 14:50 399 查看
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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐