|  | 
| 82 | 82 | </span></span></code></pre></div><br><h3 id=add-to-projects-gemfile>Add to project’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>'selenium-devtools'</span><span style=color:#000;font-weight:700>,</span> <span style=color:#4e9a06>'= 0.130.0'</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> | 
| 83 | 83 | <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 | 
| 84 | 84 | <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’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>"mocha"</span><span style=color:#a40000>:</span> <span style=color:#4e9a06>"10.7.3"</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’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>"mocha"</span><span style=color:#a40000>:</span> <span style=color:#4e9a06>"10.8.2"</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> | 
| 86 | 86 | <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>, | 
| 87 | 87 | you’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. | 
| 88 | 88 | Most of what you’ll do with Selenium is a combination of these basic commands</p><p>Click on the link to “View full example on GitHub” 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 | 2186 | 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> | 
| 2187 | 2187 | 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> | 
| 2188 | 2188 | 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>'/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver'</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> | 
| 2190 | 2196 | </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> | 
| 2191 | 2197 | <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 | 
| 2192 | 2198 | that the web application is in a state to execute a particular | 
|  | 
| 6088 | 6094 | </span></span><span style=display:flex><span>      <span style=color:#0000cf;font-weight:700>0</span><span style=color:#000;font-weight:700>);</span> | 
| 6089 | 6095 | </span></span><span style=display:flex><span> | 
| 6090 | 6096 | </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> | 
| 6092 | 6098 | <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> | 
| 6093 | 6099 | 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> | 
| 6094 | 6100 | 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