Selenium Webdriver java 積累一

Selenium Webdriver 學習css

http://jarvi.iteye.com/category/203994html

https://github.com/easonhan007/webdriver_guidejava

Selenium WebDriver經驗雜記
http://blog.csdn.net/ant_yan/article/details/8185899
http://blog.csdn.net/aerchi/article/category/936247git

1. Selenium Webdriver java 瀏覽器中前進,後退,刷新操做。github

System.setProperty("webdriver.firefox.bin","D:/Mozilla Firefox/firefox.exe");
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("http://www.google.com.hk");
driver.navigate().forward(); // 前進
driver.navigate().back(); // 後退
driver.navigate().refresh(); // 刷新

2. TestNG實例:web

http://blog.csdn.net/yuxinlong2006/article/details/6765522windows

http://magustest.com/blog/automationtesting/webdriver-testng/瀏覽器

WebDriver+TestNG+ANT 實現多瀏覽器兼容性測試安全

http://www.51testing.com/?uid-375957-action-viewspace-itemid-817942session

3. Webdriver 針對iframe中的元素定位

Selenium2在使用get()方法打開一個網頁的時候,是不會繼續加載裏面的iframe中的內容的(這一點與Selenium有所區別)。那麼,咱們就須要人爲的要求Selenium2對iframe中的內容進行加載。
例子一:
driver.switchTo().frame(driver.findElement(By.xpath("//iframe[@class='g-editor-iframe']"))); 
例子二:
driver.switchTo().frame(driver.findElement(By.id("baiduSpFrame")));

切換主頁

用getWindowHandle()方法能夠快速的進行切換回主頁: String strMainHandler = driver.getWindowHandle(); driver.switchTo().window(strMainHandler);關於iframe中 元素定位和xpath, cssSelector定位可參考: http://blog.csdn.net/dancedan/article/details/7406942

4. Webdriver中操做下拉列表

對下拉框進行操做時首先要定位到這個下拉框,new 一個Selcet對象,而後對它進行操做。

5. Webdriver 利用Actions類模擬鼠標和鍵盤的操做

6. webdriver 中 層級定位

參見:http://jarvi.iteye.com/blog/1448025

7. webdriver 執行js腳本

http://jarvi.iteye.com/blog/1447755

8. webdriver 等待頁面加載完成

http://jarvi.iteye.com/blog/1453662

9. Webdriver 經過調用JavascriptExecutor 使對象隱藏對象出現,操做對象。

http://blog.sina.com.cn/s/blog_539a70d30101ajsg.html

10.Selenium中webdriver的quit()和close()區別

在關閉driver時用Driver.Quit();不要用Driver.Close();
1. webDriver.Close() - Close the browser window that the driver has focus of //關閉當前焦點所在的窗口
2. webDriver.Quit() - Calls dispose //調用dispose方法
3. webDriver.Dispose() Closes all browser windows and safely ends the session 關閉全部窗口,而且安全關閉session
參考:
 
 
相關文章
相關標籤/搜索