<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Selenium WebDriver</title>
	<atom:link href="http://selenium.polteq.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://selenium.polteq.com</link>
	<description></description>
	<lastBuildDate>Mon, 14 May 2012 08:29:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Use custom prioritizer for Selenium Grid Hub</title>
		<link>http://selenium.polteq.com/en/use-custom-prioritizer-for-selelenium-grid-hub/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=use-custom-prioritizer-for-selelenium-grid-hub</link>
		<comments>http://selenium.polteq.com/en/use-custom-prioritizer-for-selelenium-grid-hub/#comments</comments>
		<pubDate>Mon, 14 May 2012 08:29:35 +0000</pubDate>
		<dc:creator>Roy de Kleijn</dc:creator>
				<category><![CDATA[Selenium Grid 2]]></category>

		<guid isPermaLink="false">http://selenium.polteq.com/?p=833</guid>
		<description><![CDATA[Problem Imagine all the machines will push their test scripts to the HUB. They will be queued and executed according to the FIFO principles (First In First Out). But also the Continuous Integration (CI) environment will push the test scripts &#8230; <a href="http://selenium.polteq.com/en/use-custom-prioritizer-for-selelenium-grid-hub/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h1>Problem</h1>
<p>Imagine all the machines will push their test scripts to the HUB. They will be queued and executed according to the FIFO principles (First In First Out).</p>
<p>But also the Continuous Integration (CI) environment will push the test scripts to the HUB. Although they have a higher priority (because we want to keep the feedback cycle as short as possible), they will be queued according to the same principles. We can implement the code described in this recipes to make an distinction based on priority.</p>
<h1>Solution</h1>
<ol>
<li>Create the prioritizer</li>
<li>Create a config file (hub.json)</li>
<li>Launch the HUB with the custom prioritizer</li>
<li>Modify the test scripts</li>
</ol>
<h2>Create the prioritizer</h2>
<div class="highlight-wrapper java">
<div class="tools">
<div class="wrap">
<a href="#" class="show-raw">raw</a><a href="#" class="show-colored">highlighted</a><a href="#" class="to-clipboard">copy</a><a href="#" class="print">print</a><a href="#" class="about">?</a>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<pre class="raw"><code lang="java">
import java.util.Map;

import org.openqa.grid.internal.listeners.Prioritizer;

public class CustomPrioritizer implements Prioritizer {

    public int compareTo(Map&lt;String, Object&gt; a, Map&lt;String, Object&gt; b) {
        boolean aImportant = a.get("_important") == null ? false : Boolean
                .parseBoolean(a.get("_important").toString());
        boolean bImportant = b.get("_important") == null ? false : Boolean
                .parseBoolean(b.get("_important").toString());
        if (aImportant == bImportant) {
            return 0;
        }
        if (aImportant &amp;&amp; !bImportant) {
            return -1;
        } else {
            return 1;
        }
    }
}
</code></pre>
<div class="highlighted">
<table class="highlighttable">
<tr>
<td class="linenos">
<div class="linenodiv">
<pre class="nl"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21</pre>
</div>
</td>
<td class="code">
<div class="highlight">
<pre><span class="kn">import</span> <span class="nn">java.util.Map</span><span class="o">;</span>

<span class="kn">import</span> <span class="nn">org.openqa.grid.internal.listeners.Prioritizer</span><span class="o">;</span>

<span class="kd">public</span> <span class="kd">class</span> <span class="nc">CustomPrioritizer</span> <span class="kd">implements</span> <span class="n">Prioritizer</span> <span class="o">{</span>

    <span class="kd">public</span> <span class="kt">int</span> <span class="nf">compareTo</span><span class="o">(</span><span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">a</span><span class="o">,</span> <span class="n">Map</span><span class="o">&lt;</span><span class="n">String</span><span class="o">,</span> <span class="n">Object</span><span class="o">&gt;</span> <span class="n">b</span><span class="o">)</span> <span class="o">{</span>
        <span class="kt">boolean</span> <span class="n">aImportant</span> <span class="o">=</span> <span class="n">a</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"_important"</span><span class="o">)</span> <span class="o">==</span> <span class="kc">null</span> <span class="o">?</span> <span class="kc">false</span> <span class="o">:</span> <span class="n">Boolean</span>
                <span class="o">.</span><span class="na">parseBoolean</span><span class="o">(</span><span class="n">a</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"_important"</span><span class="o">).</span><span class="na">toString</span><span class="o">());</span>
        <span class="kt">boolean</span> <span class="n">bImportant</span> <span class="o">=</span> <span class="n">b</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"_important"</span><span class="o">)</span> <span class="o">==</span> <span class="kc">null</span> <span class="o">?</span> <span class="kc">false</span> <span class="o">:</span> <span class="n">Boolean</span>
                <span class="o">.</span><span class="na">parseBoolean</span><span class="o">(</span><span class="n">b</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"_important"</span><span class="o">).</span><span class="na">toString</span><span class="o">());</span>
        <span class="k">if</span> <span class="o">(</span><span class="n">aImportant</span> <span class="o">==</span> <span class="n">bImportant</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">return</span> <span class="mi">0</span><span class="o">;</span>
        <span class="o">}</span>
        <span class="k">if</span> <span class="o">(</span><span class="n">aImportant</span> <span class="o">&amp;&amp;</span> <span class="o">!</span><span class="n">bImportant</span><span class="o">)</span> <span class="o">{</span>
            <span class="k">return</span> <span class="o">-</span><span class="mi">1</span><span class="o">;</span>
        <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
            <span class="k">return</span> <span class="mi">1</span><span class="o">;</span>
        <span class="o">}</span>
    <span class="o">}</span>
