码迷,mamicode.com
首页 > 其他好文 > 详细

[Selenium] The commonly used operation of element

时间:2015-04-23 15:33:49      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:

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

标签:

原文地址:http://www.cnblogs.com/feifeidxl/p/4450535.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!