最近想总结一下学习selenium webdriver的情况,于是就想用selenium webdriver里面的方法来实现selenium RC中操作的一些方法。目前封装了一个ActionDriverHelper类,来实现RC中Selenium.java和DefaultSelenium.java中的方法。有一些方法还没有实现,写的方法大多没有经过测试,仅供参考。代码如下:
- packagecore;
- importjava.io.File;
- importjava.io.IOException;
- importjava.util.HashSet;
- importjava.util.List;
- importjava.util.Set;
- importjava.util.concurrent.TimeUnit;
- importorg.apache.commons.io.FileUtils;
- importorg.openqa.selenium.By;
- importorg.openqa.selenium.Cookie;
- importorg.openqa.selenium.Dimension;
- importorg.openqa.selenium.JavascriptExecutor;
- importorg.openqa.selenium.Keys;
- importorg.openqa.selenium.NoSuchElementException;
- importorg.openqa.selenium.OutputType;
- importorg.openqa.selenium.Point;
- importorg.openqa.selenium.TakesScreenshot;
- importorg.openqa.selenium.WebDriver;
- importorg.openqa.selenium.WebElement;
- importorg.openqa.selenium.WebDriver.Timeouts;
- importorg.openqa.selenium.interactions.Actions;
- importorg.openqa.selenium.support.ui.Select;
- publicclassActionDriverHelper{
- protectedWebDriverdriver;
- publicActionDriverHelper(WebDriverdriver){
- this.driver=driver;
- }
- publicvoidclick(Byby){
- driver.findElement(by).click();
- }
- publicvoiddoubleClick(Byby){
- newActions(driver).doubleClick(driver.findElement(by)).perform();
- }
- publicvoidcontextMenu(Byby){
- newActions(driver).contextClick(driver.findElement(by)).perform();
- }
- publicvoidclickAt(Byby,StringcoordString){
- intindex=coordString.trim().indexOf(',');
- intxOffset=Integer.parseInt(coordString.trim().substring(0,index));
- intyOffset=Integer.parseInt(coordString.trim().substring(index+1));
- newActions(driver).moveToElement(driver.findElement(by),xOffset,yOffset).click().perform();
- }
- publicvoiddoubleClickAt(Byby,StringcoordString){
- intindex=coordString.trim().indexOf(',');
- intxOffset=Integer.parseInt(coordString.trim().substring(0,index));
- intyOffset=Integer.parseInt(coordString.trim().substring(index+1));
- newActions(driver).moveToElement(driver.findElement(by),xOffset,yOffset)
- .doubleClick(driver.findElement(by))
- .perform();
- }
- publicvoidcontextMenuAt(Byby,StringcoordString){
- intindex=coordString.trim().indexOf(',');
- intxOffset=Integer.parseInt(coordString.trim().substring(0,index));
- intyOffset=Integer.parseInt(coordString.trim().substring(index+1));
- newActions(driver).moveToElement(driver.findElement(by),xOffset,yOffset)
- .contextClick(driver.findElement(by))
- .perform();
- }
- publicvoidfireEvent(Byby,StringeventName){
- System.out.println("webdriver不建议使用这样的方法,所以没有实现。");
- }
- publicvoidfocus(Byby){
- System.out.println("webdriver不建议使用这样的方法,所以没有实现。");
- }
- publicvoidkeyPress(Byby,KeystheKey){
- newActions(driver).keyDown(driver.findElement(by),theKey).release().perform();
- }
- publicvoidshiftKeyDown(){
- newActions(driver).keyDown(Keys.SHIFT).perform();
- }
- publicvoidshiftKeyUp(){
- newActions(driver).keyUp(Keys.SHIFT).perform();
- }
- publicvoidmetaKeyDown(){
- newActions(driver).keyDown(Keys.META).perform();
- }
- publicvoidmetaKeyUp(){
- newActions(driver).keyUp(Keys.META).perform();
- }
- publicvoidaltKeyDown(){
- newActions(driver).keyDown(Keys.ALT).perform();
- }
- publicvoidaltKeyUp(){
- newActions(driver).keyUp(Keys.ALT).perform();
- }
- publicvoidcontrolKeyDown(){
- newActions(driver).keyDown(Keys.CONTROL).perform();
- }
- publicvoidcontrolKeyUp(){
- newActions(driver).keyUp(Keys.CONTROL).perform();
- }
- publicvoidKeyDown(KeystheKey){
- newActions(driver).keyDown(theKey).perform();
- }
- publicvoidKeyDown(Byby,KeystheKey){
- newActions(driver).keyDown(driver.findElement(by),theKey).perform();
- }
- publicvoidKeyUp(KeystheKey){
- newActions(driver).keyUp(theKey).perform();
- }
- publicvoidKeyUp(Byby,KeystheKey){
- newActions(driver).keyUp(driver.findElement(by),theKey).perform();
- }
- publicvoidmouseOver(Byby){
- newActions(driver).moveToElement(driver.findElement(by)).perform();
- }
- publicvoidmouseOut(Byby){
- System.out.println("没有实现!");
- //newActions(driver).moveToElement((driver.findElement(by)),-10,-10).perform();
- }
- publicvoidmouseDown(Byby){
- newActions(driver).clickAndHold(driver.findElement(by)).perform();
- }
- publicvoidmouseDownRight(Byby){
- System.out.println("没有实现!");
- }
- publicvoidmouseDownAt(Byby,StringcoordString){
- System.out.println("没有实现!");
- }
- publicvoidmouseDownRightAt(Byby,StringcoordString){
- System.out.println("没有实现!");
- }
- publicvoidmouseUp(Byby){
- System.out.println("没有实现!");
- }
- publicvoidmouseUpRight(Byby){
- System.out.println("没有实现!");
- }
- publicvoidmouseUpAt(Byby,StringcoordString){
- System.out.println("没有实现!");
- }
- publicvoidmouseUpRightAt(Byby,StringcoordString){
- System.out.println("没有实现!");
- }
- publicvoidmouseMove(Byby){
- newActions(driver).moveToElement(driver.findElement(by)).perform();
- }
- publicvoidmouseMoveAt(Byby,StringcoordString){
- intindex=coordString.trim().indexOf(',');
- intxOffset=Integer.parseInt(coordString.trim().substring(0,index));
- intyOffset=Integer.parseInt(coordString.trim().substring(index+1));
- newActions(driver).moveToElement(driver.findElement(by),xOffset,yOffset).perform();
- }
- publicvoidtype(Byby,Stringtestdata){
- driver.findElement(by).clear();
- driver.findElement(by).sendKeys(testdata);
- }
- publicvoidtypeKeys(Byby,Keyskey){
- driver.findElement(by).sendKeys(key);
- }
- publicvoidsetSpeed(Stringvalue){
- System.out.println("ThemethodstosettheexecutionspeedinWebDriverweredeprecated");
- }
- publicStringgetSpeed(){
- System.out.println("ThemethodstosettheexecutionspeedinWebDriverweredeprecated");
- returnnull;
- }
- publicvoidcheck(Byby){
- if(!isChecked(by))
- click(by);
- }
- publicvoiduncheck(Byby){
- if(isChecked(by))
- click(by);
- }
- publicvoidselect(Byby,StringoptionValue){
- newSelect(driver.findElement(by)).selectByValue(optionValue);
- }
- publicvoidselect(Byby,intindex){
- newSelect(driver.findElement(by)).selectByIndex(index);
- }
- publicvoidaddSelection(Byby,StringoptionValue){
- select(by,optionValue);
- }
- publicvoidaddSelection(Byby,intindex){
- select(by,index);
- }
- publicvoidremoveSelection(Byby,Stringvalue){
- newSelect(driver.findElement(by)).deselectByValue(value);
- }
- publicvoidremoveSelection(Byby,intindex){
- newSelect(driver.findElement(by)).deselectByIndex(index);
- }
- publicvoidremoveAllSelections(Byby){
- newSelect(driver.findElement(by)).deselectAll();
- }
- publicvoidsubmit(Byby){
- driver.findElement(by).submit();
- }
- publicvoidopen(Stringurl){
- driver.get(url);
- }
- publicvoidopenWindow(Stringurl,Stringhandler){
- System.out.println("方法没有实现!");
- }
- publicvoidselectWindow(Stringhandler){
- driver.switchTo().window(handler);
- }
- publicStringgetCurrentHandler(){
- StringcurrentHandler=driver.getWindowHandle();
- returncurrentHandler;
- }
- publicStringgetSecondWindowHandler(){
- Set<String>handlers=driver.getWindowHandles();
- StringreHandler=getCurrentHandler();
- for(Stringhandler:handlers){
- if(reHandler.equals(handler))continue;
- reHandler=handler;
- }
- returnreHandler;
- }
- publicvoidselectPopUp(Stringhandler){
- driver.switchTo().window(handler);
- }
- publicvoidselectPopUp(){
- driver.switchTo().window(getSecondWindowHandler());
- }
- publicvoiddeselectPopUp(){
- driver.switchTo().window(getCurrentHandler());
- }
- publicvoidselectFrame(intindex){
- driver.switchTo().frame(index);
- }
- publicvoidselectFrame(Stringstr){
- driver.switchTo().frame(str);
- }
- publicvoidselectFrame(Byby){
- driver.switchTo().frame(driver.findElement(by));
- }
- publicvoidwaitForPopUp(StringwindowID,Stringtimeout){
- System.out.println("没有实现");
- }
- publicvoidaccept(){
- driver.switchTo().alert().accept();
- }
- publicvoiddismiss(){
- driver.switchTo().alert().dismiss();
- }
- publicvoidchooseCancelOnNextConfirmation(){
- driver.switchTo().alert().dismiss();
- }
- publicvoidchooseOkOnNextConfirmation(){
- driver.switchTo().alert().accept();
- }
- publicvoidanswerOnNextPrompt(Stringanswer){
- driver.switchTo().alert().sendKeys(answer);
- }
- publicvoidgoBack(){
- driver.navigate().back();
- }
- publicvoidrefresh(){
- driver.navigate().refresh();
- }
- publicvoidforward(){
- driver.navigate().forward();
- }
- publicvoidto(StringurlStr){
- driver.navigate().to(urlStr);
- }
- publicvoidclose(){
- driver.close();
- }
- publicbooleanisAlertPresent(){
- Booleanb=true;
- try{
- driver.switchTo().alert();
- }catch(Exceptione){
- b=false;
- }
- returnb;
- }
- publicbooleanisPromptPresent(){
- returnisAlertPresent();
- }
- publicbooleanisConfirmationPresent(){
- returnisAlertPresent();
- }
- publicStringgetAlert(){
- returndriver.switchTo().alert().getText();
- }
- publicStringgetConfirmation(){
- returngetAlert();
- }
- publicStringgetPrompt(){
- returngetAlert();
- }
- publicStringgetLocation(){
- returndriver.getCurrentUrl();
- }
- publicStringgetTitle(){
- returndriver.getTitle();
- }
- publicStringgetBodyText(){
- Stringstr="";
- List<WebElement>elements=driver.findElements(By.xpath("//body//*[contains(text(),*)]"));
- for(WebElemente:elements){
- str+=e.getText()+"";
- }
- returnstr;
- }
- publicStringgetValue(Byby){
- returndriver.findElement(by).getAttribute("value");
- }
- publicStringgetText(Byby){
- returndriver.findElement(by).getText();
- }
- publicvoidhighlight(Byby){
- WebElementelement=driver.findElement(by);
- ((JavascriptExecutor)driver).executeScript("arguments[0].style.border=\"5pxsolidyellow\"",element);
- }
- publicObjectgetEval(Stringscript,Object...args){
- return((JavascriptExecutor)driver).executeScript(script,args);
- }
- publicObjectgetAsyncEval(Stringscript,Object...args){
- return((JavascriptExecutor)driver).executeAsyncScript(script,args);
- }
- publicbooleanisChecked(Byby){
- returndriver.findElement(by).isSelected();
- }
- publicStringgetTable(Byby,StringtableCellAddress){
- WebElementtable=driver.findElement(by);
- intindex=tableCellAddress.trim().indexOf('.');
- introw=Integer.parseInt(tableCellAddress.substring(0,index));
- intcell=Integer.parseInt(tableCellAddress.substring(index+1));
- List<WebElement>rows=table.findElements(By.tagName("tr"));
- WebElementtheRow=rows.get(row);
- Stringtext=getCell(theRow,cell);
- returntext;
- }
- privateStringgetCell(WebElementRow,intcell){
- List<WebElement>cells;
- Stringtext=null;
- if(Row.findElements(By.tagName("th")).size()>0){
- cells=Row.findElements(By.tagName("th"));
- text=cells.get(cell).getText();
- }
- if(Row.findElements(By.tagName("td")).size()>0){
- cells=Row.findElements(By.tagName("td"));
- text=cells.get(cell).getText();
- }
- returntext;
- }
- publicString[]getSelectedLabels(Byby){
- Set<String>set=newHashSet<String>();
- List<WebElement>selectedOptions=newSelect(driver.findElement(by))
- .getAllSelectedOptions();
- for(WebElemente:selectedOptions){
- set.add(e.getText());
- }
- returnset.toArray(newString[set.size()]);
- }
- publicStringgetSelectedLabel(Byby){
- returngetSelectedOption(by).getText();
- }
- publicString[]getSelectedValues(Byby){
- Set<String>set=newHashSet<String>();
- List<WebElement>selectedOptions=newSelect(driver.findElement(by))
- .getAllSelectedOptions();
- for(WebElemente:selectedOptions){
- set.add(e.getAttribute("value"));
- }
- returnset.toArray(newString[set.size()]);
- }
- publicStringgetSelectedValue(Byby){
- returngetSelectedOption(by).getAttribute("value");
- }
- publicString[]getSelectedIndexes(Byby){
- Set<String>set=newHashSet<String>();
- List<WebElement>selectedOptions=newSelect(driver.findElement(by))
- .getAllSelectedOptions();
- List<WebElement>options=newSelect(driver.findElement(by)).getOptions();
- for(WebElemente:selectedOptions){
- set.add(String.valueOf(options.indexOf(e)));
- }
- returnset.toArray(newString[set.size()]);
- }
- publicStringgetSelectedIndex(Byby){
- List<WebElement>options=newSelect(driver.findElement(by)).getOptions();
- returnString.valueOf(options.indexOf(getSelectedOption(by)));
- }
- publicString[]getSelectedIds(Byby){
- Set<String>ids=newHashSet<String>();
- List<WebElement>options=newSelect(driver.findElement(by)).getOptions();
- for(WebElementoption:options){
- if(option.isSelected()){
- ids.add(option.getAttribute("id"));
- }
- }
- returnids.toArray(newString[ids.size()]);
- }
- publicStringgetSelectedId(Byby){
- returngetSelectedOption(by).getAttribute("id");
- }
- privateWebElementgetSelectedOption(Byby){
- WebElementselectedOption=null;
- List<WebElement>options=newSelect(driver.findElement(by)).getOptions();
- for(WebElementoption:options){
- if(option.isSelected()){
- selectedOption=option;
- }
- }
- returnselectedOption;
- }
- publicbooleanisSomethingSelected(Byby){
- booleanb=false;
- List<WebElement>options=newSelect(driver.findElement(by)).getOptions();
- for(WebElementoption:options){
- if(option.isSelected()){
- b=true;
- break;
- }
- }
- returnb;
- }
- publicString[]getSelectOptions(Byby){
- Set<String>set=newHashSet<String>();
- List<WebElement>options=newSelect(driver.findElement(by)).getOptions();
- for(WebElemente:options){
- set.add(e.getText());
- }
- returnset.toArray(newString[set.size()]);
- }
- publicStringgetAttribute(Byby,StringattributeLocator){
- returndriver.findElement(by).getAttribute(attributeLocator);
- }
- publicbooleanisTextPresent(Stringpattern){
- StringXpath="//*[contains(text(),\'"+pattern+"\')]";
- try{
- driver.findElement(By.xpath(Xpath));
- returntrue;
- }catch(NoSuchElementExceptione){
- returnfalse;
- }
- }
- publicbooleanisElementPresent(Byby){
- returndriver.findElements(by).size()>0;
- }
- publicbooleanisVisible(Byby){
- returndriver.findElement(by).isDisplayed();
- }
- publicbooleanisEditable(Byby){
- returndriver.findElement(by).isEnabled();
- }
- publicList<WebElement>getAllButtons(){
- returndriver.findElements(By.xpath("//input[@type='button']"));
- }
- publicList<WebElement>getAllLinks(){
- returndriver.findElements(By.tagName("a"));
- }
- publicList<WebElement>getAllFields(){
- returndriver.findElements(By.xpath("//input[@type='text']"));
- }
- publicString[]getAttributeFromAllWindows(StringattributeName){
- System.out.println("不知道怎么实现");
- returnnull;
- }
- publicvoiddragdrop(Byby,StringmovementsString){
- dragAndDrop(by,movementsString);
- }
- publicvoiddragAndDrop(Byby,StringmovementsString){
- intindex=movementsString.trim().indexOf('.');
- intxOffset=Integer.parseInt(movementsString.substring(0,index));
- intyOffset=Integer.parseInt(movementsString.substring(index+1));
- newActions(driver).clickAndHold(driver.findElement(by)).moveByOffset(xOffset,yOffset).perform();
- }
- publicvoidsetMouseSpeed(Stringpixels){
- System.out.println("不支持");
- }
- publicNumbergetMouseSpeed(){
- System.out.println("不支持");
- returnnull;
- }
- publicvoiddragAndDropToObject(Bysource,Bytarget){
- newActions(driver).dragAndDrop(driver.findElement(source),driver.findElement(target)).perform();
- }
- publicvoidwindowFocus(){
- driver.switchTo().defaultContent();
- }
- publicvoidwindowMaximize(){
- driver.manage().window().setPosition(newPoint(0,0));
- java.awt.DimensionscreenSize=java.awt.Toolkit.getDefaultToolkit().getScreenSize();
- Dimensiondim=newDimension((int)screenSize.getWidth(),(int)screenSize.getHeight());
- driver.manage().window().setSize(dim);
- }
- publicString[]getAllWindowIds(){
- System.out.println("不能实现!");
- returnnull;
- }
- publicString[]getAllWindowNames(){
- System.out.println("不能实现!");
- returnnull;
- }
- publicString[]getAllWindowTitles(){
- Set<String>handles=driver.getWindowHandles();
- Set<String>titles=newHashSet<String>();
- for(Stringhandle:handles){
- titles.add(driver.switchTo().window(handle).getTitle());
- }
- returntitles.toArray(newString[titles.size()]);
- }
- publicStringgetHtmlSource(){
- returndriver.getPageSource();
- }
- publicvoidsetCursorPosition(Stringlocator,Stringposition){
- System.out.println("没能实现!");
- }
- publicNumbergetElementIndex(Stringlocator){
- System.out.println("没能实现!");
- returnnull;
- }
- publicObjectisOrdered(Byby1,Byby2){
- System.out.println("没能实现!");
- returnnull;
- }
- publicNumbergetElementPositionLeft(Byby){
- returndriver.findElement(by).getLocation().getX();
- }
- publicNumbergetElementPositionTop(Byby){
- returndriver.findElement(by).getLocation().getY();
- }
- publicNumbergetElementWidth(Byby){
- returndriver.findElement(by).getSize().getWidth();
- }
- publicNumbergetElementHeight(Byby){
- returndriver.findElement(by).getSize().getHeight();
- }
- publicNumbergetCursorPosition(Stringlocator){
- System.out.println("没能实现!");
- returnnull;
- }
- publicStringgetExpression(Stringexpression){
- System.out.println("没能实现!");
- returnnull;
- }
- publicNumbergetXpathCount(Byxpath){
- returndriver.findElements(xpath).size();
- }
- publicvoidassignId(Byby,Stringidentifier){
- System.out.println("不想实现!");
- }
- /*publicvoidallowNativeXpath(Stringallow){
- commandProcessor.doCommand("allowNativeXpath",newString[]{allow,});
- }*/
- /*publicvoidignoreAttributesWithoutValue(Stringignore){
- commandProcessor.doCommand("ignoreAttributesWithoutValue",newString[]{ignore,});
- }*/
- publicvoidwaitForCondition(Stringscript,Stringtimeout,Object...args){
- Booleanb=false;
- inttime=0;
- while(time<=Integer.parseInt(timeout)){
- b=(Boolean)((JavascriptExecutor)driver).executeScript(script,args);
- if(b==true)break;
- try{
- Thread.sleep(1000);
- }catch(InterruptedExceptione){
- //TODOAuto-generatedcatchblock
- e.printStackTrace();
- }
- time+=1000;
- }
- }
- publicvoidsetTimeout(Stringtimeout){
- driver.manage().timeouts().implicitlyWait(Integer.parseInt(timeout),TimeUnit.SECONDS);
- }
- publicvoidwaitForPageToLoad(Stringtimeout){
- driver.manage().timeouts().pageLoadTimeout(Integer.parseInt(timeout),TimeUnit.SECONDS);
- }
- publicvoidwaitForFrameToLoad(StringframeAddress,Stringtimeout){
- /*driver.switchTo().frame(frameAddress)
- .manage()
- .timeouts()
- .pageLoadTimeout(Integer.parseInt(timeout),TimeUnit.SECONDS);*/
- }
- publicStringgetCookie(){
- Stringcookies="";
- Set<Cookie>cookiesSet=driver.manage().getCookies();
- for(Cookiec:cookiesSet){
- cookies+=c.getName()+"="+c.getValue()+";";
- }
- returncookies;
- }
- publicStringgetCookieByName(Stringname){
- returndriver.manage().getCookieNamed(name).getValue();
- }
- publicbooleanisCookiePresent(Stringname){
- booleanb=false;
- if(driver.manage().getCookieNamed(name)!=null||driver.manage().getCookieNamed(name).equals(null))
- b=true;
- returnb;
- }
- publicvoidcreateCookie(Cookiec){
- driver.manage().addCookie(c);
- }
- publicvoiddeleteCookie(Cookiec){
- driver.manage().deleteCookie(c);
- }
- publicvoiddeleteAllVisibleCookies(){
- driver.manage().getCookieNamed("fs").isSecure();
- }
- /*publicvoidsetBrowserLogLevel(StringlogLevel){
- }*/
- /*publicvoidrunScript(Stringscript){
- commandProcessor.doCommand("runScript",newString[]{script,});
- }*/
- /*publicvoidaddLocationStrategy(StringstrategyName,StringfunctionDefinition){
- commandProcessor.doCommand("addLocationStrategy",newString[]{strategyName,functionDefinition,});
- }*/
- publicvoidcaptureEntirePageScreenshot(Stringfilename){
- FilescreenShotFile=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
- try{
- FileUtils.copyFile(screenShotFile,newFile(filename));
- }catch(IOExceptione){
- //TODOAuto-generatedcatchblock
- e.printStackTrace();
- }
- }
- /*publicvoidrollup(StringrollupName,Stringkwargs){
- commandProcessor.doCommand("rollup",newString[]{rollupName,kwargs,});
- }
- publicvoidaddScript(StringscriptContent,StringscriptTagId){
- commandProcessor.doCommand("addScript",newString[]{scriptContent,scriptTagId,});
- }
- publicvoidremoveScript(StringscriptTagId){
- commandProcessor.doCommand("removeScript",newString[]{scriptTagId,});
- }
- publicvoiduseXpathLibrary(StringlibraryName){
- commandProcessor.doCommand("useXpathLibrary",newString[]{libraryName,});
- }
- publicvoidsetContext(Stringcontext){
- commandProcessor.doCommand("setContext",newString[]{context,});
- }*/
- /*publicvoidattachFile(StringfieldLocator,StringfileLocator){
- commandProcessor.doCommand("attachFile",newString[]{fieldLocator,fileLocator,});
- }*/
- /*publicvoidcaptureScreenshot(Stringfilename){
- commandProcessor.doCommand("captureScreenshot",newString[]{filename,});
- }*/
- publicStringcaptureScreenshotToString(){
- Stringscreen=((TakesScreenshot)driver).getScreenshotAs(OutputType.BASE64);
- returnscreen;
- }
- /*publicStringcaptureNetworkTraffic(Stringtype){
- returncommandProcessor.getString("captureNetworkTraffic",newString[]{type});
- }
- */
- /*publicvoidaddCustomRequestHeader(Stringkey,Stringvalue){
- commandProcessor.getString("addCustomRequestHeader",newString[]{key,value});
- }*/
- /*publicStringcaptureEntirePageScreenshotToString(Stringkwargs){
- returncommandProcessor.getString("captureEntirePageScreenshotToString",newString[]{kwargs,});
- }*/
- publicvoidshutDown(){
- driver.quit();
- }
- /*publicStringretrieveLastRemoteControlLogs(){
- returncommandProcessor.getString("retrieveLastRemoteControlLogs",newString[]{});
- }*/
- publicvoidkeyDownNative(Keyskeycode){
- newActions(driver).keyDown(keycode).perform();
- }
- publicvoidkeyUpNative(Keyskeycode){
- newActions(driver).keyUp(keycode).perform();
- }
- publicvoidkeyPressNative(Stringkeycode){
- newActions(driver).click().perform();
- }
- publicvoidwaitForElementPresent(Byby){
- for(inti=0;i<60;i++){
- if(isElementPresent(by)){
- break;
- }else{
- try{
- driver.wait(1000);
- }catch(InterruptedExceptione){
- e.printStackTrace();
- }
- }
- }
- }
- publicvoidclickAndWaitForElementPresent(Byby,BywaitElement){
- click(by);
- waitForElementPresent(waitElement);
- }
- publicBooleanVeryTitle(Stringexception,Stringactual){
- if(exception.equals(actual))returntrue;
- elsereturnfalse;
- }
- }