<span class="o">}</span>
</pre>
</div>
</td>
</tr>
</table>
</div>
</div>
<h2>Create a config file (hub.json)</h2>
<div class="highlight-wrapper java">
<div class="tools">
<div class="wrap">
<a href="#" class="show-raw">raw</a><a href="#" class="show-colored">highlighted</a><a href="#" class="to-clipboard">copy</a><a href="#" class="print">print</a><a href="#" class="about">?</a>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<pre class="raw"><code lang="java">
{
  "host": null,
  "port": 4444,
  "newSessionWaitTimeout": -1,
  "servlets" : [],
  "prioritizer": myPriotizer.customPrioritizer,
  "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
  "throwOnCapabilityNotPresent": true,
  "nodePolling": 5000,

  "cleanUpCycle": 5000,
  "timeout": 300000,
  "maxSession": 20
}
</code></pre>
<div class="highlighted">
<table class="highlighttable">
<tr>
<td class="linenos">
<div class="linenodiv">
<pre class="nl"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14</pre>
</div>
</td>
<td class="code">
<div class="highlight">
<pre><span class="o">{</span>
  <span class="s">"host"</span><span class="o">:</span> <span class="kc">null</span><span class="o">,</span>
  <span class="s">"port"</span><span class="o">:</span> <span class="mi">4444</span><span class="o">,</span>
  <span class="s">"newSessionWaitTimeout"</span><span class="o">:</span> <span class="o">-</span><span class="mi">1</span><span class="o">,</span>
  <span class="s">"servlets"</span> <span class="o">:</span> <span class="o">[],</span>
  <span class="s">"prioritizer"</span><span class="o">:</span> <span class="n">myPriotizer</span><span class="o">.</span><span class="na">customPrioritizer</span><span class="o">,</span>
  <span class="s">"capabilityMatcher"</span><span class="o">:</span> <span class="s">"org.openqa.grid.internal.utils.DefaultCapabilityMatcher"</span><span class="o">,</span>
  <span class="s">"throwOnCapabilityNotPresent"</span><span class="o">:</span> <span class="kc">true</span><span class="o">,</span>
  <span class="s">"nodePolling"</span><span class="o">:</span> <span class="mi">5000</span><span class="o">,</span>

  <span class="s">"cleanUpCycle"</span><span class="o">:</span> <span class="mi">5000</span><span class="o">,</span>
  <span class="s">"timeout"</span><span class="o">:</span> <span class="mi">300000</span><span class="o">,</span>
  <span class="s">"maxSession"</span><span class="o">:</span> <span class="mi">20</span>
<span class="o">}</span>
</pre>
</div>
</td>
</tr>
</table>
</div>
</div>
<h2>Launch the HUB with the custom prioritizer</h2>
<div class="highlight-wrapper bash">
<div class="tools">
<div class="wrap">
<a href="#" class="show-raw">raw</a><a href="#" class="show-colored">highlighted</a><a href="#" class="to-clipboard">copy</a><a href="#" class="print">print</a><a href="#" class="about">?</a>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<pre class="raw"><code lang="bash">
java -cp selenium-server-standalone-&lt;version&gt;.jar:prioritizer.jar org.openqa.grid.selenium.GridLauncher -role hub -hubConfig hub.json
</code></pre>
<div class="highlighted">
<table class="highlighttable">
<tr>
<td class="linenos">
<div class="linenodiv">
<pre class="nl">1</pre>
</div>
</td>
<td class="code">
<div class="highlight">
<pre>java -cp selenium-server-standalone-&lt;version&gt;.jar:prioritizer.jar org.openqa.grid.selenium.GridLauncher -role hub -hubConfig hub.json
</pre>
</div>
</td>
</tr>
</table>
</div>
</div>
<h2>Modify the test scripts</h2>
<div class="highlight-wrapper java">
<div class="tools">
<div class="wrap">
<a href="#" class="show-raw">raw</a><a href="#" class="show-colored">highlighted</a><a href="#" class="to-clipboard">copy</a><a href="#" class="print">print</a><a href="#" class="about">?</a>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<pre class="raw"><code lang="java">
import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.Test;

public class PrioritizerExample {

    @Test
    public void importantTest() throws MalformedURLException {
        DesiredCapabilities capability = DesiredCapabilities.firefox();
        capability.setCapability("_important", true);

        RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
        driver.get("http://selenium.polteq.com/prestashop/");

        driver.findElement(By.cssSelector("input#search_query_top")).sendKeys("ipod nano");
        driver.findElement(By.cssSelector("input[name='submit_search']")).click();
        String searchHeader = driver.findElement(By.cssSelector("H1")).getText().toLowerCase();

        Assert.assertTrue(searchHeader.contains("ipod nano"));

        driver.close();
        driver.quit();
    }

    @Test
    public void lessImportantTest() throws MalformedURLException {
        DesiredCapabilities capability = DesiredCapabilities.firefox();
        capability.setCapability("_important", false);

        RemoteWebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
        driver.get("http://selenium.polteq.com/prestashop/");

        driver.findElement(By.cssSelector("input#search_query_top")).sendKeys("ipod nano");
        driver.findElement(By.cssSelector("input[name='submit_search']")).click();
        String searchHeader = driver.findElement(By.cssSelector("H1")).getText().toLowerCase();

        Assert.assertTrue(searchHeader.contains("ipod nano"));

        driver.close();
        driver.quit();
    }

}
</code></pre>
<div class="highlighted">
<table class="highlighttable">
<tr>
<td class="linenos">
<div class="linenodiv">
<pre class="nl"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48</pre>
</div>
</td>
<td class="code">
<div class="highlight">
<pre><span class="kn">import</span> <span class="nn">java.net.MalformedURLException</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">java.net.URL</span><span class="o">;</span>

<span class="kn">import</span> <span class="nn">org.openqa.selenium.By</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.openqa.selenium.remote.DesiredCapabilities</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.openqa.selenium.remote.RemoteWebDriver</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.Assert</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.annotations.Test</span><span class="o">;</span>

<span class="kd">public</span> <span class="kd">class</span> <span class="nc">PrioritizerExample</span> <span class="o">{</span>

    <span class="nd">@Test</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">importantTest</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">MalformedURLException</span> <span class="o">{</span>
        <span class="n">DesiredCapabilities</span> <span class="n">capability</span> <span class="o">=</span> <span class="n">DesiredCapabilities</span><span class="o">.</span><span class="na">firefox</span><span class="o">();</span>
        <span class="n">capability</span><span class="o">.</span><span class="na">setCapability</span><span class="o">(</span><span class="s">"_important"</span><span class="o">,</span> <span class="kc">true</span><span class="o">);</span>

        <span class="n">RemoteWebDriver</span> <span class="n">driver</span> <span class="o">=</span> <span class="k">new</span> <span class="n">RemoteWebDriver</span><span class="o">(</span><span class="k">new</span> <span class="n">URL</span><span class="o">(</span><span class="s">"http://localhost:4444/wd/hub"</span><span class="o">),</span> <span class="n">capability</span><span class="o">);</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"http://selenium.polteq.com/prestashop/"</span><span class="o">);</span>

        <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"input#search_query_top"</span><span class="o">)).</span><span class="na">sendKeys</span><span class="o">(</span><span class="s">"ipod nano"</span><span class="o">);</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"input[name='submit_search']"</span><span class="o">)).</span><span class="na">click</span><span class="o">();</span>
        <span class="n">String</span> <span class="n">searchHeader</span> <span class="o">=</span> <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"H1"</span><span class="o">)).</span><span class="na">getText</span><span class="o">().</span><span class="na">toLowerCase</span><span class="o">();</span>

        <span class="n">Assert</span><span class="o">.</span><span class="na">assertTrue</span><span class="o">(</span><span class="n">searchHeader</span><span class="o">.</span><span class="na">contains</span><span class="o">(</span><span class="s">"ipod nano"</span><span class="o">));</span>

        <span class="n">driver</span><span class="o">.</span><span class="na">close</span><span class="o">();</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">quit</span><span class="o">();</span>
    <span class="o">}</span>

    <span class="nd">@Test</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">lessImportantTest</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">MalformedURLException</span> <span class="o">{</span>
        <span class="n">DesiredCapabilities</span> <span class="n">capability</span> <span class="o">=</span> <span class="n">DesiredCapabilities</span><span class="o">.</span><span class="na">firefox</span><span class="o">();</span>
        <span class="n">capability</span><span class="o">.</span><span class="na">setCapability</span><span class="o">(</span><span class="s">"_important"</span><span class="o">,</span> <span class="kc">false</span><span class="o">);</span>

        <span class="n">RemoteWebDriver</span> <span class="n">driver</span> <span class="o">=</span> <span class="k">new</span> <span class="n">RemoteWebDriver</span><span class="o">(</span><span class="k">new</span> <span class="n">URL</span><span class="o">(</span><span class="s">"http://localhost:4444/wd/hub"</span><span class="o">),</span> <span class="n">capability</span><span class="o">);</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"http://selenium.polteq.com/prestashop/"</span><span class="o">);</span>

        <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"input#search_query_top"</span><span class="o">)).</span><span class="na">sendKeys</span><span class="o">(</span><span class="s">"ipod nano"</span><span class="o">);</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"input[name='submit_search']"</span><span class="o">)).</span><span class="na">click</span><span class="o">();</span>
        <span class="n">String</span> <span class="n">searchHeader</span> <span class="o">=</span> <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"H1"</span><span class="o">)).</span><span class="na">getText</span><span class="o">().</span><span class="na">toLowerCase</span><span class="o">();</span>

        <span class="n">Assert</span><span class="o">.</span><span class="na">assertTrue</span><span class="o">(</span><span class="n">searchHeader</span><span class="o">.</span><span class="na">contains</span><span class="o">(</span><span class="s">"ipod nano"</span><span class="o">));</span>

        <span class="n">driver</span><span class="o">.</span><span class="na">close</span><span class="o">();</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">quit</span><span class="o">();</span>
    <span class="o">}</span>

