<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>SeleniumExamples</title>
	
	<link>http://seleniumexamples.com/blog</link>
	<description>Examples and tips for Selenium</description>
	<lastBuildDate>Thu, 10 Mar 2011 15:29:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/seleniumexamples" /><feedburner:info uri="seleniumexamples" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:browserFriendly></feedburner:browserFriendly><item>
		<title>London Selenium Users Event #4</title>
		<link>http://seleniumexamples.com/blog/events/london-selenium-users-event-4/</link>
		<comments>http://seleniumexamples.com/blog/events/london-selenium-users-event-4/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 15:29:20 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Events]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=288</guid>
		<description><![CDATA[In a couple of weeks the 4th event of the London Selenium users meetup takes place. This time it will be hosted by Thoughtworks, and has a loose theme of extending on top of Selenium. I&#8217;m pleased to announce the following speakers, in addition to a talk from Google on mobile testing with Selenium. Andy [...]]]></description>
			<content:encoded><![CDATA[<p>In a couple of weeks the 4th event of the London Selenium users meetup takes place. This time it will be hosted by Thoughtworks, and has a loose theme of extending on top of Selenium. I&#8217;m pleased to announce the following speakers, in addition to a talk from Google on mobile testing with Selenium.</p>
<p><strong>Andy Kemp</strong> &#8211; Andy has been working in software for 15  years. The last 6 have been at  ThoughtWorks where he has worked as a  tester and project manager across  London, San Francisco and Sydney. His  latest role is Product Manager  for Twist. He has recently started  blogging at <a href="http://kyndainverse.com/" target="_blank">http://kyndainverse.com</a><strong></strong></p>
<p><strong>Samit Badle</strong> &#8211; Samit is a Selenium Committer and  author of several Selenium IDE plugins. He is a Oracle Certified Java  Programmer, Microsoft Certified Solution Developer and is also a ISEB  certified tester.<strong></strong></p>
<p><strong>Andy Smith</strong> &#8211; Andy has been building websites for over 10 years and runs <a href="http://canvasdemos.com/">CanvasDemos.com</a>, a repository for applications which use the HTML5 Canvas element.</p>
<p>The event is currently full, but <a href="http://www.meetup.com/seleniumlondon/events/16079171/">join the waiting list</a> if you&#8217;re interested in attending and if someone changes their RSVP you will be able to take their place.</p>
]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/events/london-selenium-users-event-4/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Selenium Conference 2011 – Survey</title>
		<link>http://seleniumexamples.com/blog/events/selenium-conference-2011-survey/</link>
		<comments>http://seleniumexamples.com/blog/events/selenium-conference-2011-survey/#comments</comments>
		<pubDate>Tue, 30 Nov 2010 02:39:38 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[selenium]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=284</guid>
		<description><![CDATA[The first ever Selenium is currently being planned for sometime in April next year. Get involved by responding to this short survey. Your responses will be used to help plan the conference.]]></description>
			<content:encoded><![CDATA[<p>The first ever Selenium is currently being planned for sometime in April next year. Get involved by responding to <a href="http://spreadsheets0.google.com/viewform?formkey=dGZIMjZSME5RTUVKNHdfeTBfeGlfUmc6MQ">this short survey</a>. Your responses will be used to help plan the conference.</p>
]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/events/selenium-conference-2011-survey/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Videos now online for ‘Advanced Test Automation with Firefox’</title>
		<link>http://seleniumexamples.com/blog/events/videos-now-online-for-advanced-test-automation-with-firefox/</link>
		<comments>http://seleniumexamples.com/blog/events/videos-now-online-for-advanced-test-automation-with-firefox/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 23:52:27 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[london]]></category>
		<category><![CDATA[meetup]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[selenium 2]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[webdriver]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=279</guid>
		<description><![CDATA[The videos from the third London Selenium users event are now available on the London Selenium YouTube channel: http://www.youtube.com/user/londonselenium/]]></description>
			<content:encoded><![CDATA[<p>The videos from the third London Selenium users event are now available on the London Selenium YouTube channel: <a href="http://www.youtube.com/user/londonselenium/">http://www.youtube.com/user/londonselenium/</a></p>
<p><object width="500" height="306"><param name="movie" value="http://www.youtube.com/v/AYJMct82YXg?fs=1&amp;hl=en_GB"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/AYJMct82YXg?fs=1&amp;hl=en_GB" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="306"></embed></object></p>
<p><object width="500" height="306"><param name="movie" value="http://www.youtube.com/v/HYSJUSI3_VU?fs=1&amp;hl=en_GB"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/HYSJUSI3_VU?fs=1&amp;hl=en_GB" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="500" height="306"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/events/videos-now-online-for-advanced-test-automation-with-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Meetup.com Attendance Lists</title>
		<link>http://seleniumexamples.com/blog/examples/meetup-com-attendance-lists/</link>
		<comments>http://seleniumexamples.com/blog/examples/meetup-com-attendance-lists/#comments</comments>
		<pubDate>Mon, 08 Nov 2010 11:53:55 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[meetup]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[selenium 2]]></category>
		<category><![CDATA[webdriver]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=274</guid>
		<description><![CDATA[For the recent London Selenium Users Meetup Event I was asked if I could provide the attendance list in a suitable format for creating labels for the guests when they arrive. Given the short timeframe I did this simply by highlighting the names on meetup.com, copying them, and pasting them into a simple text editor. [...]]]></description>
			<content:encoded><![CDATA[<p>For the recent London Selenium Users Meetup Event I was asked if I could provide the attendance list in a suitable format for creating labels for the guests when they arrive. Given the short timeframe I did this simply by highlighting the names on meetup.com, copying them, and pasting them into a simple text editor. I then quickly cleaned this up before sending the list on. Within a short while the list was out of date due to some members dropping out.</p>
<p>It did occur to me at the time that I could write a simple Selenium script, but I didn&#8217;t want to delay providing the list. Well I&#8217;ve now had some time to revisit this, and hopefully for the next meetup event I&#8217;ll be more prepared. The following script should work on both upcoming and past events. It doesn&#8217;t support waiting lists, and may have problems if meetup.com truncates lists after a certain number. I may revisit these items once I&#8217;ve scheduled the next event.</p>
<p><strong>Meetup.java</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.By</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.NoSuchElementException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.WebElement</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.chrome.ChromeDriver</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.htmlunit.HtmlUnitDriver</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.testng.annotations.AfterTest</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.testng.annotations.BeforeTest</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.testng.annotations.Test</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.ArrayList</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Meetup <span style="color: #009900;">&#123;</span>
&nbsp;
    HtmlUnitDriver driver<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003399;">String</span> meetup <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;seleniumlondon&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//meetup name from URL</span>
    <span style="color: #003399;">String</span> event <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;14712022&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//event ID from URL</span>
&nbsp;
    @BeforeTest
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> startDriver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        driver <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HtmlUnitDriver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @AfterTest
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> stopDriver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        driver.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @Test
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> listResponses<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//open the event page</span>
        driver.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.meetup.com/&quot;</span> <span style="color: #339933;">+</span> meetup <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;/calendar/&quot;</span> <span style="color: #339933;">+</span> event <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id('C_document')/descendant::dl[@class='stats'][2]/dt&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Who’s coming?&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">//this event has not yet occurred</span>
            listMembers<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id('C_document')//li[div[@class='D_attendeeHeader D_yes']]//li[starts-with(@id, 'member_')]&quot;</span>, <span style="color: #0000ff;">&quot;Yes&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            listMembers<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id('C_document')//li[div[@class='D_attendeeHeader D_maybe']]//li[starts-with(@id, 'member_')]&quot;</span>, <span style="color: #0000ff;">&quot;Maybe&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            listMembers<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id('C_document')//li[div[@class='D_attendeeHeader D_no']]//li[starts-with(@id, 'member_')]&quot;</span>, <span style="color: #0000ff;">&quot;No&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">//this event is in the past</span>
            listMembers<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id('C_document')//li[starts-with(@id, 'member_')]&quot;</span>, <span style="color: #0000ff;">&quot;Attended&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> listMembers<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> xpath, <span style="color: #003399;">String</span> label<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//get a list of all members that have responded or attended</span>
        List<span style="color: #339933;">&lt;</span>WebElement<span style="color: #339933;">&gt;</span> memberElements <span style="color: #339933;">=</span> driver.<span style="color: #006633;">findElements</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span>xpath<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">int</span> guestTotal <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//set guest total to zero</span>
        List<span style="color: #339933;">&lt;</span>Member<span style="color: #339933;">&gt;</span> members <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;</span>Member<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//create a list to store our members</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>WebElement member <span style="color: #339933;">:</span> memberElements<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">String</span> name <span style="color: #339933;">=</span> member.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">className</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D_name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//member name</span>
&nbsp;
            <span style="color: #000066; font-weight: bold;">int</span> guests <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//set member's guests to zero</span>
&nbsp;
            <span style="color: #666666; font-style: italic;">//get the number of guests for this member</span>
            <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">//upcoming events use a different class for the guest count as past events</span>
                <span style="color: #003399;">String</span> guestsTemp <span style="color: #339933;">=</span> member.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">className</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;guests&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                guests <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Integer</span><span style="color: #009900;">&#40;</span>guestsTemp.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span>guestsTemp.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;+&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span>, guestsTemp.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">NoSuchElementException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003399;">String</span> guestsTemp <span style="color: #339933;">=</span> member.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">className</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D_guests&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//past events use a different format for the guest count</span>
                guests <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Integer</span><span style="color: #009900;">&#40;</span>guestsTemp.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span>guestsTemp.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;+&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span>, guestsTemp.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">NoSuchElementException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
            guestTotal <span style="color: #339933;">=</span> guestTotal <span style="color: #339933;">+</span> guests<span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//update the total number of guests for this event</span>
            members.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Member</span><span style="color: #009900;">&#40;</span>name, guests<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//add the current member to our list</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">//output a label for this list including total member and guest counts</span>
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #339933;">+</span> members.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #339933;">+</span> label <span style="color: #339933;">+</span> getGuestSuffix<span style="color: #009900;">&#40;</span>guestTotal<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>members.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">//output details for each member</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;. &quot;</span> <span style="color: #339933;">+</span> members.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">name</span> <span style="color: #339933;">+</span> getGuestSuffix<span style="color: #009900;">&#40;</span>members.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">guests</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getGuestSuffix<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> guests<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">//return a suffix to indicate the number of guests</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>guests <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot; (+&quot;</span> <span style="color: #339933;">+</span> guests <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; guest&quot;</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>guests <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">?</span> <span style="color: #0000ff;">&quot;s&quot;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;)&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//inner class for members</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> <span style="color: #003399;">Member</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #003399;">String</span> name<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> guests<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Member</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> name, <span style="color: #000066; font-weight: bold;">int</span> guests<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">name</span> <span style="color: #339933;">=</span> name<span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">guests</span> <span style="color: #339933;">=</span> guests<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/examples/meetup-com-attendance-lists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cheesecake</title>
		<link>http://seleniumexamples.com/blog/examples/cheesecake/</link>
		<comments>http://seleniumexamples.com/blog/examples/cheesecake/#comments</comments>
		<pubDate>Sun, 07 Nov 2010 19:08:55 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[cheesecake]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[selenium 2]]></category>
		<category><![CDATA[webdriver]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=267</guid>
		<description><![CDATA[Here&#8217;s another one of my odd Selenium examples! Last month I finally got to eat at a &#8216;Cheesecake Factory&#8217; restaurant, after first hearing about them a few years back from an American friend. There&#8217;s an overwhelming choice of 30+ cheesecakes to choose from, and I&#8217;m really not good at making decisions when there&#8217;s so much [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s another one of my odd Selenium examples! Last month I finally got to eat at a &#8216;Cheesecake Factory&#8217; restaurant, after first hearing about them a few years back from an American friend. There&#8217;s an overwhelming choice of 30+ cheesecakes to choose from, and I&#8217;m really not good at making decisions when there&#8217;s so much choice. I decided to go with &#8216;The Original&#8217;, and that every subsequent visit to the chain I would work my way down the menu, knowing I&#8217;d probably never get through all of them in my lifetime!</p>
<p>So as I&#8217;m in California right now, I remembered my experience, and decided to check out the full menu from the restaurant so that I could add it to Evernote and keep track of my progress. Unfortunately I wasn&#8217;t able to do a nice copy+paste from the site, so &#8211; as usual &#8211; I wrote a Selenium script to list all the cheesecakes. For a change this script uses the HtmlUnitDriver, however you can easily swap in one of the other browser drivers.</p>
<p><strong>CheesecakeFactory.java</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.By</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.WebElement</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.htmlunit.HtmlUnitDriver</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.testng.annotations.AfterTest</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.testng.annotations.BeforeTest</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.testng.annotations.Test</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> CheesecakeFactory <span style="color: #009900;">&#123;</span>
&nbsp;
    HtmlUnitDriver driver<span style="color: #339933;">;</span>
&nbsp;
    @BeforeTest
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> startDriver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        driver <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HtmlUnitDriver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @AfterTest
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> stopDriver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        driver.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @Test
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> listCheesecakes<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        driver.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.thecheesecakefactory.com/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">linkText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Menu&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">linkText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cheesecake&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        List<span style="color: #339933;">&lt;</span>WebElement<span style="color: #339933;">&gt;</span> cheesecakes <span style="color: #339933;">=</span> driver.<span style="color: #006633;">findElements</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id('leftNav_levelTwo')//li&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>cheesecakes.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; cheesecakes:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>cheesecakes.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;. &quot;</span> <span style="color: #339933;">+</span> cheesecakes.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Output</strong></p>
<pre>34 cheesecakes:
1. The Original
2. Fresh Strawberry
3. Reeses Peanut Butter Chocolate Cake Cheesecake
4. 30th Anniversary Chocolate Cake Cheesecake
5. White Chocolate Raspberry Truffle®
6. Ultimate Red Velvet Cake Cheesecake™
7. Godiva® Chocolate Cheesecake
8. Fresh Banana Cream Cheesecake
9. Adam's Peanut Butter Cup Fudge Ripple
10. White Chocolate Caramel Macadamia Nut Cheesecake
11. Lemon Raspberry Cream Cheesecake
12. Dulce de Leche Caramel Cheesecake
13. Chocolate Coconut Cream Cheesecake
14. Tiramisu Cheesecake
15. Chocolate Mousse Cheesecake
16. Vanilla Bean Cheesecake
17. Chocolate Tuxedo Cream™ Cheesecake
18. Kahlua® Cocoa Coffee Cheesecake
19. Pineapple Upside-Down Cheesecake
20. Chocolate Raspberry Truffle®
21. Dutch Apple Caramel Struesel
22. Chocolate Chip Cookie - Dough Cheesecake
23. Wild Blueberry White Chocolate Cheesecake™
24. Low Carb Cheesecake
25. Low Carb Cheesecake with Strawberries
26. Key Lime Cheesecake
27. Caramel Pecan Turtle Cheesecake
28. Brownie Sundae Cheesecake
29. Snickers® Bar Chunks and Cheesecake
30. Craig's Crazy Carrot Cake Cheesecake
31. Oreo® Cheesecake
32. Cherry Cheesecake
33. Pumpkin Cheesecake
34. Pumpkin Pecan Cheesecake</pre>
<p>Hmmm&#8230; Maybe I should get the Caltrain into San Francisco and make it 2 down, 32 to go!</p>
]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/examples/cheesecake/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How Mozilla Uses Selenium</title>
		<link>http://seleniumexamples.com/blog/events/how-mozilla-uses-selenium/</link>
		<comments>http://seleniumexamples.com/blog/events/how-mozilla-uses-selenium/#comments</comments>
		<pubDate>Fri, 05 Nov 2010 15:50:15 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[london]]></category>
		<category><![CDATA[meetup]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[slides]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=264</guid>
		<description><![CDATA[&#8220;How Mozilla Uses Selenium&#8221; View more presentations from Stephen Donner.]]></description>
			<content:encoded><![CDATA[<div id="__ss_5671730" style="width: 425px;"><strong style="display: block; margin: 12px 0 4px;"><a title="&quot;How Mozilla Uses Selenium&quot;" href="http://www.slideshare.net/stephendonner/selenium-londonmeetup-5671730">&#8220;How Mozilla Uses Selenium&#8221;</a></strong><object id="__sse5671730" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=selenium-london-meetup-101104175032-phpapp01&amp;stripped_title=selenium-londonmeetup-5671730&amp;userName=stephendonner" /><param name="name" value="__sse5671730" /><param name="allowfullscreen" value="true" /><embed id="__sse5671730" type="application/x-shockwave-flash" width="425" height="355" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=selenium-london-meetup-101104175032-phpapp01&amp;stripped_title=selenium-londonmeetup-5671730&amp;userName=stephendonner" name="__sse5671730" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<div style="padding: 5px 0 12px;">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/stephendonner">Stephen Donner</a>.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/events/how-mozilla-uses-selenium/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>London Selenium Meetup Event #3</title>
		<link>http://seleniumexamples.com/blog/events/london-selenium-meetup-event-3/</link>
		<comments>http://seleniumexamples.com/blog/events/london-selenium-meetup-event-3/#comments</comments>
		<pubDate>Fri, 05 Nov 2010 14:52:24 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[london]]></category>
		<category><![CDATA[meetup]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[selenium 2]]></category>
		<category><![CDATA[webdriver]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=260</guid>
		<description><![CDATA[This week saw the third London Selenium Users Meetup event, with presentations from Mozilla and an update from Simon Stewart on the progress of Selenium 2. You can read my full write-up of the event on my personal blog.]]></description>
			<content:encoded><![CDATA[<p>This week saw the third London Selenium Users Meetup event, with presentations from Mozilla and an update from Simon Stewart on the progress of Selenium 2. You can read my full write-up of the event on <a href="http://blargon7.com/2010/11/mozilla-in-london-for-selenium-meetup-3/">my personal blog</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/events/london-selenium-meetup-event-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New London Users Event: Advanced Test Automation with Firefox</title>
		<link>http://seleniumexamples.com/blog/events/new-london-users-event-advanced-test-automation-with-firefox/</link>
		<comments>http://seleniumexamples.com/blog/events/new-london-users-event-advanced-test-automation-with-firefox/#comments</comments>
		<pubDate>Fri, 24 Sep 2010 12:53:11 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[london]]></category>
		<category><![CDATA[meetup]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[selenium 2]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=256</guid>
		<description><![CDATA[Although it&#8217;s been scheduled for a while, the next London Selenium Users meetup event has now been officially announced. As before, Google will be generously hosting the event, which this time is Firefox flavoured! There will be four presentations, mostly by folks from Mozilla, but also an update from Simon Stewart on the progress of [...]]]></description>
			<content:encoded><![CDATA[<p>Although it&#8217;s been scheduled for a while, the next London Selenium Users meetup event has now been officially announced. As before, Google will be generously hosting the event, which this time is Firefox flavoured! There will be four presentations, mostly by folks from Mozilla, but also an update from Simon Stewart on the progress of Selenium 2. Head over to <a href="http://www.meetup.com/seleniumlondon/calendar/14712022/">the event page</a> on meetup.com for all the latest details.</p>
]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/events/new-london-users-event-advanced-test-automation-with-firefox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Checking Wedding Gifts with Selenium</title>
		<link>http://seleniumexamples.com/blog/examples/checking-wedding-gifts-with-selenium/</link>
		<comments>http://seleniumexamples.com/blog/examples/checking-wedding-gifts-with-selenium/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 09:28:33 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[gift list]]></category>
		<category><![CDATA[selenium 2]]></category>
		<category><![CDATA[webdriver]]></category>
		<category><![CDATA[wedding]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=249</guid>
		<description><![CDATA[Admittedly this one is unlikely to be useful to many, but it could still serve as a useful example for Selenium 2. Also, I haven&#8217;t posted an example since alpha 5 was released. I&#8217;m getting married in a few short weeks, and our gift list has now opened for any guests that would like to [...]]]></description>
			<content:encoded><![CDATA[<p>Admittedly this one is unlikely to be useful to many, but it could still serve as a useful example for Selenium 2. Also, I haven&#8217;t posted an example since <a href="http://seleniumhq.wordpress.com/2010/07/14/selenium-2-0a5-released/">alpha 5</a> was released.</p>
<p>I&#8217;m getting married in a few short weeks, and our gift list has now opened for any guests that would like to buy us something for the occasion. We debated over having a list in the first place, but in the end decided that it was probably for the best. One of our hesitations was that we didn&#8217;t want to know what people had bought for us before the day, and having an online gift list makes it possible to &#8216;spoil&#8217; the surprise.</p>
<p>With the list only having been open a couple of days, the temptation was already pretty difficult to resist and we decided that it was okay to see what has been bought just so long as we don&#8217;t find out who&#8217;s bought what. Unfortunately this isn&#8217;t easy on the site as they&#8217;re listed together, so I was sneakily able to construct an XPath that extracted the necessary information. I&#8217;ve now combined into a Selenium 2 example using Java, which can be found below.</p>
<p><strong>GiftList.java</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">giftlist</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.concurrent.TimeUnit</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.By</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.WebDriver</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.WebElement</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.firefox.FirefoxDriver</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> GiftList <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> WebDriver driver<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> GIFT_LIST_NUMBER <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;123546&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> GIFT_LIST_PASSWORD <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> <span style="color: #009900;">&#91;</span> <span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//open browser</span>
		driver <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FirefoxDriver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//set implicit wait</span>
		driver.<span style="color: #006633;">manage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">timeouts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">implicitlyWait</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">20</span>, TimeUnit.<span style="color: #006633;">SECONDS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//login</span>
		driver.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;https://www.johnlewisgiftlist.com/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">linkText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Manage your list&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">name</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;giftListNumber&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">sendKeys</span><span style="color: #009900;">&#40;</span>GIFT_LIST_NUMBER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">name</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;listPassword&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">sendKeys</span><span style="color: #009900;">&#40;</span>GIFT_LIST_PASSWORD<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">linkText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Display List&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//get purchased items</span>
		driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">linkText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Gifts purchased&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//h1[text()='Gifts purchased by guests']&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		List<span style="color: #339933;">&lt;</span>WebElement<span style="color: #339933;">&gt;</span> purchasedItems <span style="color: #339933;">=</span> driver.<span style="color: #006633;">findElements</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//tr[td[2] and @class='item']&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//output purchased items</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>WebElement item <span style="color: #339933;">:</span> purchasedItems<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>item.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/td[1]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//log out</span>
		driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">linkText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Log out&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//close browser</span>
		driver.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/examples/checking-wedding-gifts-with-selenium/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Proposal for new Selenium Q&amp;A site</title>
		<link>http://seleniumexamples.com/blog/proposals/proposal-for-new-selenium-qa-site/</link>
		<comments>http://seleniumexamples.com/blog/proposals/proposal-for-new-selenium-qa-site/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 08:57:27 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Proposals]]></category>
		<category><![CDATA[q&a]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[stackexchange]]></category>
		<category><![CDATA[stackoverflow]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=237</guid>
		<description><![CDATA[If you&#8217;re not already aware of the dedicated Selenium Q&#38;A site that I have proposed, then it&#8217;s definitely worth checking it out. If you&#8217;re interested in supporting the proposal, and helping it to reach beta then please commit. By committing you are stating that you are prepared to both ask and answer questions on the [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re not already aware of the <a href="http://area51.stackexchange.com/proposals/4693/selenium">dedicated Selenium Q&amp;A site</a> that I have proposed, then it&#8217;s definitely worth checking it out. If you&#8217;re interested in supporting the proposal, and helping it to reach beta then please <a href="http://area51.stackexchange.com/proposals/4693/selenium?referrer=l3hVtTWVlCTWgagw76fBpg2">commit</a>. By committing you are stating that you are prepared to both ask and answer questions on the proposed site.</p>
<p><strong>So why does Selenium need a new site for Q&amp;A?</strong></p>
<p>Well, first let me give you some history of the official Selenium forums. When I first started to get involved in the Selenium community there was the <a href="http://seleniumhq.org/clearspace.html">Clearspace forums</a>, which provided a good structure, a pretty good interface, and a basic reward system. The main problems I had with Clearspace was searching the content, identifying unanswered questions, and the alarming regularity of certain basic (but very suitable) questions. Another issue turned out to be spam, which I believe was the main reason the content was migrated &#8211; after much discussion &#8211; to <a href="http://groups.google.com/group/selenium-users/">Google Groups</a>.</p>
<p><span id="more-237"></span></p>
<p>I was 100% for this move, however with hindsight I believe it wasn&#8217;t the best decision. Google Groups is great for discussions but not a suitable place for Q&amp;A. It might be powerful in terms of search, but the format of text and structure of conversations makes it very difficult to identify questions, and there&#8217;s little or no incentive in answering them. Whenever I&#8217;ve taken time to read the posts in the group I&#8217;ve almost always lost interest after reading just one or two &#8211; there&#8217;s just so much text!</p>
<p>At this time the StackOverflow site was already becoming a popular place to ask Selenium questions &#8211; there are now over <a href="http://stackoverflow.com/questions/tagged/selenium">600 questions tagged &#8216;selenium&#8217;</a>. Once I&#8217;d asked and answered a handful of questions myself I was hooked. StackOverflow&#8217;s mission is to solve the common problems found in other forum solutions, and they do it very well. Their &#8216;ask a question&#8217; system makes it very obvious if you&#8217;re asking a question that has already been answered, therefore filtering out repetition questions but at the same time providing those users with quality answers. Their rewards system works well to encourage good quality questions and answers. The only problem is that StackOverflow is for asking programming questions, and although Selenium does have programming aspects to it, it&#8217;s not the perfect fit.</p>
<p>Along comes <a href="http://stackexchange.com/">StackExchange</a>, which provides the same underlying solution from StackOverflow to fit an audience other than programmers. Unfortunately StackExchange was a commercial solution, and as Selenium is free and open source there wasn&#8217;t the cash to get something running. It&#8217;s also difficult to determine if the cost would be worthwhile, as without community interested the site would get nowhere.</p>
<p>When StackExchange <a href="http://blog.stackoverflow.com/2010/04/changes-to-stack-exchange/">announced that they would be redesigning their model</a> so that community powered Q&amp;A sites would be provided free of charge if they can prove they have enough committed users, I decided to put forward the Selenium proposal. After 29 days I&#8217;m impressed that the proposal has over <strong>100</strong> followers, and now has over <strong>80</strong> committed users!</p>
<p>If you&#8217;ve already committed then thank you &#8211; I&#8217;m really looking forward to participating with you on the new site!</p>
]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/proposals/proposal-for-new-selenium-qa-site/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss><!-- Dynamic page generated in 0.566 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-02-10 21:51:46 -->

