標籤:

Selenium 2.0 WebDriver with Visual Studio, C#, & IE

enium2.0WebDriverwithVisualStudio,C#,&IE

(2013-03-21 17:23:33)

轉載

分類: Selenium

原文:http://www.joecolantonio.com/2012/07/31/getting-started-using-selenium-2-0-webdriver-for-ie-in-visual-studio-c/

Download Selenium C# Client DriversThe first step is to download the C# dlls from Selenium"s website.You"ll also want to download the Internet Explorer DriverServer:

Configure Visual Studio to work withSelenium

Time to Code!Cool!! Now that we have the Selenium dlls referenced in ourproject, it"s time to test the configuration by running a quicktest.At the top of your project code after the last "using" namespaceadd the following Selenium namespaces:

Run the test. joecolantonio.com should appear.IE Developer ToolbarIf you are going to be scripting against IE you"ll want to installthe Internet Explorer Developer Toolbar. (Those familiar with QTPare aware that this is similar QTP"s spy tool)Using the IE Dev"s Arrow feature allows you to spy on an element"sattributes. You can then use those attributes in your Selenium codeto help identify fields in you web application.

For example if we want to navigate towww.joecolantonio.com/HpSupport.html and select a value from the"Select your tool & Version" we would point the IE Dev arrow tothe field to see its attributes:

WTF"s to look out forIf you getting the following error:"InvalidOperationException was unhandled –unexpected error launching Internet Explorer. Protected Mode setting are not the same for allzones.Enable Protected Mode must be set to the same value (enabled ordisabled) for all zones"

If you are getting the following error:"DriverServiceNotFoundException wasunhandled: The file … IEDriverServer.exe does not exist. Thedriver can be downloaded at"

Make sure that you downloaded the IEDriverServer.exe and alsothat you have the correct path specified in your code


推薦閱讀:

Selenium Page Object 自動化測試框架-run.py總控腳本設計
selenium中如何模擬頁面滾動?
selenium自動化測試入門 操作瀏覽器
4.3 通過selenium 模擬瀏覽器抓取
爬蟲雜談(二)使用Selenium抓取動態網站

TAG:Selenium |