<span class="o">}</span>
</pre>
</div>
</td>
</tr>
</table>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://selenium.polteq.com/en/use-custom-prioritizer-for-selelenium-grid-hub/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Launch node with config</title>
		<link>http://selenium.polteq.com/en/launch-node-with-config/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=launch-node-with-config</link>
		<comments>http://selenium.polteq.com/en/launch-node-with-config/#comments</comments>
		<pubDate>Mon, 14 May 2012 08:21:35 +0000</pubDate>
		<dc:creator>Roy de Kleijn</dc:creator>
				<category><![CDATA[Selenium Grid 2]]></category>

		<guid isPermaLink="false">http://selenium.polteq.com/?p=830</guid>
		<description><![CDATA[Problem We can set parameters to the node in order to configure them. We can set the maximum number of concurrent tests, platform, browserName and so on. We can use those values in our tests to specify the corresponding node. &#8230; <a href="http://selenium.polteq.com/en/launch-node-with-config/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h1>Problem</h1>
<p>We can set parameters to the node in order to configure them. We can set the maximum number of concurrent tests, platform, browserName and so on. We can use those values in our tests to specify the corresponding node.</p>
<h1>Prerequisites</h1>
<p>Open the command prompt and navigate to the directory where we put the selenium-server-standalone file.</p>
<h1>Solution</h1>
<p>We can add the -browser parameters to the command line with the following values to launch 5 FireFox 3.6 instances on Linux.</p>
<p><code>-browser browserName=firefox,version=3.6,maxInstances=5,platform=LINUX</code></p>
<h1>There is more&#8230;</h1>
<p>We can also load a JSON file while launching the browser, in addition to specifying the browser parameter on the command line. We need to add the following parameter to the test: -nodeConfig node.json The contents of node.json may look like this:</p>
<div class="highlight-wrapper javascript">
<div class="tools">
<div class="wrap">
<a href="#" class="show-raw">raw</a><a href="#" class="show-colored">highlighted</a><a href="#" class="to-clipboard">copy</a><a href="#" class="print">print</a><a href="#" class="about">?</a>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<pre class="raw"><code lang="javascript">
{
  "capabilities":
      [
        {
          "browserName": "firefox",
          "version": "3.6",
          "platform": "WINDOWS",
          "maxInstances": 1
        },
        {
          "browserName": "internet explorer",
          "version": "8",
          "platform": "WINDOWS",
          "maxInstances": 1
        }
      ],
    "configuration":
        {
        "nodeTimeout":120,
        "port":5555,

        "hubPort":4444,
        "hubHost":"localhost",

        "nodePolling":2000,

        "registerCycle":10000,
        "register":true,
        "cleanUpCycle":2000,
        "timeout":30000,
        "maxSession":1,
        }
}
</code></pre>
<div class="highlighted">
<table class="highlighttable">
<tr>
<td class="linenos">
<div class="linenodiv">
<pre class="nl"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33</pre>
</div>
</td>
<td class="code">
<div class="highlight">
<pre><span class="p">{</span>
  <span class="s2">"capabilities"</span><span class="o">:</span>
      <span class="p">[</span>
        <span class="p">{</span>
          <span class="s2">"browserName"</span><span class="o">:</span> <span class="s2">"firefox"</span><span class="p">,</span>
          <span class="s2">"version"</span><span class="o">:</span> <span class="s2">"3.6"</span><span class="p">,</span>
          <span class="s2">"platform"</span><span class="o">:</span> <span class="s2">"WINDOWS"</span><span class="p">,</span>
          <span class="s2">"maxInstances"</span><span class="o">:</span> <span class="mi">1</span>
        <span class="p">},</span>
        <span class="p">{</span>
          <span class="s2">"browserName"</span><span class="o">:</span> <span class="s2">"internet explorer"</span><span class="p">,</span>
          <span class="s2">"version"</span><span class="o">:</span> <span class="s2">"8"</span><span class="p">,</span>
          <span class="s2">"platform"</span><span class="o">:</span> <span class="s2">"WINDOWS"</span><span class="p">,</span>
          <span class="s2">"maxInstances"</span><span class="o">:</span> <span class="mi">1</span>
        <span class="p">}</span>
      <span class="p">],</span>
    <span class="s2">"configuration"</span><span class="o">:</span>
        <span class="p">{</span>
        <span class="s2">"nodeTimeout"</span><span class="o">:</span><span class="mi">120</span><span class="p">,</span>
        <span class="s2">"port"</span><span class="o">:</span><span class="mi">5555</span><span class="p">,</span>

        <span class="s2">"hubPort"</span><span class="o">:</span><span class="mi">4444</span><span class="p">,</span>
        <span class="s2">"hubHost"</span><span class="o">:</span><span class="s2">"localhost"</span><span class="p">,</span>

        <span class="s2">"nodePolling"</span><span class="o">:</span><span class="mi">2000</span><span class="p">,</span>

        <span class="s2">"registerCycle"</span><span class="o">:</span><span class="mi">10000</span><span class="p">,</span>
        <span class="s2">"register"</span><span class="o">:</span><span class="kc">true</span><span class="p">,</span>
        <span class="s2">"cleanUpCycle"</span><span class="o">:</span><span class="mi">2000</span><span class="p">,</span>
        <span class="s2">"timeout"</span><span class="o">:</span><span class="mi">30000</span><span class="p">,</span>
        <span class="s2">"maxSession"</span><span class="o">:</span><span class="mi">1</span><span class="p">,</span>
        <span class="p">}</span>
<span class="p">}</span>
</pre>
</div>
</td>
</tr>
</table>
</div>
</div>
<p>It will launch a firefox and a windows browser on a windows platform.</p>
<p>Command line script to start a Selenium Node with Config:</p>
<p><code>java -jar selenium-server-standalone-2.20.0.jar -role node -hub http://localhost:4444/grid/register -nodeConfig defaultNodeConfig.json</code></p>
]]></content:encoded>
			<wfw:commentRss>http://selenium.polteq.com/en/launch-node-with-config/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running tests against the Grid</title>
		<link>http://selenium.polteq.com/en/running-tests-against-the-grid/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=running-tests-against-the-grid</link>
		<comments>http://selenium.polteq.com/en/running-tests-against-the-grid/#comments</comments>
		<pubDate>Mon, 14 May 2012 08:17:07 +0000</pubDate>
		<dc:creator>Roy de Kleijn</dc:creator>
				<category><![CDATA[Selenium Grid 2]]></category>

		<guid isPermaLink="false">http://selenium.polteq.com/?p=825</guid>
		<description><![CDATA[Problem We have to make minor changes to the tests in order to run our tests against the Grid. This recipes will show us how we can define capabilities to match a node. Prerequisites Make sure the desired capabilities are &#8230; <a href="http://selenium.polteq.com/en/running-tests-against-the-grid/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h1>Problem</h1>
<p>We have to make minor changes to the tests in order to run our tests against the Grid. This recipes will show us how we can define capabilities to match a node.</p>
<h1>Prerequisites</h1>
<p>Make sure the desired capabilities are in the Grid otherwise the test can not be routed to the node.</p>
<h1>Solution</h1>
<p>The code below will match the following nodes: browserName=firefox,version=3.6,platform=LINUX</p>
<div class="highlight-wrapper java">
<div class="tools">
<div class="wrap">
<a href="#" class="show-raw">raw</a><a href="#" class="show-colored">highlighted</a><a href="#" class="to-clipboard">copy</a><a href="#" class="print">print</a><a href="#" class="about">?</a>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<pre class="raw"><code lang="java">
import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.By;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class GridExample {
    private static RemoteWebDriver driver;

    @BeforeClass
    public void setUp() throws MalformedURLException {
        DesiredCapabilities capability = DesiredCapabilities.firefox();
        capability.setBrowserName("firefox");
        capability.setPlatform(Platform.LINUX);
        capability.setVersion("3.6");
        driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability);
        driver.get("http://selenium.polteq.com/prestashop/");
    }

    @Test
    public void measurePerformance() {
        driver.findElement(By.cssSelector("input#search_query_top")).sendKeys("ipod nano");
        driver.findElement(By.cssSelector("input[name='submit_search']")).click();
        String searchHeader = driver.findElement(By.cssSelector("H1")).getText().toLowerCase();

        Assert.assertTrue(searchHeader.contains("ipod nano"));
    }
}
</code></pre>
<div class="highlighted">
<table class="highlighttable">
<tr>
<td class="linenos">
<div class="linenodiv">
<pre class="nl"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33</pre>
</div>
</td>
<td class="code">
<div class="highlight">
<pre><span class="kn">import</span> <span class="nn">java.net.MalformedURLException</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">java.net.URL</span><span class="o">;</span>

<span class="kn">import</span> <span class="nn">org.openqa.selenium.By</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.openqa.selenium.Platform</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.openqa.selenium.remote.DesiredCapabilities</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.openqa.selenium.remote.RemoteWebDriver</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.Assert</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.annotations.BeforeClass</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.annotations.Test</span><span class="o">;</span>

<span class="kd">public</span> <span class="kd">class</span> <span class="nc">GridExample</span> <span class="o">{</span>
    <span class="kd">private</span> <span class="kd">static</span> <span class="n">RemoteWebDriver</span> <span class="n">driver</span><span class="o">;</span>

    <span class="nd">@BeforeClass</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">setUp</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">MalformedURLException</span> <span class="o">{</span>
        <span class="n">DesiredCapabilities</span> <span class="n">capability</span> <span class="o">=</span> <span class="n">DesiredCapabilities</span><span class="o">.</span><span class="na">firefox</span><span class="o">();</span>
        <span class="n">capability</span><span class="o">.</span><span class="na">setBrowserName</span><span class="o">(</span><span class="s">"firefox"</span><span class="o">);</span>
        <span class="n">capability</span><span class="o">.</span><span class="na">setPlatform</span><span class="o">(</span><span class="n">Platform</span><span class="o">.</span><span class="na">LINUX</span><span class="o">);</span>
        <span class="n">capability</span><span class="o">.</span><span class="na">setVersion</span><span class="o">(</span><span class="s">"3.6"</span><span class="o">);</span>
        <span class="n">driver</span> <span class="o">=</span> <span class="k">new</span> <span class="n">RemoteWebDriver</span><span class="o">(</span><span class="k">new</span> <span class="n">URL</span><span class="o">(</span><span class="s">"http://localhost:4444/wd/hub"</span><span class="o">),</span> <span class="n">capability</span><span class="o">);</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"http://selenium.polteq.com/prestashop/"</span><span class="o">);</span>
    <span class="o">}</span>

    <span class="nd">@Test</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">measurePerformance</span><span class="o">()</span> <span class="o">{</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"input#search_query_top"</span><span class="o">)).</span><span class="na">sendKeys</span><span class="o">(</span><span class="s">"ipod nano"</span><span class="o">);</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"input[name='submit_search']"</span><span class="o">)).</span><span class="na">click</span><span class="o">();</span>
        <span class="n">String</span> <span class="n">searchHeader</span> <span class="o">=</span> <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"H1"</span><span class="o">)).</span><span class="na">getText</span><span class="o">().</span><span class="na">toLowerCase</span><span class="o">();</span>

        <span class="n">Assert</span><span class="o">.</span><span class="na">assertTrue</span><span class="o">(</span><span class="n">searchHeader</span><span class="o">.</span><span class="na">contains</span><span class="o">(</span><span class="s">"ipod nano"</span><span class="o">));</span>
    <span class="o">}</span>
