08 2013 档案

摘要:/*java里面实现多线程一般有两种方式 * 1,继承Thread类,实现run方法 * 2,实现Runnable接口,实现run方法 * start方法可以新建一个线程,创建多线程必须调用此方法 * run方法用于存放要多线程要运行的代码 * */public class ThreadDemo { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub TicketT t1=new TicketT()... 阅读全文
posted @ 2013-08-27 23:34 苦逼IT男 阅读(221) 评论(0) 推荐(0)
摘要:public static void main(String[] args) throws Exception { User user= (User) test(User.class); System.out.println(user.getMoney()); invokeTest(user,"getMoneyT"); } /**通过反射获取实例 * @param clazz类,如user.class * @return 类实例 * @throws Exception */ static Obj... 阅读全文
posted @ 2013-08-25 20:42 苦逼IT男 阅读(1483) 评论(0) 推荐(0)
摘要://山寨法 String setscroll = "document.documentElement.scrollTop=100"; JavascriptExecutor jse=(JavascriptExe... 阅读全文
posted @ 2013-08-25 13:40 苦逼IT男 阅读(3154) 评论(0) 推荐(0)
摘要:public static void main(String[] args) { //TestUtils.killProcess("javaw.exe"); TestUtils.killProcess("iexplore.exe"); WebDriver driver=ExplorerBase.IESetting(); driver.manage().window().maximize(); String baseUrl= "http://www.baidu.com/"; ... 阅读全文
posted @ 2013-08-25 12:20 苦逼IT男 阅读(645) 评论(0) 推荐(0)
摘要:getText(),获得标签内文本getAttribute("title")获得对应的html属性值 阅读全文
posted @ 2013-08-25 12:12 苦逼IT男 阅读(151) 评论(0) 推荐(0)
摘要:Connection con=null; PreparedStatement ps=null; ResultSet rs=null; try { //建立连接 con= JDBCUtils.getConnection(); //创建语句 String sql="insert into t_user values('test','123',null,null)"; ps = con.prepareStatement... 阅读全文
posted @ 2013-08-24 22:43 苦逼IT男 阅读(360) 评论(0) 推荐(0)
摘要:ITeye:http://shijincheng0223.iteye.com/blog/1481446 http://ztreeapi.iteye.com/blog/1750554http://smilejay.com/2012/09/selenium-webdriver-with-ie/http://uniquepig.iteye.com/blog/1703553http://wenku.baidu.com/view/a5d218cdb14e852458fb571c.html?pn=51 阅读全文
posted @ 2013-08-24 20:42 苦逼IT男 阅读(173) 评论(0) 推荐(0)
摘要:/**显示等待并返回元素 * @param driver * @param locator */ public static WebElement showWait(WebDriver driver, final String locator) { return new WebDriverWait(driver, 10).until(new ExpectedCondition() { public WebElement apply(WebDriver ... 阅读全文
posted @ 2013-08-24 20:30 苦逼IT男 阅读(233) 评论(0) 推荐(0)
摘要:@Test public void testRadio() { WebDriver driver = ExplorerBase.IESetting(); try { Thread.sleep(500); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } driver.manage().window().maxim... 阅读全文
posted @ 2013-08-24 20:02 苦逼IT男 阅读(2147) 评论(0) 推荐(0)
摘要:@Test public void test() { WebDriver driver=ExplorerBase.IESetting(); driver.get("http://uniquepig.iteye.com/signup"); driver.manage().window().maximize(); //在读学生 Select select = new Select(driver.findElement(By.id("user_gender"))); select.selectByVisible... 阅读全文
posted @ 2013-08-24 19:35 苦逼IT男 阅读(718) 评论(0) 推荐(0)
摘要:/**截图 * @param driver * @param name */ public static void takeScreenShot(WebDriver driver,String name){ File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); try { FileUtils.copyFile(scrFile, new File("c:\\"... 阅读全文
posted @ 2013-08-24 17:25 苦逼IT男 阅读(302) 评论(0) 推荐(0)
摘要:public class BaiduTest { private WebDriver driver; private String baseUrl; private StringBuffer verificationErrors = new StringBuffer(); @Before public void setUp() throws Exception { driver = ExplorerBase.IESetting(); baseUrl = "http://www.baidu.com/"; driver.manage().timeouts().impli... 阅读全文
posted @ 2013-08-24 17:04 苦逼IT男 阅读(1605) 评论(0) 推荐(0)
摘要:@Test public void testElementByID() { //通过JS获取页面元素 driver.get(url); driver.manage().window().maximize(); try { Thread.sleep(500); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); ... 阅读全文
posted @ 2013-08-24 17:00 苦逼IT男 阅读(400) 评论(0) 推荐(0)
摘要:static final WebDriver driver = ExplorerBase.IESetting(); // 实例化一个浏览器对象 @Test //@Ignore public void findBaiDuElements() { try { Thread.sleep(500); } catch (InterruptedException e1) { e1.printStackTrace(); } driver.manage().window().maxim... 阅读全文
posted @ 2013-08-24 16:58 苦逼IT男 阅读(405) 评论(0) 推荐(0)
摘要:/**模拟鼠标悬浮在某元素上 * @param driver * @param locator */ public static void moveToElement(WebDriver driver, By locator) { Actions ... 阅读全文
posted @ 2013-08-24 16:55 苦逼IT男 阅读(4243) 评论(0) 推荐(0)
摘要:/** * 判断元素是否存在 * * @param driver * @param by * @return */ public static boolean isElementPresent(WebDriver driver, By by) { try { driver.findElement(by); return true; } catch (NoSuchElementException e) { return false; ... 阅读全文
posted @ 2013-08-24 16:53 苦逼IT男 阅读(454) 评论(0) 推荐(0)
摘要:public static FirefoxDriver FFSetting() { System.setProperty("webdriver.firefox.bin", "D:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); return new FirefoxDriver(); } public static InternetExplorerDriver IESetting() { System.setProperty("webdriver... 阅读全文
posted @ 2013-08-24 16:49 苦逼IT男 阅读(1526) 评论(0) 推荐(0)
摘要:1 import java.io.File; 2 import java.io.FileInputStream; 3 import java.io.FileOutputStream; 4 import java.io.InputStream; 5 import java.io.OutputStream; 6 7 public class CopyFile { 8 9 /**10 * @param args11 */12 private static final String fileType=".avi";//文件后缀名13 public s... 阅读全文
posted @ 2013-08-07 20:48 苦逼IT男 阅读(399) 评论(0) 推荐(0)