webdriver知识点总结

基础知识: http://www.360doc.com/content/12/0525/16/1073512_213657192.shtml

源码下载:https://code.google.com/p/selenium/downloads/detail?name=selenium-java-2.35.0.zip


切换到当前窗口:

	public static void switchToCurrentWindow(WebDriver driver){
	    //get current window
	    String currentWindow = driver.getWindowHandle();  
	    //get all windows
	    Set<String> handles = driver.getWindowHandles();  
	    Iterator<String> it = handles.iterator();  
	    while(it.hasNext()){  
	        String handle = it.next();  
	        if(currentWindow.equals(handle)) continue;  
	        WebDriver window = driver.switchTo().window(handle);  
	        System.out.println("windows changed,the title and url is "+window.getTitle()+","+window.getCurrentUrl());  
	    }
	}

移动鼠标:

	public static void mouseToElement(WebDriver driver,String elementId){
	    Actions action = new Actions(driver);
	    action.moveToElement(driver.findElement(By.id(elementId))).build().perform();
	}


发布了37 篇原创文章 · 获赞 4 · 访问量 13万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章