<span class="o">}</span>
</pre>
</div>
</td>
</tr>
</table>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://selenium.polteq.com/en/running-tests-against-the-grid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding nodes to the hub</title>
		<link>http://selenium.polteq.com/en/adding-nodes-to-the-hub/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=adding-nodes-to-the-hub</link>
		<comments>http://selenium.polteq.com/en/adding-nodes-to-the-hub/#comments</comments>
		<pubDate>Mon, 14 May 2012 08:11:47 +0000</pubDate>
		<dc:creator>Roy de Kleijn</dc:creator>
				<category><![CDATA[Selenium Grid 2]]></category>

		<guid isPermaLink="false">http://selenium.polteq.com/?p=821</guid>
		<description><![CDATA[Problem We can add nodes to the Selenium Grid Hub, now the hub is up and running. This recipe will describe how to launch Selenium instances and register them to the hub so it starts forming the grid op Selenium &#8230; <a href="http://selenium.polteq.com/en/adding-nodes-to-the-hub/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h1>Problem</h1>
<p>We can add nodes to the Selenium Grid Hub, now the hub is up and running. This recipe will describe how to launch Selenium instances and register them to the hub so it starts forming the grid op Selenium instances that we are expecting.</p>
<h1>Prerequisites</h1>
<p>Open the command prompt and navigate to the directory where we put the selenium-server-standalone file.</p>
<h1>Solution</h1>
<p>Enter something like the following command in the command prompt: java -jar selenium-server-standalone-<version>.jar -role node -hub http://localhost:4444/grid/register -port 5556 We should see the following output in the console: <a href="http://selenium.polteq.com/wp-content/uploads/5740_07_03.png"><img src="http://selenium.polteq.com/wp-content/uploads/5740_07_03.png" alt="" title="5740_07_03" width="779" height="580" class="alignnone size-full wp-image-815"></a></version></p>
<h1>What has been done</h1>
<p>The command above will register a node to the hub, which is fully backwards compatible with Selenium 1. We can see this node in the Hub Console: <a href="http://selenium.polteq.com/wp-content/uploads/5740_07_04.png"><img src="http://selenium.polteq.com/wp-content/uploads/5740_07_04.png" alt="" title="5740_07_04" width="631" height="249" class="alignnone size-full wp-image-816"></a></p>
<blockquote>
<p>We can add multiple operating systems to our Selenium Grid. This allows us to check, whether different versions of Firefox on different operating systems are showing the same behavior.</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://selenium.polteq.com/en/adding-nodes-to-the-hub/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Launching the hub</title>
		<link>http://selenium.polteq.com/en/launching-the-hub/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=launching-the-hub</link>
		<comments>http://selenium.polteq.com/en/launching-the-hub/#comments</comments>
		<pubDate>Mon, 14 May 2012 08:02:55 +0000</pubDate>
		<dc:creator>Roy de Kleijn</dc:creator>
				<category><![CDATA[Selenium Grid 2]]></category>

		<guid isPermaLink="false">http://selenium.polteq.com/?p=811</guid>
		<description><![CDATA[Problem We want to start Selenium HUB, which is the central point in the Grid that will receive all Selenium commands and route them to the right node. Prerequisites Download the latest version of selenium-server-standalone.jar from the Selenium website. (http://code.google.com/p/selenium/downloads/list) &#8230; <a href="http://selenium.polteq.com/en/launching-the-hub/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h1>Problem</h1>
<p>We want to start Selenium HUB, which is the central point in the Grid that will receive all Selenium commands and route them to the right node.</p>
<h1>Prerequisites</h1>
<p>Download the latest version of selenium-server-standalone.jar from the Selenium website. (http://code.google.com/p/selenium/downloads/list) Open the command prompt and navigate to the directory where we put the selenium-server-standalone file.</p>
<h1>Solution</h1>
<p>Enter something like the following command in the command prompt to start the hub: java -jar selenium-server-standalone-<version>.jar -role hub The output in the console will look like this: <a href="http://selenium.polteq.com/wp-content/uploads/5740_07_01.png"><img src="http://selenium.polteq.com/wp-content/uploads/5740_07_01.png" alt="" title="5740_07_01" width="677" height="258" class="alignnone size-full wp-image-818"></a></version></p>
<h1>What has been done</h1>
<p>The hub will use port 4444 by default. We can see the Selenium instances that are connected to the hub and the status of the nodes if we put http://ip-of-hub:4444/grid/console in a browser window, where ip-of-hub is the name of the machine with the hub. If it is on the local machine then you can place http://localhost:4444/grid/console. We can see that in the next screenshot: <a href="http://selenium.polteq.com/wp-content/uploads/5740_07_02.png"><img src="http://selenium.polteq.com/wp-content/uploads/5740_07_02.png" alt="" title="5740_07_02" width="605" height="244" class="alignnone size-full wp-image-814"></a></p>
<blockquote>
<p>Tip: We can also specify a different port to run the hub on. We can give an extra parameter to the command, like: -port # (where # is the port-number)</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://selenium.polteq.com/en/launching-the-hub/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Selenium Grid 2 &#8211; Introduction</title>
		<link>http://selenium.polteq.com/en/selenium-grid-2-introduction/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=selenium-grid-2-introduction</link>
		<comments>http://selenium.polteq.com/en/selenium-grid-2-introduction/#comments</comments>
		<pubDate>Mon, 14 May 2012 08:01:04 +0000</pubDate>
		<dc:creator>Roy de Kleijn</dc:creator>
				<category><![CDATA[Selenium Grid 2]]></category>

		<guid isPermaLink="false">http://selenium.polteq.com/?p=808</guid>
		<description><![CDATA[Selenium Grid allows us to have multiple Selenium instances on multiple machines and then have one point to send Selenium commands to. We can specify the operating system / browser and browser version where we want to run the test &#8230; <a href="http://selenium.polteq.com/en/selenium-grid-2-introduction/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Selenium Grid allows us to have multiple Selenium instances on multiple machines and then have one point to send Selenium commands to. We can specify the operating system / browser and browser version where we want to run the test on. The hub which is the central point of the Grid will route all the Selenium command to the requested node.</p>
<p>In this section of the blog we will see how to set up Selenium Grid and how to make use of some common properties.</p>
]]></content:encoded>
			<wfw:commentRss>http://selenium.polteq.com/en/selenium-grid-2-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running tests on an Android simulator</title>
		<link>http://selenium.polteq.com/en/running-tests-on-an-android-simulator/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=running-tests-on-an-android-simulator</link>
		<comments>http://selenium.polteq.com/en/running-tests-on-an-android-simulator/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 15:40:23 +0000</pubDate>
		<dc:creator>Roy de Kleijn</dc:creator>
				<category><![CDATA[Testing on Mobile Browsers]]></category>

		<guid isPermaLink="false">http://selenium.polteq.com/?p=690</guid>
		<description><![CDATA[Problem The android driver allows us to execute our tests against an Android browser. This can be a simulator or a real device. This recipe will walk us through the steps we have to do to run our tests in &#8230; <a href="http://selenium.polteq.com/en/running-tests-on-an-android-simulator/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h1>Problem</h1>
<p>The android driver allows us to execute our tests against an Android browser. This can be a simulator or a real device. This recipe will walk us through the steps we have to do to run our tests in a simulator.</p>
<h1>Prerequisites</h1>
<p>Before we can register our simulator we have to download the android SDK (Software Development Kit) from the following location: <a href="http://developer.android.com/sdk/" title="http://developer.android.com/sdk/" target="_blank">http://developer.android.com/sdk/</a></p>
<h1>Solution</h1>
<p>We can divide this section into three parts: setup the emulator, install the WebDriver APK and finally run the test.</p>
<p><strong>Setup the emulator</strong></p>
<p>Navigate to the tools directory and create an Android Virtual Device.</p>
<div class="highlight-wrapper console">
<div class="tools">
<div class="wrap">
<a href="#" class="show-raw">raw</a><a href="#" class="show-colored">highlighted</a><a href="#" class="to-clipboard">copy</a><a href="#" class="print">print</a><a href="#" class="about">?</a>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<pre class="raw"><code lang="console">
$cd ~/android_sdk/tools/
$./android create avd -n my_android -t 12 -c 100M
</code></pre>
<div class="highlighted">
<table class="highlighttable">
<tr>
<td class="linenos">
<div class="linenodiv">
<pre class="nl">1
2</pre>
</div>
</td>
<td class="code">
<div class="highlight">
<pre><span class="gp">$</span><span class="nb">cd</span> ~/android_sdk/tools/
<span class="gp">$</span>./android create avd -n my_android -t 12 -c 100M
</pre>
</div>
</td>
</tr>
</table>
</div>
</div>
<blockquote>
<p>-n: specifies the name of the AVD -t: specifies the platform target -c: specifies the SD card storage space</p>
</blockquote>
<p>We can list the targets with the following command to check if the creation succeeded:</p>
<p><code>./android list targets</code></p>
<p>Finally we can start the emulator with the following command:</p>
<p><code>$./emulator -avd my_android &amp;</code></p>
<p><strong>Install the WebDriver APK</strong></p>
<ol>
<li>We need to retrieve the serial id with the following command: <code>/android_sdk/platform-tools/adb devices</code>
</li>
<li>Download the Android server from <a href="http://code.google.com/p/selenium/downloads/list" title="http://code.google.com/p/selenium/downloads/list" target="_blank">http://code.google.com/p/selenium/downloads/list</a> and save it in the platform-tools directory. To install the application enter: <code>$./adb -s &lt;serialId&gt; -e install -r android-server.apk</code> </li>
<li>Start the Android WebDriver application,by running this command: <code>$./adb -s &lt;serialId&gt; shell am start -a android.intent.action.MAIN -n org.openqa.selenium.android.app/.MainActivity</code> </li>
<li>Now we need to setup the port forwarding in order to forward traffic from the host machine to the emulator. Enter the following in the terminal: <code>$./adb -s &lt;serialId&gt; forward tcp:8080 tcp:8080</code>
</li>
</ol>
<p><strong>Run the test</strong></p>
<p>Now we have our environment setup we can run our tests. The test will look like this:</p>
<div class="highlight-wrapper java">
<div class="tools">
<div class="wrap">
<a href="#" class="show-raw">raw</a><a href="#" class="show-colored">highlighted</a><a href="#" class="to-clipboard">copy</a><a href="#" class="print">print</a><a href="#" class="about">?</a>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<pre class="raw"><code lang="java">
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.android.AndroidDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class MobileAndroidDevice {
    private static WebDriver driver;

    @BeforeClass
    public void setUp() throws Exception {
        driver = new AndroidDriver();
        driver.get("http://selenium.polteq.com/prestashop/");
    }

    @AfterClass
    public void tearDown() {
        driver.close();
        driver.quit();
    }

    @Test
    public void measurePerformance() throws InterruptedException {
        Thread.sleep(1500);
        driver.findElement(By.cssSelector("input#search_query_top")).sendKeys("ipod nano");
        driver.findElement(By.cssSelector("input[name='submit_search']")).click();
        String searchHeader = driver.findElement(By.cssSelector("H1")).getText().toLowerCase();

        Assert.assertTrue(searchHeader.contains("ipod nano"));
    }
}
</code></pre>
<div class="highlighted">
<table class="highlighttable">
<tr>
<td class="linenos">
<div class="linenodiv">
<pre class="nl"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33</pre>
</div>
</td>
<td class="code">
<div class="highlight">
<pre><span class="kn">import</span> <span class="nn">org.openqa.selenium.By</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.openqa.selenium.WebDriver</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.openqa.selenium.android.AndroidDriver</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.Assert</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.annotations.AfterClass</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.annotations.BeforeClass</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.annotations.Test</span><span class="o">;</span>

<span class="kd">public</span> <span class="kd">class</span> <span class="nc">MobileAndroidDevice</span> <span class="o">{</span>
    <span class="kd">private</span> <span class="kd">static</span> <span class="n">WebDriver</span> <span class="n">driver</span><span class="o">;</span>

    <span class="nd">@BeforeClass</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">setUp</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span>
        <span class="n">driver</span> <span class="o">=</span> <span class="k">new</span> <span class="n">AndroidDriver</span><span class="o">();</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"http://selenium.polteq.com/prestashop/"</span><span class="o">);</span>
    <span class="o">}</span>

    <span class="nd">@AfterClass</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">tearDown</span><span class="o">()</span> <span class="o">{</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">close</span><span class="o">();</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">quit</span><span class="o">();</span>
    <span class="o">}</span>

    <span class="nd">@Test</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">measurePerformance</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">InterruptedException</span> <span class="o">{</span>
        <span class="n">Thread</span><span class="o">.</span><span class="na">sleep</span><span class="o">(</span><span class="mi">1500</span><span class="o">);</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"input#search_query_top"</span><span class="o">)).</span><span class="na">sendKeys</span><span class="o">(</span><span class="s">"ipod nano"</span><span class="o">);</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"input[name='submit_search']"</span><span class="o">)).</span><span class="na">click</span><span class="o">();</span>
        <span class="n">String</span> <span class="n">searchHeader</span> <span class="o">=</span> <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"H1"</span><span class="o">)).</span><span class="na">getText</span><span class="o">().</span><span class="na">toLowerCase</span><span class="o">();</span>

        <span class="n">Assert</span><span class="o">.</span><span class="na">assertTrue</span><span class="o">(</span><span class="n">searchHeader</span><span class="o">.</span><span class="na">contains</span><span class="o">(</span><span class="s">"ipod nano"</span><span class="o">));</span>
    <span class="o">}</span>
