Skip to content

Commit

Permalink
LukeIS: bumping python version to 2.18 in prep for release, updating …
Browse files Browse the repository at this point in the history
…changelog, updating pydocs

r15716
  • Loading branch information
lukeis committed Jan 27, 2012
1 parent 6ce98be commit 711a412
Show file tree
Hide file tree
Showing 19 changed files with 99 additions and 23 deletions.
20 changes: 17 additions & 3 deletions docs/api/py/_modules/selenium/webdriver/chrome/webdriver.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ <h1>Source code for selenium.webdriver.chrome.webdriver</h1><div class="highligh

<span class="kn">import</span> <span class="nn">base64</span>
<span class="kn">import</span> <span class="nn">httplib</span>
<span class="kn">from</span> <span class="nn">selenium.webdriver.common.desired_capabilities</span> <span class="kn">import</span> <span class="n">DesiredCapabilities</span>
<span class="kn">import</span> <span class="nn">warnings</span>
<span class="kn">from</span> <span class="nn">selenium.webdriver.remote.command</span> <span class="kn">import</span> <span class="n">Command</span>
<span class="kn">from</span> <span class="nn">selenium.webdriver.remote.webdriver</span> <span class="kn">import</span> <span class="n">WebDriver</span> <span class="k">as</span> <span class="n">RemoteWebDriver</span>
<span class="kn">from</span> <span class="nn">service</span> <span class="kn">import</span> <span class="n">Service</span>
<span class="kn">from</span> <span class="nn">options</span> <span class="kn">import</span> <span class="n">Options</span>

<div class="viewcode-block" id="WebDriver"><a class="viewcode-back" href="../../../../webdriver_chrome/selenium.webdriver.chrome.webdriver.html#selenium.webdriver.chrome.webdriver.WebDriver">[docs]</a><span class="k">class</span> <span class="nc">WebDriver</span><span class="p">(</span><span class="n">RemoteWebDriver</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
Expand All @@ -79,7 +80,7 @@ <h1>Source code for selenium.webdriver.chrome.webdriver</h1><div class="highligh
<span class="sd"> &quot;&quot;&quot;</span>

<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">executable_path</span><span class="o">=</span><span class="s">&quot;chromedriver&quot;</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span>
<span class="n">desired_capabilities</span><span class="o">=</span><span class="n">DesiredCapabilities</span><span class="o">.</span><span class="n">CHROME</span><span class="p">):</span>
<span class="n">desired_capabilities</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">chrome_options</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Creates a new instance of the chrome driver.</span>

Expand All @@ -88,8 +89,21 @@ <h1>Source code for selenium.webdriver.chrome.webdriver</h1><div class="highligh
<span class="sd"> :Args:</span>
<span class="sd"> - executable_path - path to the executable. If the default is used it assumes the executable is in the $PATH</span>
<span class="sd"> - port - port you would like the service to run, if left as 0, a free port will be found.</span>
<span class="sd"> - desired_capabilities: Dictionary object with desired capabilities (Can be used to provide various chrome switches).</span>
<span class="sd"> - desired_capabilities: Dictionary object with desired capabilities (Can be used to provide various chrome</span>
<span class="sd"> switches). This is being deprecated, please use chrome_options</span>
<span class="sd"> - chrome_options: this takes an instance of ChromeOptions</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">chrome_options</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">options</span> <span class="o">=</span> <span class="n">Options</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">options</span> <span class="o">=</span> <span class="n">chrome_options</span>

<span class="k">if</span> <span class="n">desired_capabilities</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s">&quot;Desired Capabilities has been deprecated, please user chrome_options.&quot;</span><span class="p">,</span> <span class="ne">DeprecationWarning</span><span class="p">)</span>
<span class="n">desired_capabilities</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">options</span><span class="o">.</span><span class="n">to_capabilities</span><span class="p">())</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">desired_capabilities</span> <span class="o">=</span> <span class="n">options</span><span class="o">.</span><span class="n">to_capabilities</span><span class="p">()</span>

