Skip to content

Commit b9f908a

Browse files
committed
docs: add Python code for Safari Technology Preview (#2039)[deploy site]
Co-authored-by: Sri Harsha <[email protected]> fa77979
1 parent 6c0a058 commit b9f908a

File tree

53 files changed

+1108
-986
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1108
-986
lines changed

documentation/_print/index.html

Lines changed: 59 additions & 53 deletions
Large diffs are not rendered by default.

documentation/about/_print/index.html

Lines changed: 50 additions & 50 deletions
Large diffs are not rendered by default.

documentation/about/copyright/index.html

Lines changed: 50 additions & 50 deletions
Large diffs are not rendered by default.

documentation/webdriver/_print/index.html

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
</span></span></code></pre></div><br><h3 id=add-to-projects-gemfile>Add to project&rsquo;s gemfile</h3><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-Gemfile data-lang=Gemfile><span style=display:flex><span><span style=color:#000>gem</span> <span style=color:#4e9a06>&#39;selenium-devtools&#39;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#4e9a06>&#39;= 0.130.0&#39;</span></span></span></code></pre></div><div class="text-end pb-2"><a href=https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/examples/ruby/Gemfile#L10 target=_blank><i class="fas fa-external-link-alt pl-2"></i>
8383
<strong>View full example on GitHub</strong></a></div></div><div class="tab-body tab-pane fade" id=tabs-00-04 role=tabpanel aria-labelled-by=tabs-00-04-tab tabindex=0><p>You can find the minimum required version of Node for any given version of Selenium in the
8484
<code>Node Support Policy</code> section on <a href=https://www.npmjs.com/package/selenium-webdriver>npmjs</a></p><p>Selenium is typically installed using npm.</p><h3 id=install-locally>Install locally</h3><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-shell data-lang=shell><span style=display:flex><span>npm install selenium-webdriver
85-
</span></span></code></pre></div><br><h3 id=add-to-project>Add to project</h3><p>In your project&rsquo;s <code>package.json</code>, add requirement to <code>dependencies</code>:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span> <span style=color:#4e9a06>&#34;mocha&#34;</span><span style=color:#a40000>:</span> <span style=color:#4e9a06>&#34;10.7.3&#34;</span></span></span></code></pre></div><div class="text-end pb-2"><a href=https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/examples/javascript/package.json#L14 target=_blank><i class="fas fa-external-link-alt pl-2"></i>
85+
</span></span></code></pre></div><br><h3 id=add-to-project>Add to project</h3><p>In your project&rsquo;s <code>package.json</code>, add requirement to <code>dependencies</code>:</p><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-json data-lang=json><span style=display:flex><span> <span style=color:#4e9a06>&#34;mocha&#34;</span><span style=color:#a40000>:</span> <span style=color:#4e9a06>&#34;10.8.2&#34;</span></span></span></code></pre></div><div class="text-end pb-2"><a href=https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/examples/javascript/package.json#L14 target=_blank><i class="fas fa-external-link-alt pl-2"></i>
8686
<strong>View full example on GitHub</strong></a></div></div><div class="tab-body tab-pane fade" id=tabs-00-05 role=tabpanel aria-labelled-by=tabs-00-05-tab tabindex=0>Use the Java bindings for Kotlin.</div></div><h2 id=next-step>Next Step</h2><p><a href=https://www.selenium.dev/documentation/webdriver/getting_started/first_script/>Create your first Selenium script</a></p></div><div class=td-content style=page-break-before:always><h1 id=pg-422333a0d0201faac798caa658508cf1>1.2 - Write your first Selenium script</h1><div class=lead>Step-by-step instructions for constructing a Selenium script</div><p>Once you have <a href=https://www.selenium.dev/documentation/webdriver/getting_started/install_library/>Selenium installed</a>,
8787
you&rsquo;re ready to write Selenium code.</p><h2 id=eight-basic-components>Eight Basic Components</h2><p>Everything Selenium does is send the browser commands to do something or send requests for information.
8888
Most of what you&rsquo;ll do with Selenium is a combination of these basic commands</p><p>Click on the link to &ldquo;View full example on GitHub&rdquo; to see the code in context.</p><h3 id=1-start-the-session>1. Start the session</h3><p>For more details on starting a session read our documentation on <a href=https://www.selenium.dev/documentation/webdriver/drivers/>driver sessions</a></p><ul class="nav nav-tabs" id=tabs-2 role=tablist><li class=nav-item><button class="nav-link active" id=tabs-02-00-tab data-bs-toggle=tab data-bs-target=#tabs-02-00 role=tab data-td-tp-persist=java aria-controls=tabs-02-00 aria-selected=true>
@@ -2186,7 +2186,13 @@
21862186
CSharp</button></li><li class=nav-item><button class=nav-link id=tabs-04-03-tab data-bs-toggle=tab data-bs-target=#tabs-04-03 role=tab data-td-tp-persist=ruby aria-controls=tabs-04-03 aria-selected=false>
21872187
Ruby</button></li><li class=nav-item><button class=nav-link id=tabs-04-04-tab data-bs-toggle=tab data-bs-target=#tabs-04-04 role=tab data-td-tp-persist=javascript aria-controls=tabs-04-04 aria-selected=false>
21882188
JavaScript</button></li><li class=nav-item><button class=nav-link id=tabs-04-05-tab data-bs-toggle=tab data-bs-target=#tabs-04-05 role=tab data-td-tp-persist=kotlin aria-controls=tabs-04-05 aria-selected=false>
2189-
Kotlin</button></li></ul><div class=tab-content id=tabs-4-content><div class="tab-body tab-pane fade show active" id=tabs-04-00 role=tabpanel aria-labelled-by=tabs-04-00-tab tabindex=4><p><a href=/documentation/about/contributing/#creating-examples><span class=selenium-badge-code data-bs-toggle=tooltip data-bs-placement=right title="This code example is missing. Examples are added to the examples directory; click for details in the contribution guide">Add Example</span></a></p></div><div class="tab-body tab-pane fade" id=tabs-04-01 role=tabpanel aria-labelled-by=tabs-04-01-tab tabindex=4><p><a href=/documentation/about/contributing/#creating-examples><span class=selenium-badge-code data-bs-toggle=tooltip data-bs-placement=right title="This code example is missing. Examples are added to the examples directory; click for details in the contribution guide">Add Example</span></a></p></div><div class="tab-body tab-pane fade" id=tabs-04-02 role=tabpanel aria-labelled-by=tabs-04-02-tab tabindex=4><p><a href=/documentation/about/contributing/#creating-examples><span class=selenium-badge-code data-bs-toggle=tooltip data-bs-placement=right title="This code example is missing. Examples are added to the examples directory; click for details in the contribution guide">Add Example</span></a></p></div><div class="tab-body tab-pane fade" id=tabs-04-03 role=tabpanel aria-labelled-by=tabs-04-03-tab tabindex=4><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-rb data-lang=rb><span style=display:flex><span> <span style=color:#000>Selenium</span><span style=color:#ce5c00;font-weight:700>::</span><span style=color:#000>WebDriver</span><span style=color:#ce5c00;font-weight:700>::</span><span style=color:#000>Safari</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>technology_preview!</span>
2189+
Kotlin</button></li></ul><div class=tab-content id=tabs-4-content><div class="tab-body tab-pane fade show active" id=tabs-04-00 role=tabpanel aria-labelled-by=tabs-04-00-tab tabindex=4><p><a href=/documentation/about/contributing/#creating-examples><span class=selenium-badge-code data-bs-toggle=tooltip data-bs-placement=right title="This code example is missing. Examples are added to the examples directory; click for details in the contribution guide">Add Example</span></a></p></div><div class="tab-body tab-pane fade" id=tabs-04-01 role=tabpanel aria-labelled-by=tabs-04-01-tab tabindex=4><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-py data-lang=py><span style=display:flex><span> <span style=color:#000>options</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>webdriver</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>SafariOptions</span><span style=color:#000;font-weight:700>()</span>
2190+
</span></span><span style=display:flex><span> <span style=color:#000>options</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>use_technology_preview</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>True</span>
2191+
</span></span><span style=display:flex><span> <span style=color:#000>service</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>webdriver</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>SafariService</span><span style=color:#000;font-weight:700>(</span>
2192+
</span></span><span style=display:flex><span> <span style=color:#000>executable_path</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#4e9a06>&#39;/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver&#39;</span>
2193+
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>)</span>
2194+
</span></span><span style=display:flex><span> <span style=color:#000>driver</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>webdriver</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>Safari</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>options</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#000>options</span><span style=color:#000;font-weight:700>,</span> <span style=color:#000>service</span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#000>service</span><span style=color:#000;font-weight:700>)</span></span></span></code></pre></div><div class="text-end pb-2"><a href=https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/examples/python/tests/browsers/test_safari.py#L25-L30 target=_blank><i class="fas fa-external-link-alt pl-2"></i>
2195+
<strong>View full example on GitHub</strong></a></div></div><div class="tab-body tab-pane fade" id=tabs-04-02 role=tabpanel aria-labelled-by=tabs-04-02-tab tabindex=4><p><a href=/documentation/about/contributing/#creating-examples><span class=selenium-badge-code data-bs-toggle=tooltip data-bs-placement=right title="This code example is missing. Examples are added to the examples directory; click for details in the contribution guide">Add Example</span></a></p></div><div class="tab-body tab-pane fade" id=tabs-04-03 role=tabpanel aria-labelled-by=tabs-04-03-tab tabindex=4><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-rb data-lang=rb><span style=display:flex><span> <span style=color:#000>Selenium</span><span style=color:#ce5c00;font-weight:700>::</span><span style=color:#000>WebDriver</span><span style=color:#ce5c00;font-weight:700>::</span><span style=color:#000>Safari</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>technology_preview!</span>
21902196
</span></span><span style=display:flex><span> <span style=color:#000>local_driver</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>Selenium</span><span style=color:#ce5c00;font-weight:700>::</span><span style=color:#000>WebDriver</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>for</span> <span style=color:#4e9a06>:safari</span></span></span></code></pre></div><div class="text-end pb-2"><a href=https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/examples/ruby/spec/browsers/safari_spec.rb#L38-L39 target=_blank><i class="fas fa-external-link-alt pl-2"></i>
21912197
<strong>View full example on GitHub</strong></a></div></div><div class="tab-body tab-pane fade" id=tabs-04-04 role=tabpanel aria-labelled-by=tabs-04-04-tab tabindex=4><p><a href=/documentation/about/contributing/#creating-examples><span class=selenium-badge-code data-bs-toggle=tooltip data-bs-placement=right title="This code example is missing. Examples are added to the examples directory; click for details in the contribution guide">Add Example</span></a></p></div><div class="tab-body tab-pane fade" id=tabs-04-05 role=tabpanel aria-labelled-by=tabs-04-05-tab tabindex=4><p><a href=/documentation/about/contributing/#creating-examples><span class=selenium-badge-code data-bs-toggle=tooltip data-bs-placement=right title="This code example is missing. Examples are added to the examples directory; click for details in the contribution guide">Add Example</span></a></p></div></div></div><div class=td-content style=page-break-before:always><h1 id=pg-58266faca85e4ab60aaea44c4765d4f7>4 - Waiting Strategies</h1><p>Perhaps the most common challenge for browser automation is ensuring
21922198
that the web application is in a state to execute a particular
@@ -6088,7 +6094,7 @@
60886094
</span></span><span style=display:flex><span> <span style=color:#0000cf;font-weight:700>0</span><span style=color:#000;font-weight:700>);</span>
60896095
</span></span><span style=display:flex><span>
60906096
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>await</span> <span style=color:#000>driver</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>addCredential</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>nonResidentCredential</span><span style=color:#000;font-weight:700>);</span>
6091-
</span></span><span style=display:flex><span> <span style=color:#000>driver</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>removeAllCredentials</span><span style=color:#000;font-weight:700>();</span></span></span></code></pre></div><div class="text-end pb-2"><a href=https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/examples/javascript/test/virtual_authenticator/virtualAuthenticator.spec.js#L181-L190 target=_blank><i class="fas fa-external-link-alt pl-2"></i>
6097+
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>await</span> <span style=color:#000>driver</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>removeAllCredentials</span><span style=color:#000;font-weight:700>();</span></span></span></code></pre></div><div class="text-end pb-2"><a href=https://github.com/SeleniumHQ/seleniumhq.github.io/blob/trunk/examples/javascript/test/virtual_authenticator/virtualAuthenticator.spec.js#L181-L190 target=_blank><i class="fas fa-external-link-alt pl-2"></i>
60926098
<strong>View full example on GitHub</strong></a></div></div><div class="tab-body tab-pane fade" id=tabs-08-05 role=tabpanel aria-labelled-by=tabs-08-05-tab tabindex=8><p><a href=/documentation/about/contributing/#creating-examples><span class=selenium-badge-code data-bs-toggle=tooltip data-bs-placement=right title="This code example is missing. Examples are added to the examples directory; click for details in the contribution guide">Add Example</span></a></p></div></div><h2 id=set-user-verified>Set User Verified</h2><p>Sets whether the authenticator will simulate success or fail on user verification.</p><ul class="nav nav-tabs" id=tabs-9 role=tablist><li class=nav-item><button class="nav-link active" id=tabs-09-00-tab data-bs-toggle=tab data-bs-target=#tabs-09-00 role=tab data-td-tp-persist=java aria-controls=tabs-09-00 aria-selected=true>
60936099
Java</button></li><li class=nav-item><button class=nav-link id=tabs-09-01-tab data-bs-toggle=tab data-bs-target=#tabs-09-01 role=tab data-td-tp-persist=csharp aria-controls=tabs-09-01 aria-selected=false>
60946100
CSharp</button></li><li class=nav-item><button class=nav-link id=tabs-09-02-tab data-bs-toggle=tab data-bs-target=#tabs-09-02 role=tab data-td-tp-persist=ruby aria-controls=tabs-09-02 aria-selected=false>

0 commit comments

Comments
 (0)