<span class="o">}</span>
</pre>
</div>
</td>
</tr>
</table>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://selenium.polteq.com/en/running-tests-on-an-android-simulator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running tests on a real Android device</title>
		<link>http://selenium.polteq.com/en/running-tests-on-a-real-android-device-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=running-tests-on-a-real-android-device-2</link>
		<comments>http://selenium.polteq.com/en/running-tests-on-a-real-android-device-2/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 15:12:37 +0000</pubDate>
		<dc:creator>Roy de Kleijn</dc:creator>
				<category><![CDATA[Testing on Mobile Browsers]]></category>

		<guid isPermaLink="false">http://selenium.polteq.com/?p=665</guid>
		<description><![CDATA[Problem We want to run our testscripts on a real Android device. The android driver allows us to execute our tests against an Android browser. This can be a simulator or a real device. Prerequisites Before we can register our &#8230; <a href="http://selenium.polteq.com/en/running-tests-on-a-real-android-device-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h1>Problem</h1>
<p>We want to run our testscripts on a real Android device. The android driver allows us to execute our tests against an Android browser. This can be a simulator or a real device.</p>
<h1>Prerequisites</h1>
<p>Before we can register our device we have to download the android SDK (Software Development Kit) from the following location: <a href="http://developer.android.com/sdk/" title="http://developer.android.com/sdk/" target="_blank">http://developer.android.com/sdk/</a></p>
<h1>Solution</h1>
<p>We can divide this section into three parts: setup the device, install the WebDriver APK and finally run the test.</p>
<p><strong>Setup the device</strong></p>
<p>Connect the android device with the computer using a USB cable.</p>
<p><strong>Install the WebDriver APK</strong></p>
<ol>
<li>We need to retrieve the serial id with the following command: <code>/android_sdk/platform-tools/adb devices</code>
</li>
<li>Download the Android server from <a href="http://code.google.com/p/selenium/downloads/list" title="http://code.google.com/p/selenium/downloads/list" target="_blank">http://code.google.com/p/selenium/downloads/list</a> and save it in the platform-tools directory. To install the application enter: <code>$./adb -s &lt;serialId&gt; -e install -r android-server.apk</code> </li>
<li>Start the Android WebDriver application,by running this command: <code>$./adb -s &lt;serialId&gt; shell am start -a android.intent.action.MAIN -n org.openqa.selenium.android.app/.MainActivity</code> </li>
<li>Now we need to setup the port forwarding in order to forward traffic from the host machine to the emulator. Enter the following in the terminal: <code>$./adb -s &lt;serialId&gt; forward tcp:8080 tcp:8080</code>
</li>
</ol>
<p><strong>Run the test</strong></p>
<p>Now we have our environment setup we can run our tests. The test will look like this:</p>
<div class="highlight-wrapper java">
<div class="tools">
<div class="wrap">
<a href="#" class="show-raw">raw</a><a href="#" class="show-colored">highlighted</a><a href="#" class="to-clipboard">copy</a><a href="#" class="print">print</a><a href="#" class="about">?</a>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<pre class="raw"><code lang="java">
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.android.AndroidDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class MobileAndroidDevice {
    private static WebDriver driver;

    @BeforeClass
    public void setUp() throws Exception {
        driver = new AndroidDriver();
        driver.get("http://selenium.polteq.com/prestashop/");
    }

    @AfterClass
    public void tearDown() {
        driver.close();
        driver.quit();
    }

    @Test
    public void measurePerformance() throws InterruptedException {
        Thread.sleep(1500);
        driver.findElement(By.cssSelector("input#search_query_top")).sendKeys("ipod nano");
        driver.findElement(By.cssSelector("input[name='submit_search']")).click();
        String searchHeader = driver.findElement(By.cssSelector("H1")).getText().toLowerCase();

        Assert.assertTrue(searchHeader.contains("ipod nano"));
    }
}
</code></pre>
<div class="highlighted">
<table class="highlighttable">
<tr>
<td class="linenos">
<div class="linenodiv">
<pre class="nl"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33</pre>
</div>
</td>
<td class="code">
<div class="highlight">
<pre><span class="kn">import</span> <span class="nn">org.openqa.selenium.By</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.openqa.selenium.WebDriver</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.openqa.selenium.android.AndroidDriver</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.Assert</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.annotations.AfterClass</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.annotations.BeforeClass</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.annotations.Test</span><span class="o">;</span>

<span class="kd">public</span> <span class="kd">class</span> <span class="nc">MobileAndroidDevice</span> <span class="o">{</span>
    <span class="kd">private</span> <span class="kd">static</span> <span class="n">WebDriver</span> <span class="n">driver</span><span class="o">;</span>

    <span class="nd">@BeforeClass</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">setUp</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span>
        <span class="n">driver</span> <span class="o">=</span> <span class="k">new</span> <span class="n">AndroidDriver</span><span class="o">();</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"http://selenium.polteq.com/prestashop/"</span><span class="o">);</span>
    <span class="o">}</span>

    <span class="nd">@AfterClass</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">tearDown</span><span class="o">()</span> <span class="o">{</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">close</span><span class="o">();</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">quit</span><span class="o">();</span>
    <span class="o">}</span>

    <span class="nd">@Test</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">measurePerformance</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">InterruptedException</span> <span class="o">{</span>
        <span class="n">Thread</span><span class="o">.</span><span class="na">sleep</span><span class="o">(</span><span class="mi">1500</span><span class="o">);</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"input#search_query_top"</span><span class="o">)).</span><span class="na">sendKeys</span><span class="o">(</span><span class="s">"ipod nano"</span><span class="o">);</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"input[name='submit_search']"</span><span class="o">)).</span><span class="na">click</span><span class="o">();</span>
        <span class="n">String</span> <span class="n">searchHeader</span> <span class="o">=</span> <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"H1"</span><span class="o">)).</span><span class="na">getText</span><span class="o">().</span><span class="na">toLowerCase</span><span class="o">();</span>

        <span class="n">Assert</span><span class="o">.</span><span class="na">assertTrue</span><span class="o">(</span><span class="n">searchHeader</span><span class="o">.</span><span class="na">contains</span><span class="o">(</span><span class="s">"ipod nano"</span><span class="o">));</span>
    <span class="o">}</span>