<span class="bp">self</span><span class="o">.</span><span class="n">service</span> <span class="o">=</span> <span class="n">Service</span><span class="p">(</span><span class="n">executable_path</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="n">port</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">service</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ <h1>Source code for selenium.webdriver.firefox.firefox_profile</h1><div class="h
<span class="kn">import</span> <span class="nn">re</span>
<span class="kn">import</span> <span class="nn">base64</span>
<span class="kn">from</span> <span class="nn">cStringIO</span> <span class="kn">import</span> <span class="n">StringIO</span>
<span class="kn">from</span> <span class="nn">selenium.webdriver.common.proxy</span> <span class="kn">import</span> <span class="n">Proxy</span><span class="p">,</span> <span class="n">ProxyType</span>

<span class="n">WEBDRIVER_EXT</span> <span class="o">=</span> <span class="s">&quot;webdriver.xpi&quot;</span>
<span class="n">EXTENSION_NAME</span> <span class="o">=</span> <span class="s">&quot;fxdriver@googlecode.com&quot;</span>
Expand Down Expand Up @@ -120,7 +121,9 @@ <h1>Source code for selenium.webdriver.firefox.firefox_profile</h1><div class="h
<span class="s">&quot;security.warn_viewing_mixed.show_once&quot;</span><span class="p">:</span> <span class="s">&quot;false&quot;</span><span class="p">,</span>
<span class="s">&quot;signon.rememberSignons&quot;</span><span class="p">:</span> <span class="s">&quot;false&quot;</span><span class="p">,</span>
<span class="s">&quot;toolkit.networkmanager.disable&quot;</span><span class="p">:</span> <span class="s">&quot;true&quot;</span><span class="p">,</span>
<span class="s">&quot;toolkit.telemetry.enabled&quot;</span><span class="p">:</span> <span class="s">&quot;false&quot;</span><span class="p">,</span>
<span class="s">&quot;toolkit.telemetry.prompted&quot;</span><span class="p">:</span> <span class="s">&quot;2&quot;</span><span class="p">,</span>
<span class="s">&quot;toolkit.telemetry.rejected&quot;</span><span class="p">:</span> <span class="s">&quot;true&quot;</span><span class="p">,</span>
<span class="s">&quot;javascript.options.showInConsole&quot;</span><span class="p">:</span> <span class="s">&quot;true&quot;</span><span class="p">,</span>
<span class="s">&quot;browser.dom.window.dump.enabled&quot;</span><span class="p">:</span> <span class="s">&quot;true&quot;</span><span class="p">,</span>
<span class="s">&quot;webdriver_accept_untrusted_certs&quot;</span><span class="p">:</span> <span class="s">&quot;true&quot;</span><span class="p">,</span>
Expand Down Expand Up @@ -163,6 +166,8 @@ <h1>Source code for selenium.webdriver.firefox.firefox_profile</h1><div class="h
<span class="n">clean_value</span> <span class="o">=</span> <span class="s">&#39;false&#39;</span>
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
<span class="n">clean_value</span> <span class="o">=</span> <span class="s">&#39;&quot;</span><span class="si">%s</span><span class="s">&quot;&#39;</span> <span class="o">%</span> <span class="n">value</span>
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="nb">unicode</span><span class="p">):</span>
<span class="n">clean_value</span> <span class="o">=</span> <span class="s">&#39;&quot;</span><span class="si">%s</span><span class="s">&quot;&#39;</span> <span class="o">%</span> <span class="n">value</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">clean_value</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">value</span><span class="p">))</span>

Expand Down Expand Up @@ -230,10 +235,35 @@ <h1>Source code for selenium.webdriver.firefox.firefox_profile</h1><div class="h
<span class="n">zipped</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">filename</span><span class="p">[</span><span class="n">path_root</span><span class="p">:])</span>
<span class="n">zipped</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
<span class="k">return</span> <span class="n">base64</span><span class="o">.</span><span class="n">encodestring</span><span class="p">(</span><span class="n">fp</span><span class="o">.</span><span class="n">getvalue</span><span class="p">())</span>
</div>
<div class="viewcode-block" id="FirefoxProfile.set_proxy"><a class="viewcode-back" href="../../../../webdriver_firefox/selenium.webdriver.firefox.firefox_profile.html#selenium.webdriver.firefox.firefox_profile.FirefoxProfile.set_proxy">[docs]</a> <span class="k">def</span> <span class="nf">set_proxy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">proxy</span><span class="p">):</span>
<span class="k">if</span> <span class="n">proxy</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s">&quot;proxy can not be None&quot;</span><span class="p">)</span>

