tag:blogger.com,1999:blog-68995011305825628432023-06-15T20:09:28.503+05:30Selenium for .Net using C# languageI started writing this blog to share my experiences/knowledge on selenium in .Net using C# language. Cuz outside you will get very little information about selenium for .Net.MD.JAWEDhttp://www.blogger.com/profile/07432832127158337660noreply@blogger.comBlogger7125tag:blogger.com,1999:blog-6899501130582562843.post-82818514700732171672012-02-11T09:38:00.000+05:302012-02-11T09:38:01.191+05:30My Name in the list of winners at C-sharp corner for the month of December, 2011.<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
I was unable to express my happiness when I saw my name in
the list of winners. </div>
<div class="MsoNormal">
While posting any article on <a href="http://www.c-sharpcorner.com/">http://www.c-sharpcorner.com</a> ,I never
thought that my name would get listed over there with in 2 months . </div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
But now this became true. All this happen due to all my readers’
comments and suggestion which gave me courage to write more and more.</div>
<div class="MsoNormal">
Thanks to all my readers, <a href="http://www.c-sharpcorner.com/">http://www.c-sharpcorner.com</a> and
mentors who encourage me share my knowledge and experience.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
These kinds of encouragement provide me a better and nice
path to share my knowledge/experience with much bigger audiences. </div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
Lists of winners:</div>
<div class="MsoNormal">
<a href="http://www.c-sharpcorner.com/News/1338/december-month-winners-announced.aspx">http://www.c-sharpcorner.com/News/1338/december-month-winners-announced.aspx</a></div>
<div class="MsoNormal">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-JgiOeRo32eA/TzXpYyp54hI/AAAAAAAAA24/AtenBGgo-7Y/s1600/Dec_Prize2011.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="http://2.bp.blogspot.com/-JgiOeRo32eA/TzXpYyp54hI/AAAAAAAAA24/AtenBGgo-7Y/s640/Dec_Prize2011.png" width="640" /></a></div>
<div class="MsoNormal">
Thanks,</div>
<div class="MsoNormal">
Md. jawed</div>
</div>MD.JAWEDhttp://www.blogger.com/profile/07432832127158337660noreply@blogger.com2tag:blogger.com,1999:blog-6899501130582562843.post-14220909287356007942012-02-08T12:49:00.000+05:302012-02-08T12:49:07.847+05:30Data Driven Testing Using Selenium (webdriver) In C#<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="margin: 0in 0in 10pt 1in;">
<b style="mso-bidi-font-weight: normal;"><u><span style="font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Data Driven Testing Using Selenium (webdriver) In C#</span></u></b></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt 1in;">
<b style="mso-bidi-font-weight: normal;"><u><span style="font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"><a href="http://www.c-sharpcorner.com/uploadfile/jawedmd/data-driven-testing-using-selenium-webdriver-in-c-sharp/" target="_blank">SourceCode</a></span></u></b></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">In this article, I would like to explain about performing data driven testing in selenium .net. </span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">I have used C# language and for IDE is Visual Studio 2010 ultimate edition to achieve our aim. As we will proceed we will know, steps by steps to Create Data Driven Test method using Selenium in .Net. So for now, let’s roll our sleeve and get going.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Before going into details, it would be better to provide synopsis of few things so that even you will get familiar with everything.<span style="mso-spacerun: yes;"> </span>And as I will proceed you will not feel out of cut from the main theme. </span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><u><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Selenium</span></u></b></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Selenium</span></b><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"> is a portable software testing </span><a href="http://en.wikipedia.org/wiki/Software_framework" title="Software framework"><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; text-decoration: none; text-underline: none;">framework</span></a><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"> for web applications. Selenium provides a record/playback tool for authoring tests without learning a test </span><a href="http://en.wikipedia.org/wiki/Scripting_language" title="Scripting language"><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; text-decoration: none; text-underline: none;">scripting language</span></a><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"> (Selenium IDE). It also provides a test domain-specific language (Selenese) to write tests in a number of popular programming languages, including </span><a href="http://en.wikipedia.org/wiki/C_Sharp_(programming_language)" title="C Sharp (programming language)"><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; text-decoration: none; text-underline: none;">C#</span></a><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">, </span><a href="http://en.wikipedia.org/wiki/Java_(software_platform)" title="Java (software platform)"><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; text-decoration: none; text-underline: none;">Java</span></a><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">, </span><a href="http://en.wikipedia.org/wiki/Groovy_(programming_language)" title="Groovy (programming language)"><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; text-decoration: none; text-underline: none;">Groovy</span></a><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">, </span><a href="http://en.wikipedia.org/wiki/Perl" title="Perl"><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; text-decoration: none; text-underline: none;">Perl</span></a><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">, </span><a href="http://en.wikipedia.org/wiki/PHP" title="PHP"><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; text-decoration: none; text-underline: none;">PHP</span></a><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">, </span><a href="http://en.wikipedia.org/wiki/Python_(programming_language)" title="Python (programming language)"><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; text-decoration: none; text-underline: none;">Python</span></a><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"> and </span><a href="http://en.wikipedia.org/wiki/Ruby_(programming_language)" title="Ruby (programming language)"><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; text-decoration: none; text-underline: none;">Ruby</span></a><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">. The tests can then be run against most modern </span><a href="http://en.wikipedia.org/wiki/Web_browser" title="Web browser"><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; text-decoration: none; text-underline: none;">web browsers</span></a><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">. Selenium deploys on Windows, Linux, and Macintosh platforms.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"><span style="mso-spacerun: yes;"> </span>(Source: </span><a href="http://en.wikipedia.org/wiki/Selenium_(software))"><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; text-decoration: none; text-underline: none;">http://en.wikipedia.org/wiki/Selenium_(software))</span></a><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"></span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">I would refrain myself by going into details about the selenium. As there is tons of documentation and information available on net which already explain about the selenium. You can go through over there.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">You can visit selenium official website for the documentation:</span></div>
<a href="http://seleniumhq.org/"><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;">http://seleniumhq.org/</span></a><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"> </span><br />
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;">Download the selenium for .Net from here:</span><br />
<a href="http://seleniumhq.org/download/"><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;">http://seleniumhq.org/download/</span></a><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"></span><br />
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;">Apart from that you can visit my blog also to get to know about selenium web driver using .Net</span><br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<a href="http://seleniumdotnet.blogspot.com/"><span style="font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">http://seleniumdotnet.blogspot.com</span></a><span style="font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><u><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Data Driven Testing</span></u></b></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Data driven testing is an action through which set of test inputs and/or output values are read from data files (ODBC source, CSV files, Excel files, DAO objects, ADO objects etc) and are loaded into variables in captured or manually coded script. Data-Driven testing generally means executing a set of steps with multiple sets of data. Selenium does not provide any out-of-the box solution for data driven testing but leaves it up to the user to implement this on his own. That why we here to do out of box </span><span style="color: #333333; font-family: Wingdings; font-size: 10pt; line-height: 115%; mso-ascii-font-family: Arial; mso-bidi-font-family: Arial; mso-char-type: symbol; mso-hansi-font-family: Arial; mso-symbol-font-family: Wingdings;"><span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings;">J</span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"></span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><u><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Code:</span></u></b></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt;">
<a href="javascript:void(0)" title="Collapse"><b><span style="color: #3f529c; font-family: "Arial", "sans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman"; text-decoration: none; text-underline: none;">Prerequisites</span></b></a><span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";"> </span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt 30pt; mso-list: l4 level1 lfo4; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-indent: -0.25in;">
<span style="color: black; font-family: Symbol; font-size: 10pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;"><span style="mso-list: Ignore;">·<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";">Visual Studio 2010 Premium or Visual Studio 2010 Ultimate.</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 10pt 30pt; mso-list: l4 level1 lfo4; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in; text-indent: -0.25in;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt; mso-fareast-font-family: "Times New Roman";"></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">So now our main coding will start from here:</span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">We will be using Unit testing feature provided by VS2010 and C# code for the same.</span></div>
<div class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in; mso-list: l3 level1 lfo1; text-indent: -0.25in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">1.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Select Unit test as project from VS2010</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 55.5pt; mso-add-space: auto; mso-list: l3 level2 lfo1; text-indent: -19.5pt;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">1.1<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">open your VS2010</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 55.5pt; mso-add-space: auto; mso-list: l3 level2 lfo1; text-indent: -19.5pt;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">1.2<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Click on Test Tab and select New test</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 55.5pt; mso-add-space: auto; mso-list: l3 level2 lfo1; text-indent: -19.5pt;">
<br /></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 55.5pt; mso-add-space: auto; mso-list: l3 level2 lfo1; text-indent: -19.5pt;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-cB-Dvk-3uzM/TzIfiYE7SVI/AAAAAAAAA1o/K4vAMwrTu3I/s1600/New_Test.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="152" sda="true" src="http://2.bp.blogspot.com/-cB-Dvk-3uzM/TzIfiYE7SVI/AAAAAAAAA1o/K4vAMwrTu3I/s400/New_Test.png" width="400" /></a></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 55.5pt; mso-add-space: auto; mso-list: l3 level2 lfo1; text-indent: -19.5pt;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"><span style="mso-spacerun: yes;"> </span><span style="mso-no-proof: yes;"><shapetype coordsize="21600,21600" filled="f" id="_x0000_t75" o:preferrelative="t" o:spt="75" path="m@4@5l@4@11@9@11@9@5xe" stroked="f"> <stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path gradientshapeok="t" o:connecttype="rect" o:extrusionok="f"></path><lock aspectratio="t" v:ext="edit"></lock></shapetype></span></span></div>
<div align="center" class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt; mso-add-space: auto; text-align: center;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Figure 1: Select New test</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt; mso-add-space: auto;">
<br /></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 55.5pt; mso-add-space: auto; mso-list: l3 level2 lfo1; text-indent: -19.5pt;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">1.3<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Click on Unit test from the New open window </span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt; mso-add-space: auto;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-no-proof: yes;"></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"></span></div>
<div align="center" class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt; mso-add-space: auto; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-2HslaqrkVuM/TzIfqDxl-rI/AAAAAAAAA2Q/jCkerOXfl68/s1600/TestFile_Sel.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="341" sda="true" src="http://1.bp.blogspot.com/-2HslaqrkVuM/TzIfqDxl-rI/AAAAAAAAA2Q/jCkerOXfl68/s400/TestFile_Sel.PNG" width="400" /></a></div>
<div align="center" class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt; mso-add-space: auto; text-align: center;">
<br /></div>
<div align="center" class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt; mso-add-space: auto; text-align: center;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Figure2. Select Unit Test from VS2010</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 55.5pt; mso-add-space: auto;">
<br /></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 73.5pt; mso-add-space: auto; mso-list: l6 level2 lfo2; text-indent: -0.25in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">1.4<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Rename the File to SeleniumTest.cs</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 55.5pt; mso-add-space: auto;">
<br /></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in; mso-list: l3 level1 lfo1; text-indent: -0.25in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">2.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Add Selenium web driver references</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 55.5pt; mso-add-space: auto; mso-list: l3 level2 lfo1; text-indent: -19.5pt;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">2.1<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Add below dlls through add references </span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 55.5pt; mso-add-space: auto; mso-list: l3 level2 lfo1; text-indent: -19.5pt;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-4dg82EBb2nY/TzIfgiKzFUI/AAAAAAAAA1c/chvk7D6Jwj0/s1600/Dllrefrences.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="140" sda="true" src="http://1.bp.blogspot.com/-4dg82EBb2nY/TzIfgiKzFUI/AAAAAAAAA1c/chvk7D6Jwj0/s320/Dllrefrences.PNG" width="320" /></a></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 55.5pt; mso-add-space: auto;">
<br /></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 55.5pt; mso-add-space: auto;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"> Figure3. Add Selenium DLL in the project.</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 55.5pt; mso-add-space: auto;">
<br /></div>
<div class="MsoListParagraphCxSpLast" style="margin: 0in 0in 10pt 0.5in; mso-list: l3 level1 lfo1; text-indent: -0.25in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">3.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Open you selenium.cs file and add below Name space</span></div>
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; margin: auto auto auto 15.15pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;"><tbody>
<tr style="height: 52.5pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;"><td style="background-color: transparent; border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; height: 52.5pt; mso-border-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 255.75pt;" valign="top" width="341"><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 8.25pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: "Arial", "sans-serif"; font-size: 10pt;">using</span><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"> OpenQA.Selenium;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 8.25pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: "Arial", "sans-serif"; font-size: 10pt;">using</span><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"> OpenQA.Selenium.IE;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 8.25pt; mso-layout-grid-align: none;">
<span style="color: green; font-family: "Arial", "sans-serif"; font-size: 10pt;">//add this name space to access WebDriverWait</span><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 8.25pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: "Arial", "sans-serif"; font-size: 10pt;">using</span><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"> OpenQA.Selenium.Support.UI;<span style="color: blue;"></span></span></div>
</td></tr>
</tbody></table>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 0.25in; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoListParagraph" style="margin: 0in 0in 10pt 0.5in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"><span style="mso-spacerun: yes;"> </span>Never try to add this forcefully until unless you are not getting into your VS intelligence.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Test Initialization:</span></b></div>
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;"><tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;"><td style="background-color: transparent; border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 6.65in;" valign="top" width="638"><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">public</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">static</span> <span style="color: #2b91af;">IWebDriver</span> WebDriver;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: green; font-family: Consolas; font-size: 9.5pt;">// Use TestInitialize to run code before running each test </span><span style="font-family: Consolas; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>[<span style="color: #2b91af;">TestInitialize</span>()]</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">public</span> <span style="color: blue;">void</span> MyTestInitialize()</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> capabilitiesInternet = <span style="color: blue;">new</span> OpenQA.Selenium.Remote.<span style="color: #2b91af;">DesiredCapabilities</span>();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>capabilitiesInternet.SetCapability(<span style="color: #a31515;">"ignoreProtectedModeSettings"</span>, <span style="color: blue;">true</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>WebDriver = <span style="color: blue;">new</span> <span style="color: #2b91af;">InternetExplorerDriver</span>(capabilitiesInternet);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt;">
<br /></div>
</td></tr>
</tbody></table>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Test Cleanup:</span></b></div>
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;"><tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;"><td style="background-color: transparent; border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 6.65in;" valign="top" width="638"><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: green; font-family: Consolas; font-size: 9.5pt;">// Use TestCleanup to run code after each test has run</span><span style="font-family: Consolas; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>[<span style="color: #2b91af;">TestCleanup</span>()]</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">public</span> <span style="color: blue;">void</span> MyTestCleanup()</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>WebDriver.Quit();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt;">
<br /></div>
</td></tr>
</tbody></table>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Before implementing the test method for data driven we will write the selenium Test method without Data Driven. Then we will go for Data Driven Testing, by going with this scenario you will clearly understand the difference between simple selenium test method without data driven and selenium test method with Data Driven.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><u><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Selenium Test Method without Data Driven</span></u></b></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">To write Automation code using selenium to automate our target website we will use any web application. Here I will use </span><a href="http://www.x-rates.com/calculator.html"><span style="font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">http://www.x-rates.com/calculator.html</span></a><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"> web application for our AUT (Application under Test) purpose. The function of this AUT web application is to compare e currency value from one country’s currency to other country’s currency.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><span style="color: red; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">NOTE:</span></b><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"> The AUT website is just for demo purpose. The currency rate would not be fixed. So might be the test cases pass for me would failed for you or vise-versa.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<u><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"><span style="text-decoration: none;"></span></span></u></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<u><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">The web page is as below:</span></u></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-no-proof: yes;"></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"></span></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-R86dcpJRPpk/TzIfshX9g3I/AAAAAAAAA2k/u0m9rnm5axk/s1600/WebPage_Currency.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" sda="true" src="http://2.bp.blogspot.com/-R86dcpJRPpk/TzIfshX9g3I/AAAAAAAAA2k/u0m9rnm5axk/s1600/WebPage_Currency.PNG" /></a></div>
<div align="center" class="MsoNormal" style="margin: 0in 0in 10pt; text-align: center;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Figure 4. Application Under test</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Now we will write our Selenium Test method to perform below operation:</span></div>
<div class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in; mso-list: l1 level1 lfo3; text-indent: -0.25in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">1.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Select Value in to first dropdown box(convert)</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in; mso-list: l1 level1 lfo3; text-indent: -0.25in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">2.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Select value into second dropdown box(into)</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in; mso-list: l1 level1 lfo3; text-indent: -0.25in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">3.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Click on Calculate button to get the currency value w.r.t first country’s currency selected.</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in; mso-list: l1 level1 lfo3; text-indent: -0.25in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">4.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Read the value from upper textbox/input box. This will be our actual result.</span></div>
<div class="MsoListParagraphCxSpLast" style="margin: 0in 0in 10pt 0.5in; mso-list: l1 level1 lfo3; text-indent: -0.25in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">5.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Compare the actual value from expected value.</span></div>
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; margin: auto auto auto 0.5in; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;"><tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;"><td style="background-color: transparent; border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 6.65in;" valign="top" width="638"><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span>[<span style="color: #2b91af;">TestMethod</span>]</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">public</span> <span style="color: blue;">void</span> TestCurrencyConvertorWithoutDDT()</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">//Read your first country currency name</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> convertVal = <span style="color: #a31515;">"American Dollar"</span>;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">//Read your second contry currency</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> inToVal = <span style="color: #a31515;">"Indian Rupee"</span>;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">//Read Expected value from data source</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> expectedValue = <span style="color: #a31515;">"49.7597 INR"</span>;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">//Goto the Target website</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>WebDriver.Navigate().GoToUrl(<span style="color: #a31515;">"http://www.x- </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: #a31515; font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>rates.com/calculator.html"</span><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;">);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> setValueConvert = WebDriver.FindElement(<span style="color: #2b91af;">By</span>.Name(<span style="color: #a31515;">"from"</span>));</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> setValueInto = WebDriver.FindElement(<span style="color: #2b91af;">By</span>.Name(<span style="color: #a31515;">"to"</span>));</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> calculateButton = WebDriver.FindElement(<span style="color: #2b91af;">By</span>.Name(<span style="color: #a31515;">"Calculate"</span>));</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> outPutvalue = WebDriver.FindElement(<span style="color: #2b91af;">By</span>.Name(<span style="color: #a31515;">"outV"</span>));</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> selectConvertItem = <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectElement</span>(setValueConvert);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> selectIntoItem = <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectElement</span>(setValueInto);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>selectConvertItem.SelectByText(convertVal);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>selectIntoItem.SelectByText(inToVal);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>calculateButton.Click();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> currencyValue = outPutvalue.GetAttribute(<span style="color: #a31515;">"value"</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">Thread</span>.Sleep(900);<span style="color: green;">//Not a good practise to use Sleep</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">//Get the screen shot of the web page and save it on local disk </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>SaveScreenShot(WebDriver.Title);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">Assert</span>.AreEqual(expectedValue, currencyValue.Trim());</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>}</span></div>
<div class="MsoListParagraph" style="line-height: normal; margin: 0in 0in 0pt; mso-add-space: auto;">
<br /></div>
</td></tr>
</tbody></table>
<br />
<div class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in;">
<u><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"><span style="text-decoration: none;"></span></span></u></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<br /></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<b style="mso-bidi-font-weight: normal;"><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Target Web page shown as below:</span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<u><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-no-proof: yes;"></span></u><u><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"></span></u></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<br /></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-zN_xtXj6G1A/TzIfmR900PI/AAAAAAAAA14/xxAt-fJADdM/s1600/DropDownBox.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" sda="true" src="http://4.bp.blogspot.com/-zN_xtXj6G1A/TzIfmR900PI/AAAAAAAAA14/xxAt-fJADdM/s1600/DropDownBox.PNG" /></a></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"> Figure 5: Target web page with all the controls</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<u><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"><span style="text-decoration: none;"></span></span></u></div>
<div class="MsoListParagraphCxSpLast" style="margin: 0in 0in 10pt 0.5in;">
<br /></div>
<div class="MsoListParagraphCxSpLast" style="margin: 0in 0in 10pt 0.5in;">
<br /></div>
<div class="MsoListParagraphCxSpLast" style="margin: 0in 0in 10pt 0.5in;">
<u><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Run the above Test method to see the result:</span></u></div>
<div style="margin-left: 0.5in; mso-list: l5 level1 lfo5; tab-stops: list .5in; text-indent: -0.25in;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">1.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;">On the <span class="label"><strong>Test</strong></span> menu, click <span class="label"><strong>Windows</strong></span> and the select <span class="label"><strong>Test View</strong></span>.</span></div>
<div style="margin-left: 0.5in;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt; mso-no-proof: yes;"></span><span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;"></span></div>
<div align="center" style="margin-left: 0.5in; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://2.bp.blogspot.com/-XNG-C-lNjHE/TzIfq5B-dgI/AAAAAAAAA2Y/tvfzbMWeG3I/s1600/TestView.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="167" sda="true" src="http://2.bp.blogspot.com/-XNG-C-lNjHE/TzIfq5B-dgI/AAAAAAAAA2Y/tvfzbMWeG3I/s400/TestView.png" width="400" /></a></div>
<div align="center" style="margin-left: 0.5in; text-align: center;">
<br /></div>
<div align="center" style="margin-left: 0.5in; text-align: center;">
<br /></div>
<div align="center" style="margin-left: 0.5in; text-align: center;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;">Figure 6. Select Test View</span></div>
<div align="center" style="margin-left: 0.5in; text-align: center;">
<br /></div>
<div align="center" style="margin-left: 0.5in; text-align: center;">
<br /></div>
<div style="margin-left: 0.5in;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;">The Test View window is displayed.</span></div>
<div style="margin-left: 0.5in;">
<br /></div>
<div style="margin-left: 0.5in;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt; mso-no-proof: yes;"></span><span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;"></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-R9U-mHLvpCU/TzIfr8Bpn3I/AAAAAAAAA2g/FsNyaiYM6rs/s1600/TestView_Right.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="197" sda="true" src="http://3.bp.blogspot.com/-R9U-mHLvpCU/TzIfr8Bpn3I/AAAAAAAAA2g/FsNyaiYM6rs/s400/TestView_Right.png" width="400" /></a></div>
<div align="center" style="margin-left: 0.5in; text-align: center;">
<br /></div>
<div align="center" style="margin-left: 0.5in; text-align: center;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;">Figure 7. Test View Window</span></div>
<div style="margin-left: 0.5in;">
<br /></div>
<div style="margin-left: 0.5in; mso-list: l5 level1 lfo5; tab-stops: list .5in; text-indent: -0.25in;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">2.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;">Right-click <span class="label"><strong>TestCurrencyConvertorWithoutDDT </strong></span>and click <span class="label"><strong>Run Selection</strong></span>. </span></div>
<div style="margin-left: 0.5in;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;">If the <span class="label"><strong>Test Results</strong></span> window is not already open, it opens now. The <span class="label"><strong>TestCurrencyConvertorWithoutDDT<span style="mso-tab-count: 1;"> </span></strong></span>test runs.</span></div>
<div style="margin-left: 0.5in;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;">In the <span class="label"><strong>Result</strong></span> column in the <span class="label"><strong>Test Results</strong></span> window, test status is displayed as <span class="label"><strong>Running</strong></span> while the test is running. </span></div>
<div style="margin-left: 0.5in; mso-list: l5 level1 lfo5; tab-stops: list .5in; text-indent: -0.25in;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">3.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;">In the <span class="label"><strong>Test Results</strong></span> window, right-click the row that represents the test and then click <span class="label"><strong>View Test Results Details</strong></span>.</span></div>
<div class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-no-proof: yes;"></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-a3zokGb0btg/TzIfoJT-rPI/AAAAAAAAA2A/HO3LIhtIb7o/s1600/RunTest_withoutDDT.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="198" sda="true" src="http://1.bp.blogspot.com/-a3zokGb0btg/TzIfoJT-rPI/AAAAAAAAA2A/HO3LIhtIb7o/s400/RunTest_withoutDDT.png" width="400" /></a></div>
<div align="center" class="MsoListParagraphCxSpLast" style="margin: 0in 0in 10pt 0.5in; text-align: center;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Figure 8. Test Results Windows</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><u><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Test Method as Data Driven</span></u></b></div>
<div class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">As already you have seen in above Selenium test method we ran our method for only one set on values. Now in Data Driven we will run the same method with multiple sets of inputs value.</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"><span style="mso-spacerun: yes;"> </span></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"><span style="mso-spacerun: yes;"> </span>To read the inputs value against which we are going to run our Test method, we have stored our inputs values into some data Source. For that we will use CSV file, but you can use other data source also like excel Sheet else. </span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">In this CSV file we will store our expected result also so that we can compare our actual output with this value.</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<br /></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<b style="mso-bidi-font-weight: normal;"><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Our csv would look something like this (give the name to this csv file as DDT.csv):</span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<br /></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-no-proof: yes;"></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-rPyWzqsJmP8/TzIfeVvrXjI/AAAAAAAAA1I/Meavy-Ejl60/s1600/CSV_DDT.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="106" sda="true" src="http://3.bp.blogspot.com/-rPyWzqsJmP8/TzIfeVvrXjI/AAAAAAAAA1I/Meavy-Ejl60/s400/CSV_DDT.PNG" width="400" /></a></div>
<div align="center" class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in; text-align: center;">
<br /></div>
<div align="center" class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in; text-align: center;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Figure 9. CSV file as Data Source</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<br /></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<br /></div>
<div class="MsoListParagraphCxSpLast" style="margin: 0in 0in 10pt 0.5in;">
<b style="mso-bidi-font-weight: normal;"><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Now we will connect the above Test method to our data Source [here it is DDT.CSV]</span></b></div>
<div style="margin-left: 0.5in; mso-list: l0 level1 lfo6; tab-stops: list .5in; text-indent: -0.25in;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">1.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;">Open the solution that contains the test method for which you want to use a data source.</span></div>
<div style="margin-left: 0.5in; mso-list: l0 level1 lfo6; tab-stops: list .5in; text-indent: -0.25in;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">2.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;">On the <span class="label"><strong>Test</strong></span> menu, point to <span class="label"><strong>Windows</strong></span>, and then click <span class="label"><strong>Test View</strong></span>.</span></div>
<div style="margin-left: 0.5in; mso-list: l0 level1 lfo6; tab-stops: list .5in; text-indent: -0.25in;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">3.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;">In the <span class="label"><strong>Test View</strong></span> window, right-click the unit test for which you want to use a data source and then click <span class="label"><strong>Properties</strong></span>.</span></div>
<div style="margin-left: 0.5in;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt; mso-no-proof: yes;"></span><span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;"></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-S2PeXFnBZHk/TzIflqLZnWI/AAAAAAAAA1w/pUvzmLvzSSE/s1600/PropertiseDDT.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="148" sda="true" src="http://4.bp.blogspot.com/-S2PeXFnBZHk/TzIflqLZnWI/AAAAAAAAA1w/pUvzmLvzSSE/s400/PropertiseDDT.png" width="400" /></a></div>
<div align="center" style="margin-left: 0.5in; text-align: center;">
<br /></div>
<div align="center" style="margin-left: 0.5in; text-align: center;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;">Figure 10. Properties of Selenium Test Method</span></div>
<div align="center" style="margin-left: 0.5in; text-align: center;">
<br /></div>
<div style="margin-left: 0.5in; mso-list: l0 level1 lfo6; tab-stops: list .5in; text-indent: -0.25in;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">4.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;">In the <span class="label"><strong>Properties</strong></span> window click <span class="label"><strong>Data Connection String</strong></span> and then click the ellipses(…).</span></div>
<div style="margin-left: 0.5in;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt; mso-no-proof: yes;"></span><span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;"></span></div>
<div align="center" style="margin-left: 0.5in; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-ad3p9MAZiQU/TzIffUQbQoI/AAAAAAAAA1Q/cvCVR58S_34/s1600/DataSource_Wizard.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="353" sda="true" src="http://3.bp.blogspot.com/-ad3p9MAZiQU/TzIffUQbQoI/AAAAAAAAA1Q/cvCVR58S_34/s400/DataSource_Wizard.PNG" width="400" /></a></div>
<div align="center" style="margin-left: 0.5in; text-align: center;">
<br /></div>
<div align="center" style="margin-left: 0.5in; text-align: center;">
<br /></div>
<div align="center" style="margin-left: 0.5in; text-align: center;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;">Figure 11. <strong><span class="label">Test Data Source Wizard</span></strong></span></div>
<div align="center" style="margin-left: 0.5in; text-align: center;">
<br /></div>
<div style="margin-left: 0.5in; mso-list: l0 level1 lfo6; tab-stops: list .5in; text-indent: -0.25in;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">5.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;">Follow the instructions in the in the <span class="label"><strong>New Test Data Source Wizard</strong></span> to create the data connection.</span></div>
<div style="margin-left: 0.5in;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt;">A connection string is added to your unit test after the first bracket of the [TestMethod()] element.</span></div>
<div class="MsoListParagraph" style="margin: 0in 0in 10pt 0.5in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">It would be something like this:</span></div>
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; margin: auto auto auto 0.5in; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;"><tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;"><td style="background-color: transparent; border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 6.65in;" valign="top" width="638"><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;">[<span style="color: #2b91af;">DeploymentItem</span>(<span style="color: #a31515;">"AutomationUsingSeleniumTest\\DDT.csv"</span>), <span style="color: #2b91af;">DataSource</span>(<span style="color: #a31515;">"Microsoft.VisualStudio.TestTools.DataSource.CSV"</span>, <span style="color: #a31515;">"|DataDirectory|\\DDT.csv"</span>, <span style="color: #a31515;">"DDT#csv"</span>, <span style="color: #2b91af;">DataAccessMethod</span>.Sequential)]</span></div>
</td></tr>
</tbody></table>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<br /></div>
<h3 style="margin: auto 0in auto 0.5in; mso-list: l0 level1 lfo6; tab-stops: list .5in; text-indent: -0.25in;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;"><span style="color: #3f529c;">6.<span style="font: 7pt "Times New Roman";"> </span></span></span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt;">Now we will assign variables to values from your data source</span><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"></span></h3>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin: 0in 0in 0pt 0.75in; mso-add-space: auto; mso-list: l2 level2 lfo7; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -0.25in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">6.1<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt;">Open the Test file that contains the test method for which you want to use a data source and locate the variables in the test method.</span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin: 0in 0in 0pt 0.75in; mso-add-space: auto; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<br /></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin: 0in 0in 0pt 0.75in; mso-add-space: auto; mso-list: l2 level2 lfo7; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; text-indent: -0.25in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">6.2<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt;">For each variable that you want to come from the data source, use the syntax TestContext.DataRow["NameOfColumn"].</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<br /></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin: 0in 0in 0pt 0.75in; mso-add-space: auto; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<br /></div>
<div class="MsoListParagraphCxSpLast" style="margin: 0in 0in 10pt 0.5in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"><span style="mso-spacerun: yes;"> </span>The piece of code would be as below:</span></div>
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; margin: auto auto auto 0.5in; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;"><tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;"><td style="background-color: transparent; border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 6.15in;" valign="top" width="590"><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span></span><span style="color: green; font-family: "Arial", "sans-serif"; font-size: 10pt;">//Read your first country currency name</span><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: "Arial", "sans-serif"; font-size: 10pt;">var</span><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"> convertVal = TestContext.DataRow[<span style="color: #a31515;">"FirstCountryByText"</span>].ToString();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: green; font-family: "Arial", "sans-serif"; font-size: 10pt;">//Read your second contry currency</span><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: "Arial", "sans-serif"; font-size: 10pt;">var</span><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"> inToVal = TestContext.DataRow[<span style="color: #a31515;">"SecondCountryByText"</span>].ToString();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: green; font-family: "Arial", "sans-serif"; font-size: 10pt;">//Read Expected value from data source</span><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: "Arial", "sans-serif"; font-size: 10pt;">var</span><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"> expectedValue = TestContext.DataRow[<span style="color: #a31515;">"ExpectedValue"</span>].ToString();</span></div>
<div class="MsoListParagraph" style="line-height: normal; margin: 0in 0in 0pt; mso-add-space: auto;">
<br /></div>
</td></tr>
</tbody></table>
<br />
<div class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in;">
<br /></div>
<div class="MsoListParagraphCxSpLast" style="margin: 0in 0in 10pt 0.5in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">The whole Code of the Test Method would be as below:</span></div>
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; margin: auto auto auto 0.5in; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;"><tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;"><td style="background-color: transparent; border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 6.65in;" valign="top" width="638"><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;">[<span style="color: #2b91af;">DeploymentItem</span>(<span style="color: #a31515;">"AutomationUsingSeleniumTest\\DDT.csv"</span>), <span style="color: #2b91af;">DataSource</span>(<span style="color: #a31515;">"Microsoft.VisualStudio.TestTools.DataSource.CSV"</span>, <span style="color: #a31515;">"|DataDirectory|\\DDT.csv"</span>, <span style="color: #a31515;">"DDT#csv"</span>, <span style="color: #2b91af;">DataAccessMethod</span>.Sequential)]</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>[<span style="color: #2b91af;">TestMethod</span>]</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">public</span> <span style="color: blue;">void</span> TestCurrencyConvertorWithDDT()</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">//Read your first country currency name</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> convertVal = TestContext.DataRow[<span style="color: #a31515;">"FirstCountryByText"</span>].ToString();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">//Read your second contry currency</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> inToVal = TestContext.DataRow[<span style="color: #a31515;">"SecondCountryByText"</span>].ToString();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">//Read Expected value from data source</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> expectedValue = TestContext.DataRow[<span style="color: #a31515;">"ExpectedValue"</span>].ToString();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">//Goto the Target website</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>WebDriver.Navigate().GoToUrl(<span style="color: #a31515;">"http://www.x-rates.com/calculator.html"</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> setValueConvert = WebDriver.FindElement(<span style="color: #2b91af;">By</span>.Name(<span style="color: #a31515;">"from"</span>));</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> setValueInto = WebDriver.FindElement(<span style="color: #2b91af;">By</span>.Name(<span style="color: #a31515;">"to"</span>));</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> calculateButton = WebDriver.FindElement(<span style="color: #2b91af;">By</span>.Name(<span style="color: #a31515;">"Calculate"</span>));</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> outPutvalue = WebDriver.FindElement(<span style="color: #2b91af;">By</span>.Name(<span style="color: #a31515;">"outV"</span>));</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> selectConvertItem=<span style="color: blue;">new</span> <span style="color: #2b91af;">SelectElement</span>(setValueConvert);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> selectIntoItem = <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectElement</span>(setValueInto);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>selectConvertItem.SelectByText(convertVal);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>selectIntoItem.SelectByText(inToVal);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>calculateButton.Click();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> currencyValue =outPutvalue.GetAttribute(<span style="color: #a31515;">"value"</span>) ;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">Thread</span>.Sleep(900);<span style="color: green;">//Not a good practise to use Sleep</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">//Get the screen shot of the web page and save it on local disk </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>SaveScreenShot(WebDriver.Title);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">Assert</span>.AreEqual(expectedValue,currencyValue.Trim());</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><span style="mso-spacerun: yes;"> </span>}</span></div>
<div class="MsoListParagraph" style="line-height: normal; margin: 0in 0in 0pt; mso-add-space: auto;">
<br /></div>
</td></tr>
</tbody></table>
<br />
<div class="MsoListParagraphCxSpFirst" style="margin: 0in 0in 0pt 0.5in;">
<br /></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in;">
<br /></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.5in; mso-list: l0 level1 lfo6; tab-stops: list .5in; text-indent: -0.25in;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-fareast-font-family: Arial;"><span style="mso-list: Ignore;">7.<span style="font: 7pt "Times New Roman";"> </span></span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Run the Test Method (already I explained this already) and Result would be something like below:</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; mso-add-space: auto;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%; mso-no-proof: yes;"></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"></span></div>
<div align="center" class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; mso-add-space: auto; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-CmDThtpYBv0/TzIfgK9H3VI/AAAAAAAAA1U/BJez-We2KNA/s1600/DDT_RunTestResult.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="182" sda="true" src="http://1.bp.blogspot.com/-CmDThtpYBv0/TzIfgK9H3VI/AAAAAAAAA1U/BJez-We2KNA/s400/DDT_RunTestResult.png" width="400" /></a></div>
<div align="center" class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; mso-add-space: auto; text-align: center;">
<br /></div>
<div align="center" class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; mso-add-space: auto; text-align: center;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Figure 12. Data Driven Test Results</span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; mso-add-space: auto;">
<br /></div>
<div class="MsoListParagraphCxSpMiddle" style="margin: 0in 0in 0pt 0.25in; mso-add-space: auto;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">So you can clearly see that the Test method had ran for 4 different set of value. And it fetched the input values from our specified data source that is DDT.csv.</span></div>
<div class="MsoListParagraphCxSpLast" style="margin: 0in 0in 10pt 0.25in; mso-add-space: auto;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt;">Download the code to get the whole piece of code. I have used a method that is <b style="mso-bidi-font-weight: normal;">SaveScreenShot(WebDriver.Title).</b> You can get the code details along with the uploaded code. Actually this method would take the screen shot you your target web page and will store that on Test Result directory. </span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<b style="mso-bidi-font-weight: normal;"><u><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt;">Save Screen Shot Method </span></u></b></div>
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;"><tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;"><td style="background-color: transparent; border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 6.65in;" valign="top" width="638"><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: grey; font-family: Consolas; font-size: 9.5pt;">///</span><span style="color: green; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: grey; font-family: Consolas; font-size: 9.5pt;"><summary></span><span style="font-family: Consolas; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: grey;">///</span><span style="color: green;"> This will Take the screen shot of the webpage and will save it at particular location</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"></summary></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"><param name="screenshotFirstName"></param></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">private</span> <span style="color: blue;">static</span> <span style="color: blue;">void</span> SaveScreenShot(<span style="color: blue;">string</span> screenshotFirstName)</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> folderLocation = <span style="color: #2b91af;">Environment</span>.CurrentDirectory.Replace(<span style="color: #a31515;">"Out"</span>,<span style="color: #a31515;">""</span>)+<span style="color: #a31515;">"\\ScreenShot\\"</span>;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">if</span> (!<span style="color: #2b91af;">Directory</span>.Exists(folderLocation))</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">Directory</span>.CreateDirectory(folderLocation);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> screenshot = ((<span style="color: #2b91af;">ITakesScreenshot</span>)WebDriver).GetScreenshot();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> filename = <span style="color: blue;">new</span> <span style="color: #2b91af;">StringBuilder</span>(folderLocation);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>filename.Append(screenshotFirstName);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>filename.Append(<span style="color: #2b91af;">DateTime</span>.Now.ToString(<span style="color: #a31515;">"dd-mm-yyyy HH_mm_ss"</span>));</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>filename.Append(<span style="color: #a31515;">".png"</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>screenshot.SaveAsFile(filename.ToString(), System.Drawing.Imaging.<span style="color: #2b91af;">ImageFormat</span>.Png);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
</td></tr>
</tbody></table>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<b style="mso-bidi-font-weight: normal;"><u><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt;">The Screen shot of your Target web page would get saved as below:</span></u></b></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt; mso-no-proof: yes;"></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://1.bp.blogspot.com/-H5OaLunw3jI/TzIfo7X9PHI/AAAAAAAAA2I/VArP8qK7vE0/s1600/ScreenShotResult.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="125" sda="true" src="http://1.bp.blogspot.com/-H5OaLunw3jI/TzIfo7X9PHI/AAAAAAAAA2I/VArP8qK7vE0/s400/ScreenShotResult.PNG" width="400" /></a></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div align="center" class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none; text-align: center;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt;">Figure 13. Screen Shot saved at Test Result folder.</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt;">Feel free to provide your feedback and comments!!</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt;">For any issue/question/suggestion in selenium for C# you refer this blog </span><a href="http://seleniumdotnet.blogspot.com/"><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;">http://seleniumdotnet.blogspot.com</span></a><span class="MsoHyperlink"><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span class="MsoHyperlink"><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;"><u><span style="color: blue;">Thanks,</span></u></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<u><span style="color: blue;"><span class="MsoHyperlink"><span style="font-family: "Arial", "sans-serif"; font-size: 10pt;">MD. Jawed (jawed.ace@gmail.com)</span></span><span style="color: #333333; font-family: "Arial", "sans-serif"; font-size: 10pt;"></span></span></u></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
</div>MD.JAWEDhttp://www.blogger.com/profile/07432832127158337660noreply@blogger.com3tag:blogger.com,1999:blog-6899501130582562843.post-20504960879300350582012-02-01T12:18:00.003+05:302012-02-01T12:18:24.588+05:30Get value from Textbox in .Net(C#)<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">Supposed that you have html code something as below:</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;"><span style="background: yellow; mso-highlight: yellow;"><input name="outV" onfocus="blur()" type="text" size="23"/></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">And you have to get the values from input box mention above. The above input box can be textbox, label or anything.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">Then in that case you have to use below piece of code to retrieve the value from Text Box:</span></div>
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="background: #f2f2f2; border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; margin: auto auto auto 0.9pt; mso-background-themecolor: background1; mso-background-themeshade: 242; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;"><tbody>
<tr style="height: 65.25pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;"><td style="background-color: transparent; border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; height: 65.25pt; mso-border-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 5.75in;" valign="top" width="552"><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 4.5pt; mso-layout-grid-align: none;">
<span style="color: #00b050;"><span style="font-family: Calibri;">//Here I will find the input control using Name, but you can try using Id/css.</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 4.5pt; mso-layout-grid-align: none;">
<span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">IWebElement</span><span style="font-family: Consolas; font-size: 9.5pt;"> outPutvalue = WebDriver.FindElement(<span style="color: #2b91af;">By</span>.Name(<span style="color: #a31515;">"outV"</span>));<span style="color: blue;">string</span> currencyValue =outPutvalue.GetAttribute(<span style="color: #a31515;">"value"</span>) ;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 4.5pt; mso-layout-grid-align: none;">
<span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">Console</span><span style="font-family: Consolas; font-size: 9.5pt;">.WriteLine(<span style="color: #a31515;">"Value from textbox is: "</span> + currencyValue);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt 4.5pt; mso-layout-grid-align: none;">
<br /></div>
</td></tr>
</tbody></table>
<br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: #00b050;"></span><span style="font-family: Consolas; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;"><span style="color: blue;">Output:</span></span></div>
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="background: #76923c; border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; margin: auto auto auto 0.9pt; mso-background-themecolor: accent3; mso-background-themeshade: 191; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;"><tbody>
<tr style="height: 21.75pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;"><td style="background-color: transparent; border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; height: 21.75pt; mso-border-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 138.75pt;" valign="top" width="185"><div class="MsoNormal" style="margin: 0in 0in 10pt 4.5pt;">
<span style="font-family: Calibri;">Value from textbox is: <span style="mso-spacerun: yes;"> </span>1234</span></div>
</td></tr>
</tbody></table>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<br />
<span style="font-family: Calibri;"><strong><span style="color: #741b47;">The Whole Piece of code would look like this:</span></strong></span></div>
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoTableGrid" style="background: #fbd4b4; border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; mso-background-themecolor: accent6; mso-background-themetint: 102; mso-border-alt: solid windowtext .5pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184;"><tbody>
<tr style="mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;"><td style="background-color: transparent; border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; mso-border-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 419.4pt;" valign="top" width="559"><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> OpenQA.Selenium;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> OpenQA.Selenium.IE;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: green; font-family: Consolas; font-size: 9.5pt;">//add this name space to access WebDriverWait</span><span style="font-family: Consolas; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> OpenQA.Selenium.Support.UI;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Threading;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">public</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">void</span> MyTestInitialize()</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span>var</span><span style="font-family: Consolas; font-size: 9.5pt;"> capabilitiesInternet = <span style="color: blue;">new</span> OpenQA.Selenium.Remote.<span style="color: #2b91af;">DesiredCapabilities</span>();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>capabilitiesInternet.SetCapability(<span style="color: #a31515;">"ignoreProtectedModeSettings"</span>, <span style="color: blue;">true</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>WebDriver = <span style="color: blue;">new</span> <span style="color: #2b91af;">InternetExplorerDriver</span>(capabilitiesInternet);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>WebDriver.Navigate().GoToUrl(<span style="color: #a31515;">"http://www.x-rates.com/calculator.html"</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>IWebElement</span><span style="font-family: Consolas; font-size: 9.5pt;"> outPutvalue = WebDriver.FindElement(<span style="color: #2b91af;">By</span>.Name(<span style="color: #a31515;">"outV"</span>));</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><span style="color: blue;">string</span> currencyValue =outPutvalue.GetAttribute(<span style="color: #a31515;">"value"</span>) ;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"Value from textbox is: "</span> +currencyValue);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">}</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt;">
<br /></div>
</td></tr>
</tbody></table>
<br />
<br />
Thanks,<br />
Md. jawed</div>MD.JAWEDhttp://www.blogger.com/profile/07432832127158337660noreply@blogger.com2tag:blogger.com,1999:blog-6899501130582562843.post-46148844550599236412012-01-30T18:56:00.000+05:302012-01-30T19:00:29.743+05:30Dropdown box in selenium web driver in .net<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">To set the desired value into Dropdown box, the below piece of would work fine!</span><br />
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Text;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Collections.Generic;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Linq;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> Microsoft.VisualStudio.TestTools.UnitTesting;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> OpenQA.Selenium;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> OpenQA.Selenium.IE;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: green; font-family: Consolas; font-size: 9.5pt;">//add this name space to access WebDriverWait</span><span style="font-family: Consolas; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> OpenQA.Selenium.Support.UI;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">namespace</span><span style="font-family: Consolas; font-size: 9.5pt;"> AutomationUsingSelenium</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: #2b91af;">InternetExplorerDriver</span> WebDriver;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{<span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> capabilitiesInternet = <span style="color: blue;">new</span> OpenQA.Selenium.Remote.<span style="color: #2b91af;">DesiredCapabilities</span>();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>capabilitiesInternet.SetCapability(<span style="color: #a31515;">"ignoreProtectedModeSettings"</span>, <span style="color: blue;">true</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>WebDriver = <span style="color: blue;">new</span> <span style="color: #2b91af;">InternetExplorerDriver</span>(capabilitiesInternet);</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt; line-height: 115%;"><span style="mso-spacerun: yes;"> </span>WebDriver.Navigate().GoToUrl(<span style="color: #a31515;">"http://www.x-rates.com/calculator.html"</span>);</span></div>
<br />
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-bottom: medium none; border-collapse: collapse; border-left: medium none; border-right: medium none; border-top: medium none; margin: auto auto auto 49.55pt; mso-border-alt: solid windowtext .5pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext; mso-padding-alt: 0in 5.4pt 0in 5.4pt;"><tbody>
<tr style="height: 131.15pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0; mso-yfti-lastrow: yes;"><td style="background: #c2d69b; border-bottom: windowtext 1pt solid; border-left: windowtext 1pt solid; border-right: windowtext 1pt solid; border-top: windowtext 1pt solid; height: 131.15pt; mso-background-themecolor: accent3; mso-background-themetint: 153; mso-border-alt: solid windowtext .5pt; padding-bottom: 0in; padding-left: 5.4pt; padding-right: 5.4pt; padding-top: 0in; width: 346.2pt;" valign="top" width="462"><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">//Get the hold of the dropdown box by Name</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">IWebElement</span> setValueConvert = WebDriver.FindElement(<span style="color: #2b91af;">By</span>.Name(<span style="color: #a31515;">"from"</span>));</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: green; font-family: Consolas; font-size: 9.5pt;">//Place the drop down into selectElemnet</span><span style="font-family: Consolas; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">SelectElement</span> clickThisitem=<span style="color: blue;">new</span> <span style="color: #2b91af;">SelectElement</span>(setValueConvert);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">Thread</span>.Sleep(600);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: green; font-family: Consolas; font-size: 9.5pt;">//Select the Item from dropdown by Index</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>clickThisitem.SelectByIndex(12);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: green; font-family: Consolas; font-size: 9.5pt;">//Select the Item from dropdown by Text</span><span style="font-family: Consolas; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>clickThisitem.SelectByText(<span style="color: #a31515;">"EUR"</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
</td></tr>
</tbody></table>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt; line-height: 115%;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">}</span></div>
<span style="font-family: Calibri;"><strong>Wesite Under Test:</strong></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://4.bp.blogspot.com/-3JMMdFEvsjc/TyaaSqGvOoI/AAAAAAAAA04/GQnB6C7Uu5Q/s1600/DropDownBox.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" gda="true" height="320" src="http://4.bp.blogspot.com/-3JMMdFEvsjc/TyaaSqGvOoI/AAAAAAAAA04/GQnB6C7Uu5Q/s320/DropDownBox.PNG" width="297" /></a></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
Thanks,</div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
Md. Jawed</div>
</div>MD.JAWEDhttp://www.blogger.com/profile/07432832127158337660noreply@blogger.com0tag:blogger.com,1999:blog-6899501130582562843.post-56949291165205337462012-01-25T14:46:00.000+05:302012-01-25T14:46:05.194+05:30Get screenshot of the web page in selenium using C# .net<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> capabilitiesInternet = <span style="color: blue;">new</span> OpenQA.Selenium.Remote.<span style="color: #2b91af;">DesiredCapabilities</span>();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>capabilitiesInternet.SetCapability(<span style="color: #a31515;">"ignoreProtectedModeSettings"</span>, <span style="color: blue;">true</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">IWebDriver</span> webDriver = <span style="color: blue;">new</span> <span style="color: #2b91af;">InternetExplorerDriver</span>(capabilitiesInternet);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Calibri;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span></span><span style="font-family: Consolas; font-size: 9.5pt;">webDriver.Navigate().GoToUrl(<span style="color: #a31515;">"http://www.google.com"</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">Screenshot</span><span style="font-family: Consolas; font-size: 9.5pt;"> screenshot = ((<span style="color: #2b91af;">ITakesScreenshot</span>) webDriver).GetScreenshot();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span>screenshot.SaveAsFile(<span style="color: #a31515;">"d:\\ScreenShot.png"</span>,System.Drawing.Imaging.<span style="color: #2b91af;">ImageFormat</span>.Png);</span></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://3.bp.blogspot.com/-3lMrKGzuK3E/Tx_IRTdJoyI/AAAAAAAAA0w/JaXGDr5V3ao/s1600/ScreenShot.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" gda="true" height="320" src="http://3.bp.blogspot.com/-3lMrKGzuK3E/Tx_IRTdJoyI/AAAAAAAAA0w/JaXGDr5V3ao/s320/ScreenShot.png" width="233" /></a></div>
</div>MD.JAWEDhttp://www.blogger.com/profile/07432832127158337660noreply@blogger.com0tag:blogger.com,1999:blog-6899501130582562843.post-67248388445686940892012-01-25T14:43:00.002+05:302012-01-25T14:43:24.826+05:30Wait for an element to load in selenium using C#<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">Sometimes while performing automation we have to wait for an element to load then only we can proceed to the next steps.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">To achieve this selenium has provided explicit wait and implicit wait.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">Here we will discuss about use of explicit wait .net using C#.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<b style="mso-bidi-font-weight: normal;"><u><span style="font-family: Calibri;">Using lambda Expression:</span></u></b></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Calibri;"><span style="mso-spacerun: yes;"> </span>Name space need to use to access </span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">WebDriverWait</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Using </span><span style="font-family: Consolas; font-size: 9.5pt;">OpenQA.Selenium.Support.UI</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Text;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> OpenQA.Selenium;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> OpenQA.Selenium.IE;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: green; font-family: Consolas; font-size: 9.5pt;">//add this name space to access WebDriverWait</span><span style="font-family: Consolas; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> OpenQA.Selenium.Support.UI;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">namespace</span><span style="font-family: Consolas; font-size: 9.5pt;"> AutomationUsingSelenium</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> capabilitiesInternet = <span style="color: blue;">new</span> OpenQA.Selenium.Remote.<span style="color: #2b91af;">DesiredCapabilities</span>();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>capabilitiesInternet.SetCapability(<span style="color: #a31515;">"ignoreProtectedModeSettings"</span>, <span style="color: blue;">true</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">IWebDriver</span> webDriver = <span style="color: blue;">new</span> <span style="color: #2b91af;">InternetExplorerDriver</span>(capabilitiesInternet);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>webDriver.Navigate().GoToUrl(<span style="color: #a31515;">"http://www.google.com"</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">IWebElement</span> query = webDriver.FindElement(<span style="color: #2b91af;">By</span>.Name(<span style="color: #a31515;">"q"</span>));</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>query.SendKeys(<span style="color: #a31515;">"http://seleniumdotnet.blogspot.com"</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>OpenQA.Selenium.Support.UI.<span style="color: #2b91af;">WebDriverWait</span> wait = <span style="color: blue;">new</span> OpenQA.Selenium.Support.UI.<span style="color: #2b91af;">WebDriverWait</span>(webDriver, <span style="color: #2b91af;">TimeSpan</span>.FromSeconds(10));</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"Page title is: "</span>+webDriver.Title);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">//using lambda expression</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>wait.Until(d => d.FindElement(<span style="color: #2b91af;">By</span>.Id(<span style="color: #a31515;">"ab_name"</span>)));<span style="color: #00b050;">//make sure that Search div appear on google</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">Screenshot</span> screenshot = ((<span style="color: #2b91af;">ITakesScreenshot</span>) webDriver).GetScreenshot();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>screenshot.SaveAsFile(<span style="color: #a31515;">"d:\\ScreenShot.png"</span>,System.Drawing.Imaging.<span style="color: #2b91af;">ImageFormat</span>.Png);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>webDriver.Quit();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">Console</span>.ReadLine();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">}</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<br />
<b style="mso-bidi-font-weight: normal;"><u><span style="font-family: Calibri;">Using Anonymous Method:</span></u></b></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Collections.Generic;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Linq;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Text;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> OpenQA.Selenium;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> OpenQA.Selenium.IE;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: green; font-family: Consolas; font-size: 9.5pt;">//add this name space to access WebDriverWait</span><span style="font-family: Consolas; font-size: 9.5pt;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> OpenQA.Selenium.Support.UI;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">namespace</span><span style="font-family: Consolas; font-size: 9.5pt;"> AutomationUsingSelenium</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> capabilitiesInternet = <span style="color: blue;">new</span> OpenQA.Selenium.Remote.<span style="color: #2b91af;">DesiredCapabilities</span>();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>capabilitiesInternet.SetCapability(<span style="color: #a31515;">"ignoreProtectedModeSettings"</span>, <span style="color: blue;">true</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">IWebDriver</span> webDriver = <span style="color: blue;">new</span> <span style="color: #2b91af;">InternetExplorerDriver</span>(capabilitiesInternet);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>webDriver.Navigate().GoToUrl(<span style="color: #a31515;">"http://www.google.com"</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">IWebElement</span> query = webDriver.FindElement(<span style="color: #2b91af;">By</span>.Name(<span style="color: #a31515;">"q"</span>));</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span>query.SendKeys(<span style="color: #a31515;">"http://seleniumdotnet.blogspot.com"</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>OpenQA.Selenium.Support.UI.<span style="color: #2b91af;">WebDriverWait</span> wait = <span style="color: blue;">new</span> OpenQA.Selenium.Support.UI.<span style="color: #2b91af;">WebDriverWait</span>(webDriver, <span style="color: #2b91af;">TimeSpan</span>.FromSeconds(10));</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"Page title is: "</span>+webDriver.Title);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">//using Anonymous method</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>wait.Until(<span style="color: blue;">delegate</span>(<span style="color: #2b91af;">IWebDriver</span> d) { <span style="color: blue;">return</span> d.FindElement(<span style="color: #2b91af;">By</span>.Id(<span style="color: #a31515;">"ab_name"</span>)); });</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">Screenshot</span> screenshot = ((<span style="color: #2b91af;">ITakesScreenshot</span>) webDriver).GetScreenshot();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span>screenshot.SaveAsFile(<span style="color: #a31515;">"d:\\ScreenShot.png"</span>,System.Drawing.Imaging.<span style="color: #2b91af;">ImageFormat</span>.Png);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>webDriver.Quit();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">Console</span>.ReadLine();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">}</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<br /></div>
</div>MD.JAWEDhttp://www.blogger.com/profile/07432832127158337660noreply@blogger.com2tag:blogger.com,1999:blog-6899501130582562843.post-83783113729558491062012-01-25T12:26:00.000+05:302012-01-25T12:28:31.781+05:30InternetExplorerDriver() issue by selenium in IE<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">While running your automation code in selenium using C#. </span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">Then, most probably chances are that you will encounter the exception as <span style="color: #990000;">“</span></span><span style="color: #990000; font-family: Calibri;">Unexpected error launching Internet Explorer. Protected Mode must be set to the same value (enabled or disabled) for all zones. (NoSuchDriver)</span><span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;"><span style="color: #990000;">”.</span> And below is the screen sot for the same.</span></div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="http://4.bp.blogspot.com/-LMhB5LUtfwY/Tx-nS0o0jNI/AAAAAAAAA0o/L6xaYDFORn0/s1600/InternetErrorDetails.PNG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" gda="true" height="195" src="http://4.bp.blogspot.com/-LMhB5LUtfwY/Tx-nS0o0jNI/AAAAAAAAA0o/L6xaYDFORn0/s640/InternetErrorDetails.PNG" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">InvalidOperationException in IE</td></tr>
</tbody></table>
<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">The cause of this issue is due to </span><span style="color: black; font-family: "Arial", "sans-serif"; font-size: 10pt; line-height: 115%;">different security level and the ability to enable or disable Protected Mode. The error message is trying to tell you that Protected Mode must either be disabled or enabled for <strong><span style="font-family: "Arial", "sans-serif";">all</span></strong> zones because of a limitation in Selenium's </span><span style="background: #eeeeee; color: black; font-family: Consolas; font-size: 10pt; line-height: 115%;">InternetExplorerDriver.</span></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">To resolve this issue you need to just add 2 extra lines of code.</span><br />
<span style="font-family: Calibri;"><div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> capabilitiesInternet = <span style="color: blue;">new</span> OpenQA.Selenium.Remote.<span style="color: #2b91af;">DesiredCapabilities</span>();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>capabilitiesInternet.SetCapability(<span style="color: #a31515;">"ignoreProtectedModeSettings"</span>, <span style="color: blue;">true</span>);</span></div>
<br />
The Whole Code would look like this:</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Collections.Generic;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Linq;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Text;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> OpenQA.Selenium;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> OpenQA.Selenium.IE;</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">namespace</span><span style="font-family: Consolas; font-size: 9.5pt;"> AutomationUsingSelenium</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>{</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">var</span> capabilitiesInternet = <span style="color: blue;">new</span> OpenQA.Selenium.Remote.<span style="color: #2b91af;">DesiredCapabilities</span>();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>capabilitiesInternet.SetCapability(<span style="color: #a31515;">"ignoreProtectedModeSettings"</span>, <span style="color: blue;">true</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">IWebDriver</span> webDriver = <span style="color: blue;">new</span> <span style="color: #2b91af;">InternetExplorerDriver</span>(capabilitiesInternet);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>webDriver.Navigate().GoToUrl(<span style="color: #a31515;">"http://www.google.com"</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">IWebElement</span> query = webDriver.FindElement(<span style="color: #2b91af;">By</span>.Name(<span style="color: #a31515;">"q"</span>));</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>query.SendKeys(<span style="color: #a31515;">"http://jawedm.blogspot.com"</span>);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">"Page title is: "</span>+webDriver.Title);</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>webDriver.Quit();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">Console</span>.ReadLine();</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<span style="font-family: Consolas; font-size: 9.5pt;">}</span></div>
<div class="MsoNormal" style="line-height: normal; margin: 0in 0in 0pt; mso-layout-grid-align: none;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
<span style="font-family: Calibri;">Hope this would be useful for you.</span></div>
<span style="font-family: Calibri;"></span>Thanks, <br />
Md. jawed<br />
<div class="MsoNormal" style="margin: 0in 0in 10pt;">
Keep looking for this space to get different types of automation solutions using Selenium in .Net.</div>
</div>MD.JAWEDhttp://www.blogger.com/profile/07432832127158337660noreply@blogger.com2