<span class="o">}</span>
</pre>
</div>
</td>
</tr>
</table>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://selenium.polteq.com/en/running-tests-on-a-real-android-device-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running against a real iPhone device</title>
		<link>http://selenium.polteq.com/en/running-against-a-real-iphone-device-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=running-against-a-real-iphone-device-2</link>
		<comments>http://selenium.polteq.com/en/running-against-a-real-iphone-device-2/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 14:53:08 +0000</pubDate>
		<dc:creator>Roy de Kleijn</dc:creator>
				<category><![CDATA[Testing on Mobile Browsers]]></category>

		<guid isPermaLink="false">http://selenium.polteq.com/?p=642</guid>
		<description><![CDATA[Problem We want to execute our testscripts on a iphone device. The iphone driver allows us to execute the WebDriver tests on a real iphone device. Prerequisites We need to install Xcode which is available for the Mac operating systems. &#8230; <a href="http://selenium.polteq.com/en/running-against-a-real-iphone-device-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h1>Problem</h1>
<p>We want to execute our testscripts on a iphone device. The iphone driver allows us to execute the WebDriver tests on a real iphone device.</p>
<h1>Prerequisites</h1>
<p>We need to install Xcode which is available for the Mac operating systems. We also need a provisoning profile for running the script on a real device.</p>
<ol>
<li>We need to create a provisioning profile, so go to this website <a href="http://developer.apple.com/programs/ios/" title="http://developer.apple.com/programs/ios/" target="_blank">http://developer.apple.com/programs/ios/</a> and create a profile. </li>
<li>We need to download Xcode from the following location: <a href="http://developer.apple.com/iphone" title="http://developer.apple.com/iphone" target="_blank">http://developer.apple.com/iphone</a> </li>
<li>The iPhone WebDriver application is not available from the App Store, therefore we need to check-out the code and build it manually. We can do the check-out by entering the following terminal command: <code>svn checkout http://selenium.googlecode.com/svn/trunk/ selenium-read-only</code>
</li>
</ol>
<blockquote>
<p>More information on SVN checkouts: <a href="http://www.linuxfromscratch.org/blfs/edguide/chapter03.html" target="_blank">http://www.linuxfromscratch.org/blfs/edguide/chapter03.html</a></p>
</blockquote>
<h1>Solution</h1>
<ol>
<li>Open the project <code>selenium-read-only/iphone/iWebDriver.xcodeproj</code> in Xcode.</li>
<li>Double-click on the project and set the build configuration to the latest version of the iPhone Simulator, by using the drop-down box in the top left corner.</li>
<li>Configure and install the iPhone provisioning profile.</li>
<li>Open <code>Info.plist</code> and edit the <code>Bundle Identifier</code> to <code>com.NAME.$ {PRODUCT_NAME:identifier}</code> where <code>NAME</code> is the name you registered your provisioning profile to be an authority on.</li>
<li>Make sure your device is connected to your computer. Your device must also be routable from your computer. The easiest way to do this is to configure a wifi network and connect your device to it.</li>
<li>Click on Run (play button). After compiling, the iphone simulator should appear and the <code>iWebDriver</code> app will be installed in it.</li>
<li>Now we can use the IPhoneDriver in our tests.</li>
</ol>
<div class="highlight-wrapper java">
<div class="tools">
<div class="wrap">
<a href="#" class="show-raw">raw</a><a href="#" class="show-colored">highlighted</a><a href="#" class="to-clipboard">copy</a><a href="#" class="print">print</a><a href="#" class="about">?</a>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<pre class="raw"><code lang="java">
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.iphone.IPhoneDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class MobileIphoneSimulator {
    private static WebDriver driver;

    @BeforeClass
    public void setUp() throws Exception {
        driver = new IPhoneDriver();
        driver.get("http://selenium.polteq.com/prestashop/");
    }

    @AfterClass
    public void tearDown() {
        driver.close();
        driver.quit();
    }

    @Test
    public void measurePerformance() throws InterruptedException {
        Thread.sleep(1500);
        driver.findElement(By.cssSelector("input#search_query_top")).sendKeys("ipod nano");
        driver.findElement(By.cssSelector("input[name='submit_search']")).click();
        String searchHeader = driver.findElement(By.cssSelector("H1")).getText().toLowerCase();

        Assert.assertTrue(searchHeader.contains("ipod nano"));
    }
}
</code></pre>
<div class="highlighted">
<table class="highlighttable">
<tr>
<td class="linenos">
<div class="linenodiv">
<pre class="nl"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33</pre>
</div>
</td>
<td class="code">
<div class="highlight">
<pre><span class="kn">import</span> <span class="nn">org.openqa.selenium.By</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.openqa.selenium.WebDriver</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.openqa.selenium.iphone.IPhoneDriver</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.Assert</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.annotations.AfterClass</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.annotations.BeforeClass</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.annotations.Test</span><span class="o">;</span>

<span class="kd">public</span> <span class="kd">class</span> <span class="nc">MobileIphoneSimulator</span> <span class="o">{</span>
    <span class="kd">private</span> <span class="kd">static</span> <span class="n">WebDriver</span> <span class="n">driver</span><span class="o">;</span>

    <span class="nd">@BeforeClass</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">setUp</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span>
        <span class="n">driver</span> <span class="o">=</span> <span class="k">new</span> <span class="n">IPhoneDriver</span><span class="o">();</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"http://selenium.polteq.com/prestashop/"</span><span class="o">);</span>
    <span class="o">}</span>

    <span class="nd">@AfterClass</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">tearDown</span><span class="o">()</span> <span class="o">{</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">close</span><span class="o">();</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">quit</span><span class="o">();</span>
    <span class="o">}</span>

    <span class="nd">@Test</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">measurePerformance</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">InterruptedException</span> <span class="o">{</span>
        <span class="n">Thread</span><span class="o">.</span><span class="na">sleep</span><span class="o">(</span><span class="mi">1500</span><span class="o">);</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"input#search_query_top"</span><span class="o">)).</span><span class="na">sendKeys</span><span class="o">(</span><span class="s">"ipod nano"</span><span class="o">);</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"input[name='submit_search']"</span><span class="o">)).</span><span class="na">click</span><span class="o">();</span>
        <span class="n">String</span> <span class="n">searchHeader</span> <span class="o">=</span> <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"H1"</span><span class="o">)).</span><span class="na">getText</span><span class="o">().</span><span class="na">toLowerCase</span><span class="o">();</span>

        <span class="n">Assert</span><span class="o">.</span><span class="na">assertTrue</span><span class="o">(</span><span class="n">searchHeader</span><span class="o">.</span><span class="na">contains</span><span class="o">(</span><span class="s">"ipod nano"</span><span class="o">));</span>
    <span class="o">}</span>
