<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5908592790614078397</id><updated>2024-10-09T18:09:33.052+05:30</updated><category term="Selenium WebDriver"/><category term="Selenium Web Driver"/><category term="select an item in listbox using Selenium"/><category term="Element should have been select but was input"/><category term="Ext JS Combobox"/><category term="How to read and write content from/to a text file"/><category term="How to retrieve Web table using selenium"/><category term="Look an element with Text"/><category term="Retrieve a cell value from a web table"/><category term="Retrieve a cell value from a webtable"/><category term="Sanpshot"/><category term="Switch between windows using Selenium WebDriver"/><category term="Synchronization in Selenium"/><category term="Take a snapshot using Web Driver"/><category term="Waits in Selenium"/><category term="Web Table"/><category term="Web Table using Selenium WebDriver"/><category term="right click and choose an option"/><category term="select an item from listbox using selenium web driver"/><title type='text'>Watch Selenium WebDriver videos in my blog seleniumwebdrivervideos.blogspot.com</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://seleniumwebdrivertips.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anem Udaya Kumar</name><uri>http://www.blogger.com/profile/13520163460208912903</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMiIKj5yEcjW61uPMzj2q4Qkeny9Tw0tJZKjLqe_Mk6tAnGC_IespIB4uhv9wrUv-2CSOA5nPwlFwDZ9y8IFd8cI0BQCwHngrf3Ah-iPvuTt3YfCVCLuVIDYT3Qtyw/s220/DSC00987.JPG.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>16</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5908592790614078397.post-5529607062625578917</id><published>2013-09-14T18:25:00.003+05:30</published><updated>2013-09-14T18:25:41.913+05:30</updated><title type='text'></title><content type='html'>&lt;ul&gt;
&lt;h2&gt;
&lt;li&gt;Selenium WebDriver Other Concepts&lt;/li&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=3vxBBlvxcKE&quot; target=&quot;_blank&quot;&gt;Difference Between WebDriver.close and WebDriver.quit&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;</content><link rel='replies' type='application/atom+xml' href='http://seleniumwebdrivertips.blogspot.com/feeds/5529607062625578917/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/09/selenium-webdriver-other-concepts.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/5529607062625578917'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/5529607062625578917'/><link rel='alternate' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/09/selenium-webdriver-other-concepts.html' title=''/><author><name>Anem Udaya Kumar</name><uri>http://www.blogger.com/profile/13520163460208912903</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMiIKj5yEcjW61uPMzj2q4Qkeny9Tw0tJZKjLqe_Mk6tAnGC_IespIB4uhv9wrUv-2CSOA5nPwlFwDZ9y8IFd8cI0BQCwHngrf3Ah-iPvuTt3YfCVCLuVIDYT3Qtyw/s220/DSC00987.JPG.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5908592790614078397.post-5081249076183781191</id><published>2013-04-17T08:46:00.004+05:30</published><updated>2013-04-17T08:46:45.770+05:30</updated><title type='text'>What is the difference between WebDriver.close() and WebDriver.quit()</title><content type='html'>&lt;b&gt;WebDriver.close() method closes the current window.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
See the below example, here it opens the new link in a different window and upon executing the close() method, it closes the parent window and leaving the new window open.&lt;br /&gt;
&lt;br /&gt;
WebDriver driver=new FirefoxDriver();&lt;br /&gt;
driver.get(&quot;http://google.com&quot;);&lt;br /&gt;
driver.manage().window().maximize();&lt;br /&gt;
WebElement oWE=driver.findElement(By.linkText(&quot;About Google&quot;));&lt;br /&gt;Actions oAction=new Actions(driver);&lt;br /&gt;oAction.moveToElement(oWE);&lt;br /&gt;oAction.contextClick(oWE).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).build().perform();&lt;br /&gt;driver.close();&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Whereas, WebDriver.quit() method quits the driver, and closing every associated window.&lt;/b&gt;&lt;br /&gt;
In the above example, if you use driver.quit() in place of close , then first opens &quot;google&quot; page and then open the &quot;about google&quot; in new window and closes both the windows.</content><link rel='replies' type='application/atom+xml' href='http://seleniumwebdrivertips.blogspot.com/feeds/5081249076183781191/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/04/what-is-difference-between.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/5081249076183781191'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/5081249076183781191'/><link rel='alternate' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/04/what-is-difference-between.html' title='What is the difference between WebDriver.close() and WebDriver.quit()'/><author><name>Anem Udaya Kumar</name><uri>http://www.blogger.com/profile/13520163460208912903</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMiIKj5yEcjW61uPMzj2q4Qkeny9Tw0tJZKjLqe_Mk6tAnGC_IespIB4uhv9wrUv-2CSOA5nPwlFwDZ9y8IFd8cI0BQCwHngrf3Ah-iPvuTt3YfCVCLuVIDYT3Qtyw/s220/DSC00987.JPG.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5908592790614078397.post-7105288691147883309</id><published>2013-04-16T23:20:00.001+05:30</published><updated>2013-04-17T08:49:01.459+05:30</updated><title type='text'>How to check the object existance</title><content type='html'>Here in the below code, i am checking for an object existence.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; //Max_TimeOut variable holds the time in seconds for the maximum time to wait before the control flows to NoSuchElementException block.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; int Max_TimeOut=60;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public boolean isObjExists(WebDriver driver,By locator)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //I am putting the code in try catch because if the object does not exist, it throws exception.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //Before throwing exception, it will wait for the Max_timeout specified&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; WebDriverWait wait=new WebDriverWait(driver,Max_TimeOut);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; wait.until(ExpectedConditions.elementToBeClickable(locator));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //If the element found, then it returns true&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return true;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; catch(NoSuchElementException exception)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //If the element is not found, then it returns false&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return false;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
This function can be invoked in like below:&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; By locator=By.name(&quot;Email&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(obj.isObjExists(driver, locator))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Reporter.log(&quot;Object exists&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; WebElement uNameElement=driver.findElement(locator);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; uNameElement.sendKeys(&quot;abcd&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Reporter.log(&quot;Object does not exist&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }</content><link rel='replies' type='application/atom+xml' href='http://seleniumwebdrivertips.blogspot.com/feeds/7105288691147883309/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/04/how-to-check-object-existance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/7105288691147883309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/7105288691147883309'/><link rel='alternate' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/04/how-to-check-object-existance.html' title='How to check the object existance'/><author><name>Anem Udaya Kumar</name><uri>http://www.blogger.com/profile/13520163460208912903</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMiIKj5yEcjW61uPMzj2q4Qkeny9Tw0tJZKjLqe_Mk6tAnGC_IespIB4uhv9wrUv-2CSOA5nPwlFwDZ9y8IFd8cI0BQCwHngrf3Ah-iPvuTt3YfCVCLuVIDYT3Qtyw/s220/DSC00987.JPG.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5908592790614078397.post-6933020023957649406</id><published>2013-03-18T16:55:00.000+05:30</published><updated>2013-03-18T16:55:18.575+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Element should have been select but was input"/><category scheme="http://www.blogger.com/atom/ns#" term="Ext JS Combobox"/><title type='text'>How to choose Ext JS Combo values using Selenium WebDriver</title><content type='html'>When we see Ext JS Combo box, it looks like a ordinary combo box and when we try&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;div align=&quot;left&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;left&quot;&gt;
Select oSel=&lt;/div&gt;
&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; Select(oCategoryItems);&lt;/span&gt;&lt;div align=&quot;left&quot;&gt;
&lt;/div&gt;
List&amp;lt;WebElement&amp;gt; oListItems=oSel.getOptions();&lt;br /&gt;
&lt;br /&gt;
It throws an error message saying, &lt;br /&gt;
&lt;strong&gt;&lt;span style=&quot;color: red;&quot;&gt;Element should have been &quot;select&quot; but was &quot;input&quot;&lt;/span&gt;&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
The reason being Ext JS combo box are not just combo boxes, they combination of controls like,&lt;br /&gt;
&amp;lt;Input&amp;gt; and &amp;lt;Image&amp;gt; or &amp;lt;em&amp;gt;&lt;br /&gt;
&amp;lt;input&amp;gt; and &amp;lt;Select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see the sample combo box object in Naukri.com website, which is attached&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPzr4SQ0Z01ZTEfa5t5Kf3tjCwxprrP1LK10wO5ErIbgJy0-akwQ9CkS_B_AyH_nI_Yv8SgwtrRhYxn5n2s5xZ1F3S07mGxGDuPZPQzXKge1APsCKHmZMW_mcMM3jRGWyp7hdYv0rcZ_Rj/s1600/ComboBox.JPG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;198&quot; psa=&quot;true&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPzr4SQ0Z01ZTEfa5t5Kf3tjCwxprrP1LK10wO5ErIbgJy0-akwQ9CkS_B_AyH_nI_Yv8SgwtrRhYxn5n2s5xZ1F3S07mGxGDuPZPQzXKge1APsCKHmZMW_mcMM3jRGWyp7hdYv0rcZ_Rj/s320/ComboBox.JPG&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
So inorder to select these items, first we need to click on the Input object and then select the value.&lt;br /&gt;
&lt;br /&gt;
Following is the code for printing out all the values, you can use whatever function you want after clicking the object.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;div align=&quot;left&quot;&gt;
　&lt;/div&gt;
&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;div align=&quot;left&quot;&gt;
import&lt;/div&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; java.util.List;&lt;/span&gt;&lt;div align=&quot;left&quot;&gt;
&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;div align=&quot;left&quot;&gt;
import&lt;/div&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; org.openqa.selenium.By;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;div align=&quot;left&quot;&gt;
import&lt;/div&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; org.openqa.selenium.WebDriver;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;div align=&quot;left&quot;&gt;
import&lt;/div&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; org.openqa.selenium.WebElement;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;div align=&quot;left&quot;&gt;
import&lt;/div&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; org.openqa.selenium.firefox.FirefoxDriver;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;div align=&quot;left&quot;&gt;
import&lt;/div&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; org.openqa.selenium.support.ui.Select;&lt;/span&gt;&lt;div align=&quot;left&quot;&gt;
&lt;/div&gt;
&lt;div align=&quot;left&quot;&gt;
　&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;div align=&quot;left&quot;&gt;
public&lt;/div&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;class&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; PrintListBoxValues &lt;/span&gt;&lt;div align=&quot;left&quot;&gt;
{&lt;/div&gt;
&lt;div align=&quot;left&quot;&gt;
&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;public&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;static&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;void&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; main(String[] args) &lt;/span&gt;&lt;div align=&quot;left&quot;&gt;
{&lt;/div&gt;
&lt;div align=&quot;left&quot;&gt;
WebDriver driver=&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; FirefoxDriver();&lt;/span&gt;&lt;div align=&quot;left&quot;&gt;
driver.get(&lt;/div&gt;
&lt;span style=&quot;color: #2a00ff; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #2a00ff; font-size: x-small;&quot;&gt;&quot;http://www.naukri.com/&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;);&lt;/span&gt;&lt;div align=&quot;left&quot;&gt;
&lt;/div&gt;
&lt;div align=&quot;left&quot;&gt;
WebElement oCategory=driver.findElement(By.&lt;i&gt;id&lt;/i&gt;(&lt;/div&gt;
&lt;span style=&quot;color: #2a00ff; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #2a00ff; font-size: x-small;&quot;&gt;&quot;farea&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;));&lt;/span&gt;&lt;div align=&quot;left&quot;&gt;
oCategory.click();&lt;/div&gt;
&lt;div align=&quot;left&quot;&gt;
&lt;/div&gt;
&lt;div align=&quot;left&quot;&gt;
WebElement oCategoryItems=driver.findElement(By.&lt;i&gt;id&lt;/i&gt;(&lt;/div&gt;
&lt;span style=&quot;color: #2a00ff; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #2a00ff; font-size: x-small;&quot;&gt;&quot;fareaSL&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;));&lt;/span&gt;&lt;div align=&quot;left&quot;&gt;
&lt;/div&gt;
&lt;div align=&quot;left&quot;&gt;
Select oSel=&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; Select(oCategoryItems);&lt;/span&gt;&lt;div align=&quot;left&quot;&gt;
&lt;/div&gt;
&lt;div align=&quot;left&quot;&gt;
List&amp;lt;WebElement&amp;gt; oListItems=oSel.getOptions();&lt;/div&gt;
&lt;div align=&quot;left&quot;&gt;
&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;for&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;(&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #7f0055; font-size: x-small;&quot;&gt;int&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt; i=1;i&amp;lt;=oListItems.size()-1;i++)&lt;/span&gt;&lt;div align=&quot;left&quot;&gt;
{&lt;/div&gt;
&lt;div align=&quot;left&quot;&gt;
System.&lt;/div&gt;
&lt;i&gt;&lt;span style=&quot;color: #0000c0; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #0000c0; font-size: x-small;&quot;&gt;out&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;.println(oListItems.get(i).getText());&lt;/span&gt;&lt;div align=&quot;left&quot;&gt;
}&lt;/div&gt;
&lt;div align=&quot;left&quot;&gt;
}&lt;/div&gt;
}&lt;br /&gt;
&lt;br /&gt;
</content><link rel='replies' type='application/atom+xml' href='http://seleniumwebdrivertips.blogspot.com/feeds/6933020023957649406/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/03/how-to-choose-ext-js-combo-values-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/6933020023957649406'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/6933020023957649406'/><link rel='alternate' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/03/how-to-choose-ext-js-combo-values-using.html' title='How to choose Ext JS Combo values using Selenium WebDriver'/><author><name>Anem Udaya Kumar</name><uri>http://www.blogger.com/profile/13520163460208912903</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMiIKj5yEcjW61uPMzj2q4Qkeny9Tw0tJZKjLqe_Mk6tAnGC_IespIB4uhv9wrUv-2CSOA5nPwlFwDZ9y8IFd8cI0BQCwHngrf3Ah-iPvuTt3YfCVCLuVIDYT3Qtyw/s220/DSC00987.JPG.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPzr4SQ0Z01ZTEfa5t5Kf3tjCwxprrP1LK10wO5ErIbgJy0-akwQ9CkS_B_AyH_nI_Yv8SgwtrRhYxn5n2s5xZ1F3S07mGxGDuPZPQzXKge1APsCKHmZMW_mcMM3jRGWyp7hdYv0rcZ_Rj/s72-c/ComboBox.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5908592790614078397.post-6148770162301794316</id><published>2013-03-17T12:41:00.000+05:30</published><updated>2013-03-17T12:41:48.506+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Switch between windows using Selenium WebDriver"/><title type='text'>How to switch between different windows using Selenium WebDriver</title><content type='html'>Inorder to switch between Windows we should be knowing the window handlers and traverse between windows.&lt;br /&gt;
&lt;br /&gt;
For that i am opening the link in a new window using clicking down button, after that moving to the specified window. &lt;br /&gt;
&lt;br /&gt;
Here is the code:&lt;br /&gt;
import java.util.Set;&lt;br /&gt;&lt;br /&gt;import org.openqa.selenium.By;&lt;br /&gt;import org.openqa.selenium.Keys;&lt;br /&gt;import org.openqa.selenium.WebDriver;&lt;br /&gt;import org.openqa.selenium.WebElement;&lt;br /&gt;import org.openqa.selenium.firefox.FirefoxDriver;&lt;br /&gt;import org.openqa.selenium.interactions.Actions;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class MoveBetweenTabs &lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String[] args) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; WebDriver driver=new FirefoxDriver();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; driver.navigate().to(&quot;http://www.google.com&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; driver.manage().window().maximize();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; WebElement oWE=driver.findElement(By.linkText(&quot;About Google&quot;));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Actions oAction=new Actions(driver);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; oAction.moveToElement(oWE);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; oAction.contextClick(oWE).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).build().perform();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Set&amp;lt;String&amp;gt; sHandlers= driver.getWindowHandles();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for(String sHandler:sHandlers)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(driver.switchTo().window(sHandler).getTitle().equals(&quot;Google&quot;))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; driver.switchTo().window(sHandler);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; WebElement oWE1=driver.findElement(By.linkText(&quot;+Google&quot;));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; oWE1.click();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}</content><link rel='replies' type='application/atom+xml' href='http://seleniumwebdrivertips.blogspot.com/feeds/6148770162301794316/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/03/how-to-switch-between-different-windows.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/6148770162301794316'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/6148770162301794316'/><link rel='alternate' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/03/how-to-switch-between-different-windows.html' title='How to switch between different windows using Selenium WebDriver'/><author><name>Anem Udaya Kumar</name><uri>http://www.blogger.com/profile/13520163460208912903</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMiIKj5yEcjW61uPMzj2q4Qkeny9Tw0tJZKjLqe_Mk6tAnGC_IespIB4uhv9wrUv-2CSOA5nPwlFwDZ9y8IFd8cI0BQCwHngrf3Ah-iPvuTt3YfCVCLuVIDYT3Qtyw/s220/DSC00987.JPG.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5908592790614078397.post-2668154252174048632</id><published>2013-03-17T10:57:00.000+05:30</published><updated>2013-03-17T10:57:00.928+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="right click and choose an option"/><title type='text'>How to right click and choose an option using Selenium WebDriver</title><content type='html'>There is no direct way to choose an option after right clicking using Selenium WebDriver.&lt;br /&gt;
&lt;br /&gt;
For Ex: what i mean here is say you open google.com&lt;br /&gt;
and then right click on &quot;About Google&quot; and have to choose &quot;Open Link in new Tab&quot;&lt;br /&gt;
&lt;br /&gt;
In Selenium WebDriver there is no direct way to do this.&lt;br /&gt;
&lt;br /&gt;
The work around is clicking {DOWN} button. But there is a disadvantage in this approach, suppose if your options dynamically change then this approach wont work.&lt;br /&gt;
&lt;br /&gt;
Here is the sample code for the above approach:&lt;br /&gt;
&lt;br /&gt;
import org.openqa.selenium.By;&lt;br /&gt;import org.openqa.selenium.Keys;&lt;br /&gt;import org.openqa.selenium.WebDriver;&lt;br /&gt;import org.openqa.selenium.WebElement;&lt;br /&gt;import org.openqa.selenium.firefox.FirefoxDriver;&lt;br /&gt;import org.openqa.selenium.interactions.Actions;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class RightClickAndChooseAnOption &lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String[] args) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; WebDriver driver=new FirefoxDriver();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; driver.navigate().to(&quot;http://www.google.com&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; driver.manage().window().maximize();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; WebElement oWE=driver.findElement(By.linkText(&quot;About Google&quot;));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Actions oAction=new Actions(driver);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; oAction.moveToElement(oWE);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; oAction.contextClick(oWE).sendKeys(Keys.ARROW_DOWN).sendKeys(Keys.ENTER).build().perform();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;}</content><link rel='replies' type='application/atom+xml' href='http://seleniumwebdrivertips.blogspot.com/feeds/2668154252174048632/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/03/how-to-right-click-and-choose-option.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/2668154252174048632'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/2668154252174048632'/><link rel='alternate' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/03/how-to-right-click-and-choose-option.html' title='How to right click and choose an option using Selenium WebDriver'/><author><name>Anem Udaya Kumar</name><uri>http://www.blogger.com/profile/13520163460208912903</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMiIKj5yEcjW61uPMzj2q4Qkeny9Tw0tJZKjLqe_Mk6tAnGC_IespIB4uhv9wrUv-2CSOA5nPwlFwDZ9y8IFd8cI0BQCwHngrf3Ah-iPvuTt3YfCVCLuVIDYT3Qtyw/s220/DSC00987.JPG.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5908592790614078397.post-8665943600958248354</id><published>2013-02-13T00:14:00.000+05:30</published><updated>2013-02-13T00:24:43.685+05:30</updated><title type='text'>How to execute JavaScript using Selenium WebDriver</title><content type='html'>&lt;br /&gt;
With Java Script we can access the DOM Properties. By doing so we can get the properties values of those objects.&lt;br /&gt;
&lt;br /&gt;
Say i have a Div or a Span control like below:&lt;br /&gt;
&amp;lt;Div id=&quot;SampleDiv1&quot;&amp;gt;I am in Div&amp;lt;/Div&amp;gt; or&lt;br /&gt;
&amp;lt;Span id=&quot;SampleSpan1&quot;&amp;gt;I am in Span&amp;lt;/Div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here we have two solutions to get the value of the objects.&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Solution 1: Use the getAttribute method.&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
This method is described in below location:&lt;br /&gt;
&lt;a href=&quot;http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebElement.html#getAttribute%28java.lang.String%29&quot;&gt;http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebElement.html#getAttribute%28java.lang.String%29&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
So for ex above, we can use like:&lt;br /&gt;
String sReturnText=driver.findElement(By.id(&quot;SampleSpan1&quot;)).getAttribute(&quot;innerHTML&quot;);&lt;br /&gt;
System.out.println(sReturnText);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Because in the above example we are trying to get text from the control we can directly use getText method like below:&lt;br /&gt;
String sReturnText=driver.findElement(By.id(&quot;SampleSpan1&quot;)).getText();&lt;br /&gt;
System.out.println(sReturnText);&lt;br /&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Solution 2: We can get the DOM properties be JavaScript&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
There might be situations you will be needing to run the JavaScript in your automation. To do this/cover the example follow below steps:&lt;br /&gt;
String sJScript = &quot;return document.getElementById(&#39;SampleSpan1&#39;).innerHTML;&quot;;&lt;br /&gt;
String sReturnText = (String) ((JavascriptExecutor) driver).executeScript(sJScript);&lt;br /&gt;
&amp;nbsp;System.out.println(sReturnText);</content><link rel='replies' type='application/atom+xml' href='http://seleniumwebdrivertips.blogspot.com/feeds/8665943600958248354/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/02/how-to-execute-javascript-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/8665943600958248354'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/8665943600958248354'/><link rel='alternate' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/02/how-to-execute-javascript-using.html' title='How to execute JavaScript using Selenium WebDriver'/><author><name>Anem Udaya Kumar</name><uri>http://www.blogger.com/profile/13520163460208912903</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMiIKj5yEcjW61uPMzj2q4Qkeny9Tw0tJZKjLqe_Mk6tAnGC_IespIB4uhv9wrUv-2CSOA5nPwlFwDZ9y8IFd8cI0BQCwHngrf3Ah-iPvuTt3YfCVCLuVIDYT3Qtyw/s220/DSC00987.JPG.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5908592790614078397.post-792761822949506172</id><published>2013-02-12T18:06:00.002+05:30</published><updated>2013-02-12T18:06:48.497+05:30</updated><title type='text'>How to close a dialog box using Selenium WebDriver</title><content type='html'>There might be places, when you click on an object a dialog will pop up asking your conformation. How to close those kind of alert messages?&lt;br /&gt;
&lt;br /&gt;
The below code help you to close any such alert boxes.&lt;br /&gt;
&lt;br /&gt;
import org.openqa.selenium.Alert;&lt;br /&gt;import org.openqa.selenium.WebDriver;&lt;br /&gt;import org.openqa.selenium.firefox.FirefoxDriver;&lt;br /&gt;
public class PopupDialog &lt;br /&gt;{&lt;br /&gt;&amp;nbsp;public static void main(String[] args) &lt;br /&gt;&amp;nbsp;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;WebDriver driver=new FirefoxDriver();&lt;br /&gt;&amp;nbsp;&amp;nbsp;driver.get(&quot;&lt;a href=&quot;http://www.agoda.com/?ymsg=1&amp;amp;tick=634955861691&quot;&gt;http://www.agoda.com/?ymsg=1&amp;amp;tick=634955861691&lt;/a&gt;&quot;);&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;Alert alt=driver.switchTo().alert();&lt;br /&gt;&amp;nbsp;&amp;nbsp;alt.accept();&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;}</content><link rel='replies' type='application/atom+xml' href='http://seleniumwebdrivertips.blogspot.com/feeds/792761822949506172/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/02/how-to-close-dialog-box-using-selenium.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/792761822949506172'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/792761822949506172'/><link rel='alternate' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/02/how-to-close-dialog-box-using-selenium.html' title='How to close a dialog box using Selenium WebDriver'/><author><name>Anem Udaya Kumar</name><uri>http://www.blogger.com/profile/13520163460208912903</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMiIKj5yEcjW61uPMzj2q4Qkeny9Tw0tJZKjLqe_Mk6tAnGC_IespIB4uhv9wrUv-2CSOA5nPwlFwDZ9y8IFd8cI0BQCwHngrf3Ah-iPvuTt3YfCVCLuVIDYT3Qtyw/s220/DSC00987.JPG.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5908592790614078397.post-427724966547245131</id><published>2013-02-09T11:20:00.000+05:30</published><updated>2013-02-09T11:20:02.432+05:30</updated><title type='text'>How to work with Cookies in a web site using selenium webdriver</title><content type='html'>import java.util.Set;&lt;br /&gt;import org.openqa.selenium.Cookie;&lt;br /&gt;import org.openqa.selenium.WebDriver;&lt;br /&gt;import org.openqa.selenium.firefox.FirefoxDriver;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class FindAllCookiesInaWebSite &lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String[] args) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; WebDriver driver=new FirefoxDriver();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; driver.get(&quot;http://in.yahoo.com/&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Set&amp;lt;Cookie&amp;gt; cookies=driver.manage().getCookies();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //To find the number of cookies used by this site&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Number of cookies in this site &quot;+cookies.size());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for(Cookie cookie:cookies)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(cookie.getName()+&quot; &quot;+cookie.getValue());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //This will delete cookie By Name&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //driver.manage().deleteCookieNamed(cookie.getName());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //This will delete the cookie&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //driver.manage().deleteCookie(cookie);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //This will delete all cookies.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //driver.manage().deleteAllCookies();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://seleniumwebdrivertips.blogspot.com/feeds/427724966547245131/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/02/how-to-work-with-cookies-in-web-site.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/427724966547245131'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/427724966547245131'/><link rel='alternate' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2013/02/how-to-work-with-cookies-in-web-site.html' title='How to work with Cookies in a web site using selenium webdriver'/><author><name>Anem Udaya Kumar</name><uri>http://www.blogger.com/profile/13520163460208912903</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMiIKj5yEcjW61uPMzj2q4Qkeny9Tw0tJZKjLqe_Mk6tAnGC_IespIB4uhv9wrUv-2CSOA5nPwlFwDZ9y8IFd8cI0BQCwHngrf3Ah-iPvuTt3YfCVCLuVIDYT3Qtyw/s220/DSC00987.JPG.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5908592790614078397.post-5329554282305461739</id><published>2012-12-21T12:37:00.000+05:30</published><updated>2012-12-21T12:37:25.575+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Look an element with Text"/><title type='text'>How to click on a element with specific Text</title><content type='html'>How we will click on a element(Link/button/any element) with a specific Text.&lt;br /&gt;
&lt;br /&gt;
In the below example i open Yahoo Website and look for an element called &quot;Mail&quot;, if it found it clicks on the link else it reports Exception saying String not found.&lt;br /&gt;
&lt;br /&gt;
import org.openqa.selenium.By;&lt;br /&gt;import org.openqa.selenium.WebDriver;&lt;br /&gt;import org.openqa.selenium.firefox.FirefoxDriver;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class ClickLinkByText &lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String[] args) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String s_URL=&quot;http://www.yahoo.com&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String s_SearchLink=&quot;Mail&quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; WebDriver driver=new FirefoxDriver();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; driver.get(s_URL);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; try&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; driver.findElement(By.xpath(&quot;//*[@title=&#39;&quot;+s_SearchLink+&quot;&#39;]&quot;)).click();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; catch(Exception e)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(&quot;Searched string not found&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}</content><link rel='replies' type='application/atom+xml' href='http://seleniumwebdrivertips.blogspot.com/feeds/5329554282305461739/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2012/12/how-to-click-on-element-with-specific.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/5329554282305461739'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/5329554282305461739'/><link rel='alternate' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2012/12/how-to-click-on-element-with-specific.html' title='How to click on a element with specific Text'/><author><name>Anem Udaya Kumar</name><uri>http://www.blogger.com/profile/13520163460208912903</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMiIKj5yEcjW61uPMzj2q4Qkeny9Tw0tJZKjLqe_Mk6tAnGC_IespIB4uhv9wrUv-2CSOA5nPwlFwDZ9y8IFd8cI0BQCwHngrf3Ah-iPvuTt3YfCVCLuVIDYT3Qtyw/s220/DSC00987.JPG.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5908592790614078397.post-1381034525849300423</id><published>2012-11-28T17:36:00.000+05:30</published><updated>2012-11-28T17:39:03.978+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="How to read and write content from/to a text file"/><title type='text'>How to read and write content from/to a text file using Selenium WebDriver</title><content type='html'>There are many ways you can do this.If you wanted to read the content line by line level you can BufferReader/BufferWriter and the below script will helps you.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import java.io.*;&lt;br /&gt;
&lt;br /&gt;
public class FileHandling &lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String[] args) &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; File o_File1=new File(&quot;C:\\Input1.txt&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; File o_File2=new File(&quot;C:\\Input2.txt&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String line;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; try &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; BufferedReader o_br1=new BufferedReader(new FileReader(o_File1));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; BufferedWriter o_bw1=null;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(!o_File2.exists())&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; o_File2.createNewFile();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; o_bw1 = new&amp;nbsp; BufferedWriter(new FileWriter(o_File2) );&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; while((line=o_br1.readLine())!=null)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; o_bw1.write(line);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; o_bw1.close();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; o_br1.close();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (Exception e) &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; e.printStackTrace();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
}</content><link rel='replies' type='application/atom+xml' href='http://seleniumwebdrivertips.blogspot.com/feeds/1381034525849300423/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2012/11/how-to-read-and-write-content-fromto.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/1381034525849300423'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/1381034525849300423'/><link rel='alternate' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2012/11/how-to-read-and-write-content-fromto.html' title='How to read and write content from/to a text file using Selenium WebDriver'/><author><name>Anem Udaya Kumar</name><uri>http://www.blogger.com/profile/13520163460208912903</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMiIKj5yEcjW61uPMzj2q4Qkeny9Tw0tJZKjLqe_Mk6tAnGC_IespIB4uhv9wrUv-2CSOA5nPwlFwDZ9y8IFd8cI0BQCwHngrf3Ah-iPvuTt3YfCVCLuVIDYT3Qtyw/s220/DSC00987.JPG.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5908592790614078397.post-8196286299560571552</id><published>2012-10-26T16:10:00.001+05:30</published><updated>2012-10-26T16:10:55.713+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Selenium Web Driver"/><category scheme="http://www.blogger.com/atom/ns#" term="Selenium WebDriver"/><category scheme="http://www.blogger.com/atom/ns#" term="Synchronization in Selenium"/><category scheme="http://www.blogger.com/atom/ns#" term="Waits in Selenium"/><title type='text'>Synchronization or Waits in Selenium WebDriver</title><content type='html'>&lt;br /&gt;When our automation execution starts, then there should be fair communication between tool and application. &lt;br /&gt;What i mean here is if the tool is too fast of execution and the application/objects are not fully loaded/not ready by that time, then our automation test cases will fail. So the tool should wait(appropriate) till the objects are present/ready in the application, so that communication/synchronization happens between the tool and application so the chances of our test cases will pass.&lt;br /&gt;&lt;br /&gt;Synchronization or Waits can be done in two ways.&lt;br /&gt;1. Explicit Waits&lt;br /&gt;2. Implicit Waits&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Explicit Waits&lt;/b&gt;&lt;/u&gt;:&lt;br /&gt;This can be achieved in 2 ways.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;Thread.sleep&lt;/u&gt;: &lt;br /&gt;Thread.sleep waits the specified time irrespective of the object state.&lt;br /&gt;Ex: Thread.sleep(30000);&lt;br /&gt;Here the execution is halted for 30 Sec., even if the object you are looking exists in 10 sec. So here tool unnecessarily waits for 20 sec.&lt;br /&gt;Execution wont wait after 30 sec.s even if the object does not available, so the chances of your Test fails.&lt;br /&gt;&lt;br /&gt;&lt;u&gt;WebDriverWait&lt;/u&gt;: &lt;br /&gt;We can tell the tool to wait only till the Condition met. Once the condition is met, the tool proceed with the next step.&lt;br /&gt;This can be done with WebDriverWait in conjunction with ExpectedConditions Class. &lt;br /&gt;There are few methods supported in ExpectedConditions class to support synchronisation.&lt;br /&gt;Here is the example:&lt;br /&gt;WebDriverWait wait = new WebDriverWait(driver, 30);&lt;br /&gt;WebElement o_element = wait.until(ExpectedConditions.elementToBeClickable(By.id(&quot;Object Id&quot;)));&lt;br /&gt;&lt;br /&gt;Here the tool waits a maximum time of 30 Sec., if the object you are looking is displayed in 10 sec. then the execution proceeds with the next step afte 10 secs. rather than waiting for 30 secs.&lt;br /&gt;&lt;br /&gt;If you dont want to include any methods in ExpectedConditions class, then you can use below code:&lt;br /&gt;WebDriver driver = new FirefoxDriver();&lt;br /&gt;driver.get(&quot;Your URL&quot;);&lt;br /&gt;WebElement o_Element = (new WebDriverWait(driver, 30))&lt;br /&gt;&amp;nbsp; .until(new ExpectedCondition&amp;lt;WebElement&amp;gt;(){&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public WebElement apply(WebDriver d) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; return d.findElement(By.id(&quot;Object Id&quot;));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }});&lt;br /&gt;Here WebDriverWait by default calls the ExpectedCondition every 500 milliseconds until it returns successfully or wait for maximum of 30 sec.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;u&gt;&lt;b&gt;Implicit Waits&lt;/b&gt;&lt;/u&gt;:&lt;br /&gt;An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance.&lt;br /&gt;WebDriver driver = new FirefoxDriver();&lt;br /&gt;driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);&lt;br /&gt;driver.get(&quot;Your URL&quot;);&lt;br /&gt;WebElement o_Element = driver.findElement(By.id(&quot;Object Id&quot;));&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://seleniumwebdrivertips.blogspot.com/feeds/8196286299560571552/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2012/10/synchronization-or-waits-in-selenium.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/8196286299560571552'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/8196286299560571552'/><link rel='alternate' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2012/10/synchronization-or-waits-in-selenium.html' title='Synchronization or Waits in Selenium WebDriver'/><author><name>Anem Udaya Kumar</name><uri>http://www.blogger.com/profile/13520163460208912903</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMiIKj5yEcjW61uPMzj2q4Qkeny9Tw0tJZKjLqe_Mk6tAnGC_IespIB4uhv9wrUv-2CSOA5nPwlFwDZ9y8IFd8cI0BQCwHngrf3Ah-iPvuTt3YfCVCLuVIDYT3Qtyw/s220/DSC00987.JPG.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5908592790614078397.post-3356716655915788247</id><published>2012-10-26T13:49:00.000+05:30</published><updated>2012-10-26T13:49:02.370+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="How to retrieve Web table using selenium"/><category scheme="http://www.blogger.com/atom/ns#" term="Selenium Web Driver"/><category scheme="http://www.blogger.com/atom/ns#" term="Selenium WebDriver"/><category scheme="http://www.blogger.com/atom/ns#" term="Web Table"/><category scheme="http://www.blogger.com/atom/ns#" term="Web Table using Selenium WebDriver"/><title type='text'>How to retrieve web table content using Selenium WebDriver</title><content type='html'>There are many ways we can do this,&lt;br /&gt;
but in below example i am following &quot;tr&quot;,&quot;td&quot; approach.&lt;br /&gt;
&lt;br /&gt;
WebDriver driver=new FirefoxDriver();&lt;br /&gt;
driver.manage().window().maximize();&lt;br /&gt;driver.get(&quot;http://money.rediff.com/&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;WebElement element=driver.findElement(By.id(&quot;allpage_links&quot;));&lt;br /&gt;List&amp;lt;WebElement&amp;gt; rowCollection=element.findElements(By.xpath(&quot;//*[@id=&#39;allpage_links&#39;]/tbody/tr&quot;));&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;System.out.println(&quot;Numer of rows in this table: &quot;+rowCollection.size());&lt;br /&gt;//Here i_RowNum and i_ColNum, i am using to indicate Row and Column numbers. It may or may not be required in real-time Test Cases.&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;br /&gt;
int i_RowNum=1;&lt;br /&gt;for(WebElement rowElement:rowCollection)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; List&amp;lt;WebElement&amp;gt; colCollection=rowElement.findElements(By.xpath(&quot;td&quot;));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; int i_ColNum=1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; for(WebElement colElement:colCollection)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; System.out.println(&quot;Row &quot;+i_RowNum+&quot; Column &quot;+i_ColNum+&quot; Data &quot;+colElement.getText());&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; i_ColNum=i_ColNum+1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i_RowNum=i_RowNum+1;&lt;br /&gt;&amp;nbsp;}&lt;br /&gt;&amp;nbsp;driver.close();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://seleniumwebdrivertips.blogspot.com/feeds/3356716655915788247/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2012/10/how-to-retrieve-web-table-content-using_3772.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/3356716655915788247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/3356716655915788247'/><link rel='alternate' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2012/10/how-to-retrieve-web-table-content-using_3772.html' title='How to retrieve web table content using Selenium WebDriver'/><author><name>Anem Udaya Kumar</name><uri>http://www.blogger.com/profile/13520163460208912903</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMiIKj5yEcjW61uPMzj2q4Qkeny9Tw0tJZKjLqe_Mk6tAnGC_IespIB4uhv9wrUv-2CSOA5nPwlFwDZ9y8IFd8cI0BQCwHngrf3Ah-iPvuTt3YfCVCLuVIDYT3Qtyw/s220/DSC00987.JPG.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5908592790614078397.post-6058551877417773592</id><published>2012-10-26T11:52:00.000+05:30</published><updated>2012-10-26T11:52:06.204+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Retrieve a cell value from a web table"/><category scheme="http://www.blogger.com/atom/ns#" term="Retrieve a cell value from a webtable"/><category scheme="http://www.blogger.com/atom/ns#" term="select an item in listbox using Selenium"/><category scheme="http://www.blogger.com/atom/ns#" term="Selenium WebDriver"/><title type='text'>How to retrieve a specifec cell value from a web table using Selenium WebDriver</title><content type='html'>Here in this example i covering how to retrieve a specific cell value from Web Table using Selenium WebDriver:&lt;br /&gt;
&lt;br /&gt;
The below code works well if the Cell contains plain text than any other controls etc.&lt;br /&gt;
&lt;br /&gt;
int rownum,colnum;&lt;br /&gt;String s_xpath;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;WebDriver driver=new FirefoxDriver();&lt;br /&gt;driver.get(&quot;https://www.irctc.co.in/&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;rownum=2;&lt;br /&gt;colnum=1;&lt;br /&gt;//Here i am framing the xpath with rownum and colnum &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;s_xpath=&quot;//*[@id=&#39;tabslinks&#39;]/tbody/tr[&quot;+rownum+&quot;]/td[&quot;+colnum+&quot;]&quot;;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
//getText method retrieves the cell value.&lt;br /&gt;System.out.println(driver.findElement(By.xpath(s_xpath)).getText());</content><link rel='replies' type='application/atom+xml' href='http://seleniumwebdrivertips.blogspot.com/feeds/6058551877417773592/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2012/10/how-to-retrieve-specifec-cell-value.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/6058551877417773592'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/6058551877417773592'/><link rel='alternate' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2012/10/how-to-retrieve-specifec-cell-value.html' title='How to retrieve a specifec cell value from a web table using Selenium WebDriver'/><author><name>Anem Udaya Kumar</name><uri>http://www.blogger.com/profile/13520163460208912903</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMiIKj5yEcjW61uPMzj2q4Qkeny9Tw0tJZKjLqe_Mk6tAnGC_IespIB4uhv9wrUv-2CSOA5nPwlFwDZ9y8IFd8cI0BQCwHngrf3Ah-iPvuTt3YfCVCLuVIDYT3Qtyw/s220/DSC00987.JPG.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5908592790614078397.post-2841142762980919195</id><published>2012-10-25T17:13:00.000+05:30</published><updated>2012-10-26T11:53:23.210+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Sanpshot"/><category scheme="http://www.blogger.com/atom/ns#" term="Selenium Web Driver"/><category scheme="http://www.blogger.com/atom/ns#" term="Selenium WebDriver"/><category scheme="http://www.blogger.com/atom/ns#" term="Take a snapshot using Web Driver"/><title type='text'>How to take a screenshot of the window using Selenium WebDriver</title><content type='html'>Below code demonstrate about how to take a snapshot of the Desktop window using Selenium WebDriver:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import java.io.File;&lt;br /&gt;
import java.io.IOException;&lt;br /&gt;
import org.apache.commons.io.FileUtils;&lt;br /&gt;
import org.openqa.selenium.OutputType;&lt;br /&gt;
import org.openqa.selenium.TakesScreenshot;&lt;br /&gt;
import org.openqa.selenium.WebDriver;&lt;br /&gt;
import org.openqa.selenium.firefox.FirefoxDriver;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public class TakeAScreenShot &lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String[] args) &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; WebDriver driver = new FirefoxDriver();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String s_FilePath=&quot;c:\\screenshot.jpg&quot;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; driver.get(&quot;http://www.google.com/&quot;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; try &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; File srcFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //Once we have the screenshot in our file &#39;srcFile&#39; you can use all FileUtils methods like&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; FileUtils.copyFile(srcFile, new File(s_FilePath));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; } &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; catch (Exception e) &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; e.printStackTrace();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
}</content><link rel='replies' type='application/atom+xml' href='http://seleniumwebdrivertips.blogspot.com/feeds/2841142762980919195/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2012/10/how-to-take-screenshot-of-window-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/2841142762980919195'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/2841142762980919195'/><link rel='alternate' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2012/10/how-to-take-screenshot-of-window-using.html' title='How to take a screenshot of the window using Selenium WebDriver'/><author><name>Anem Udaya Kumar</name><uri>http://www.blogger.com/profile/13520163460208912903</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMiIKj5yEcjW61uPMzj2q4Qkeny9Tw0tJZKjLqe_Mk6tAnGC_IespIB4uhv9wrUv-2CSOA5nPwlFwDZ9y8IFd8cI0BQCwHngrf3Ah-iPvuTt3YfCVCLuVIDYT3Qtyw/s220/DSC00987.JPG.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5908592790614078397.post-4507339260959217888</id><published>2012-10-25T15:33:00.000+05:30</published><updated>2013-02-17T10:04:14.047+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="select an item from listbox using selenium web driver"/><category scheme="http://www.blogger.com/atom/ns#" term="select an item in listbox using Selenium"/><category scheme="http://www.blogger.com/atom/ns#" term="Selenium Web Driver"/><category scheme="http://www.blogger.com/atom/ns#" term="Selenium WebDriver"/><title type='text'>How to select an item in Listbox using Selenium Webdriver</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
There are many ways you can do this.&lt;br /&gt;
&lt;br /&gt;
Below are my best ways to select a list item from a listbox:&lt;br /&gt;
&lt;br /&gt;
Option 1:&lt;br /&gt;
//First find the Listbox element as WebElement.&lt;br /&gt;
WebElement o_Item= driver.findElement(By.id(&quot;uw_flight_origin_input_d&quot;));&lt;br /&gt;
//Then select the list item from the WebElement&lt;br /&gt;
o_Item.findElement(By.xpath(&quot;//option[contains(text(),&#39;&quot; + nameYouWant + &quot;&#39;)]&quot;)).click();&lt;br /&gt;
&lt;br /&gt;
Option 2:&lt;br /&gt;
Select menu = new Select(driver.findElement(By.id(&quot;uw_flight_origin_input_d&quot;)));
menu.selectByVisibleText(nameYouWant);&lt;br /&gt;
&lt;br /&gt;
A complete sample code is here:&lt;br /&gt;
import org.openqa.selenium.support.ui.Select;&lt;br /&gt;
WebDriver driver=new FirefoxDriver();&lt;br /&gt;
driver.get(&quot;http://www.expedia.co.in/&quot;);&lt;br /&gt;
String nameYouWant=&quot;Hyderabad&quot;;&lt;br /&gt;
WebElement o_Item= driver.findElement(By.id(&quot;uw_flight_origin_input_d&quot;));
o_Item.findElement(By.xpath(&quot;//option[contains(text(),&#39;&quot; + nameYouWant + &quot;&#39;)]&quot;)).click();&lt;br /&gt;
/*Select menu = new Select(driver.findElement(By.id(&quot;uw_flight_origin_input_d&quot;)));
menu.selectByVisibleText(nameYouWant);*/&lt;br /&gt;
&lt;br /&gt;
In the same way how to select a checkbox or radio button based on a value:&lt;br /&gt;
Here is a sample HTML code&amp;nbsp; for an application&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;lt;form&amp;gt;&lt;br /&gt;&amp;lt;Input type=&quot;radio&quot; name=&quot;sex&quot; value=&quot;male&quot;&amp;gt;Male&amp;lt;br&amp;gt;&lt;br /&gt;&amp;lt;Input type=&quot;radio&quot; name=&quot;sex&quot; value=&quot;female&quot;&amp;gt;Female&amp;lt;br&amp;gt;&lt;br /&gt;Likes&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; :&amp;lt;br&amp;gt;&lt;br /&gt;&amp;lt;input type=&quot;checkbox&quot; name=&quot;likes&quot; value=&quot;cars&quot;&amp;gt;Cars&amp;lt;br&amp;gt;&lt;br /&gt;&amp;lt;input type=&quot;checkbox&quot; name=&quot;likes&quot; value=&quot;bikes&quot;&amp;gt;Bikes&amp;lt;br&amp;gt;&lt;br /&gt;&amp;lt;input type=&quot;checkbox&quot; name=&quot;likes&quot; value=&quot;Movies&quot;&amp;gt;Movies&amp;lt;br&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt; &lt;br /&gt;
&lt;br /&gt;
WebDriver driver=new FirefoxDriver();&lt;br /&gt;driver.get(&quot;FilePath);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;driver.findElement(By.xpath(&quot;//input[@name=&#39;sex&#39; and @value=&#39;female&#39;]&quot;)).click();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;driver.findElement(By.xpath(&quot;//input[@name=&#39;likes&#39; and @value=&#39;Movies&#39;]&quot;)).click();</content><link rel='replies' type='application/atom+xml' href='http://seleniumwebdrivertips.blogspot.com/feeds/4507339260959217888/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2012/10/how-to-select-item-in-listbox-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/4507339260959217888'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5908592790614078397/posts/default/4507339260959217888'/><link rel='alternate' type='text/html' href='http://seleniumwebdrivertips.blogspot.com/2012/10/how-to-select-item-in-listbox-using.html' title='How to select an item in Listbox using Selenium Webdriver'/><author><name>Anem Udaya Kumar</name><uri>http://www.blogger.com/profile/13520163460208912903</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEyMiIKj5yEcjW61uPMzj2q4Qkeny9Tw0tJZKjLqe_Mk6tAnGC_IespIB4uhv9wrUv-2CSOA5nPwlFwDZ9y8IFd8cI0BQCwHngrf3Ah-iPvuTt3YfCVCLuVIDYT3Qtyw/s220/DSC00987.JPG.jpg'/></author><thr:total>0</thr:total></entry></feed>