<span class="k">if</span> <span class="n">proxy</span><span class="o">.</span><span class="n">proxy_type</span> <span class="ow">is</span> <span class="n">ProxyType</span><span class="o">.</span><span class="n">UNSPECIFIED</span><span class="p">:</span>
<span class="k">return</span>

<span class="bp">self</span><span class="o">.</span><span class="n">set_preference</span><span class="p">(</span><span class="s">&quot;network.proxy.type&quot;</span><span class="p">,</span> <span class="n">proxy</span><span class="o">.</span><span class="n">proxy_type</span><span class="p">[</span><span class="s">&#39;ff_value&#39;</span><span class="p">])</span>

<span class="k">if</span> <span class="n">proxy</span><span class="o">.</span><span class="n">proxy_type</span> <span class="ow">is</span> <span class="n">ProxyType</span><span class="o">.</span><span class="n">MANUAL</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">set_preference</span><span class="p">(</span><span class="s">&quot;network.proxy.no_proxies_on&quot;</span><span class="p">,</span> <span class="n">proxy</span><span class="o">.</span><span class="n">no_proxy</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_set_manual_proxy_preference</span><span class="p">(</span><span class="s">&quot;ftp&quot;</span><span class="p">,</span> <span class="n">proxy</span><span class="o">.</span><span class="n">ftp_proxy</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_set_manual_proxy_preference</span><span class="p">(</span><span class="s">&quot;http&quot;</span><span class="p">,</span> <span class="n">proxy</span><span class="o">.</span><span class="n">http_proxy</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_set_manual_proxy_preference</span><span class="p">(</span><span class="s">&quot;ssl&quot;</span><span class="p">,</span> <span class="n">proxy</span><span class="o">.</span><span class="n">ssl_proxy</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">proxy</span><span class="o">.</span><span class="n">proxy_type</span> <span class="ow">is</span> <span class="n">ProxyType</span><span class="o">.</span><span class="n">AUTODETECT</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">set_preference</span><span class="p">(</span><span class="s">&quot;network.proxy.autoconfig_url&quot;</span><span class="p">,</span> <span class="n">proxy</span><span class="o">.</span><span class="n">proxy_autoconfig_url</span><span class="p">)</span>

<span class="c">#Private Methods</span>
</div>
<span class="k">def</span> <span class="nf">_set_manual_proxy_preference</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">setting</span><span class="p">):</span>
<span class="k">if</span> <span class="n">setting</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">or</span> <span class="n">setting</span> <span class="ow">is</span> <span class="s">&#39;&#39;</span><span class="p">:</span>
<span class="k">return</span>

<span class="n">host_details</span> <span class="o">=</span> <span class="n">setting</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s">&quot;:&quot;</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">set_preference</span><span class="p">(</span><span class="s">&quot;network.proxy.</span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">key</span><span class="p">,</span> <span class="n">host_details</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">2</span><span class="p">:])</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">host_details</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">set_preference</span><span class="p">(</span><span class="s">&quot;network.proxy.</span><span class="si">%s</span><span class="s">_port&quot;</span> <span class="o">%</span> <span class="n">key</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="n">host_details</span><span class="p">[</span><span class="mi">2</span><span class="p">]))</span>

<span class="k">def</span> <span class="nf">_create_tempfolder</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Creates a temp folder to store User.js and the extension</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ <h1>Source code for selenium.webdriver.remote.webdriver</h1><div class="highligh
<span class="sd"> Switches focus to the specified window.</span>

<span class="sd"> :Args:</span>
<span class="sd"> - window_name: The name of the window to switch to.</span>
<span class="sd"> - window_name: The name or window handle of the window to switch to.</span>

<span class="sd"> :Usage:</span>
<span class="sd"> driver.switch_to_window(&#39;main&#39;)</span>
Expand Down
Loading

0 comments on commit 711a412

Please sign in to comment.