selenium常用的方法

selenium常用的方法

ID:6380080

大小:132.05 KB

页数:10页

时间:2018-01-12

selenium常用的方法_第1页
selenium常用的方法_第2页
selenium常用的方法_第3页
selenium常用的方法_第4页
selenium常用的方法_第5页
资源描述:

《selenium常用的方法》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、packageavaya.browser.method;importjava.io.IOException;importjava.util.*;importorg.junit.Before;importorg.openqa.*;importcom.thoughtworks.selenium.Wait;importavaya.browser.interfac.Driver;//{attention:以Br.开头的方法,是因为Br是自己在本类还封装了一层,需要仔细看代码}publicclassBrext

2、endsBaseclass{privateStringlocator;publicstaticStringlog(Stringinfo){System.out.println(info);returninfo;}publicstaticvoidopenbrowser(Stringurl){//driver=newFirefoxDriver();//Navigationnavitation=driver.navigate();//navitation.to(url);driver.get(url);B

3、r.log("openbrowserandinputtestURL:"+url);}//oprationthewindowsmaxpublicstaticvoidmaxwindow(){driver.manage().window().maximize();Br.log("maxwindows");}//refreshthewindowspublicstaticvoidrefresh(){driver.navigate().refresh();Br.log("refreshthewindows");

4、}publicstaticvoidlogin(Stringurl,Stringuser,Stringpwd)throwsInterruptedException{driver.get(url);Br.clear(By.id("Br.logrm:username"));Br.sendkeys(By.id("Br.logrm:username"),user);Br.clear(By.id("Br.logrm:password"));Br.sendkeys(By.id("Br.logrm:password

5、"),pwd);Br.getWebText(By.id("Br.logrm:submitText"));driver.findElement(By.id("Br.logrm:submitText")).click();try{Thread.sleep(5000);}catch(InterruptedExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}Op.refresh();Br.log(",input:"+url);Br.l

6、og("登陆账号为:"+user+""+"登陆密码为:"+pwd);}//ifformparameterisnotnull,inputdataandusethismethod;publicstaticvoidclosebrowser(StringBrowserType){if(BrowserType!=null){if(BrowserType.equals("c")){try{Runtime.getRuntime().exec("taskkill/F/IMchrome.exe");}catch(IO

7、Exceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}}elseif(BrowserType.equals("i")){try{Runtime.getRuntime().exec("taskkill/F/IMiexplorer.exe");}catch(IOExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}}elseif(BrowserType.equa

8、ls("o")){try{Runtime.getRuntime().exec("taskkill/F/IMopera.exe");}catch(IOExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}}elseif(BrowserType.equals("s")){try{Runtime.getRuntime().exec("taskkill/F/IMsafari.exe");}catch(IO

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。