<span class="o">}</span>
</pre>
</div>
</td>
</tr>
</table>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://selenium.polteq.com/en/running-against-a-real-iphone-device-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Running tests on a Xcode iPhone simulator</title>
		<link>http://selenium.polteq.com/en/running-tests-on-a-xcode-iphone-simulator-3/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=running-tests-on-a-xcode-iphone-simulator-3</link>
		<comments>http://selenium.polteq.com/en/running-tests-on-a-xcode-iphone-simulator-3/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 14:40:22 +0000</pubDate>
		<dc:creator>Roy de Kleijn</dc:creator>
				<category><![CDATA[Testing on Mobile Browsers]]></category>

		<guid isPermaLink="false">http://selenium.polteq.com/?p=653</guid>
		<description><![CDATA[Problem We want to run our test in a iPhone simulator. The iphone simulator comes with Xcode which is available for the Mac operating systems. This recipe will show us how we can run our WebDriver tests in a iphone &#8230; <a href="http://selenium.polteq.com/en/running-tests-on-a-xcode-iphone-simulator-3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h1>Problem</h1>
<p>We want to run our test in a iPhone simulator. The iphone simulator comes with Xcode which is available for the Mac operating systems. This recipe will show us how we can run our WebDriver tests in a iphone simulator.</p>
<h1>Prerequisites</h1>
<p>We need to download Xcode from the following location: <a href="http://developer.apple.com/iphone" title="http://developer.apple.com/iphone" target="_blank">http://developer.apple.com/iphone</a></p>
<p>The iPhone WebDriver application is not available from the App Store, therefore we need to check-out the code and build it manually. We can do the check-out by entering the following terminal command: <code>svn checkout http://selenium.googlecode.com/svn/trunk/ selenium-read-only</code></p>
<blockquote>
<p>More information on SVN checkouts: <a href="http://www.linuxfromscratch.org/blfs/edguide/chapter03.html" target="_blank">http://www.linuxfromscratch.org/blfs/edguide/chapter03.html</a></p>
</blockquote>
<h1>Solution</h1>
<ol>
<li>Open the project <code>selenium-read-only/iphone/iWebDriver.xcodeproj</code> in Xcode.</li>
<li>Double-click on the project and set the build configuration to the latest version of the iPhone Simulator, by using the drop-down box in the top left corner.</li>
<li>Click on Run (play button). After compiling, the iphone simulator should appear and the iWebDriver app will be installed in it.</li>
<li>Now we can use the IPhoneDriver in our tests.</li>
</ol>
<div class="highlight-wrapper java">
<div class="tools">
<div class="wrap">
<a href="#" class="show-raw">raw</a><a href="#" class="show-colored">highlighted</a><a href="#" class="to-clipboard">copy</a><a href="#" class="print">print</a><a href="#" class="about">?</a>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
<pre class="raw"><code lang="java">
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.iphone.IPhoneDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class MobileIphoneSimulator {
    private static WebDriver driver;

    @BeforeClass
    public void setUp() throws Exception {
        driver = new IPhoneDriver();
        driver.get("http://selenium.polteq.com/prestashop/");
    }

    @AfterClass
    public void tearDown() {
        driver.close();
        driver.quit();
    }

    @Test
    public void measurePerformance() throws InterruptedException {
        Thread.sleep(1500);
        driver.findElement(By.cssSelector("input#search_query_top")).sendKeys("ipod nano");
        driver.findElement(By.cssSelector("input[name='submit_search']")).click();
        String searchHeader = driver.findElement(By.cssSelector("H1")).getText().toLowerCase();

        Assert.assertTrue(searchHeader.contains("ipod nano"));
    }
}
</code></pre>
<div class="highlighted">
<table class="highlighttable">
<tr>
<td class="linenos">
<div class="linenodiv">
<pre class="nl"> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33</pre>
</div>
</td>
<td class="code">
<div class="highlight">
<pre><span class="kn">import</span> <span class="nn">org.openqa.selenium.By</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.openqa.selenium.WebDriver</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.openqa.selenium.iphone.IPhoneDriver</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.Assert</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.annotations.AfterClass</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.annotations.BeforeClass</span><span class="o">;</span>
<span class="kn">import</span> <span class="nn">org.testng.annotations.Test</span><span class="o">;</span>

<span class="kd">public</span> <span class="kd">class</span> <span class="nc">MobileIphoneSimulator</span> <span class="o">{</span>
    <span class="kd">private</span> <span class="kd">static</span> <span class="n">WebDriver</span> <span class="n">driver</span><span class="o">;</span>

    <span class="nd">@BeforeClass</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">setUp</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span>
        <span class="n">driver</span> <span class="o">=</span> <span class="k">new</span> <span class="n">IPhoneDriver</span><span class="o">();</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="s">"http://selenium.polteq.com/prestashop/"</span><span class="o">);</span>
    <span class="o">}</span>

    <span class="nd">@AfterClass</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">tearDown</span><span class="o">()</span> <span class="o">{</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">close</span><span class="o">();</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">quit</span><span class="o">();</span>
    <span class="o">}</span>

    <span class="nd">@Test</span>
    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">measurePerformance</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">InterruptedException</span> <span class="o">{</span>
        <span class="n">Thread</span><span class="o">.</span><span class="na">sleep</span><span class="o">(</span><span class="mi">1500</span><span class="o">);</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"input#search_query_top"</span><span class="o">)).</span><span class="na">sendKeys</span><span class="o">(</span><span class="s">"ipod nano"</span><span class="o">);</span>
        <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"input[name='submit_search']"</span><span class="o">)).</span><span class="na">click</span><span class="o">();</span>
        <span class="n">String</span> <span class="n">searchHeader</span> <span class="o">=</span> <span class="n">driver</span><span class="o">.</span><span class="na">findElement</span><span class="o">(</span><span class="n">By</span><span class="o">.</span><span class="na">cssSelector</span><span class="o">(</span><span class="s">"H1"</span><span class="o">)).</span><span class="na">getText</span><span class="o">().</span><span class="na">toLowerCase</span><span class="o">();</span>

        <span class="n">Assert</span><span class="o">.</span><span class="na">assertTrue</span><span class="o">(</span><span class="n">searchHeader</span><span class="o">.</span><span class="na">contains</span><span class="o">(</span><span class="s">"ipod nano"</span><span class="o">));</span>
    <span class="o">}</span>
<span class="o">}</span>
</pre>
</div>
</td>
</tr>
</table>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://selenium.polteq.com/en/running-tests-on-a-xcode-iphone-simulator-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

