Skip to content

Commit

Permalink
[JS] Link code sample to github [deploy site] a4156d4
Browse files Browse the repository at this point in the history
  • Loading branch information
selenium-ci committed Apr 16, 2024
1 parent a7504b2 commit c218b05
Show file tree
Hide file tree
Showing 29 changed files with 137 additions and 341 deletions.
30 changes: 8 additions & 22 deletions documentation/_print/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5362,26 +5362,12 @@
</span></span><span style=display:flex><span> </span></span></code></pre></div></div><div class="tab-pane fade" id=tabs-17-04 role=tabpanel aria-labelled-by=tabs-17-04-tab tabindex=17><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-Ruby data-lang=Ruby><span style=display:flex><span> <span style=color:#000>driver</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>navigate_to</span> <span style=color:#4e9a06>&#39;https://www.selenium.dev&#39;</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#000>base64encodedContent</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>driver</span><span style=color:#ce5c00;font-weight:700>.</span><span style=color:#000>print_page</span><span style=color:#000;font-weight:700>(</span><span style=color:#4e9a06>orientation</span><span style=color:#000;font-weight:700>:</span> <span style=color:#4e9a06>&#39;landscape&#39;</span><span style=color:#000;font-weight:700>)</span>
</span></span><span style=display:flex><span> </span></span></code></pre></div></div><div class="tab-pane fade" id=tabs-17-05 role=tabpanel aria-labelled-by=tabs-17-05-tab tabindex=17><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-JavaScript data-lang=JavaScript><span style=display:flex><span> <span style=color:#204a87;font-weight:700>const</span> <span style=color:#000;font-weight:700>{</span><span style=color:#000>Builder</span><span style=color:#000;font-weight:700>}</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>require</span><span style=color:#000;font-weight:700>(</span><span style=color:#4e9a06>&#39;selenium-webdriver&#39;</span><span style=color:#000;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>const</span> <span style=color:#000>chrome</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>require</span><span style=color:#000;font-weight:700>(</span><span style=color:#4e9a06>&#39;selenium-webdriver/chrome&#39;</span><span style=color:#000;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>let</span> <span style=color:#000>opts</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#000>chrome</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>Options</span><span style=color:#000;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>let</span> <span style=color:#000>fs</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>require</span><span style=color:#000;font-weight:700>(</span><span style=color:#4e9a06>&#39;fs&#39;</span><span style=color:#000;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>(</span><span style=color:#204a87;font-weight:700>async</span> <span style=color:#204a87;font-weight:700>function</span> <span style=color:#000>example</span><span style=color:#000;font-weight:700>()</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>let</span> <span style=color:#000>driver</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#204a87;font-weight:700>new</span> <span style=color:#000>Builder</span><span style=color:#000;font-weight:700>()</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>.</span><span style=color:#000>forBrowser</span><span style=color:#000;font-weight:700>(</span><span style=color:#4e9a06>&#39;chrome&#39;</span><span style=color:#000;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>.</span><span style=color:#000>setChromeOptions</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>opts</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>headless</span><span style=color:#000;font-weight:700>())</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>.</span><span style=color:#000>build</span><span style=color:#000;font-weight:700>();</span>
</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>get</span><span style=color:#000;font-weight:700>(</span><span style=color:#4e9a06>&#39;https://www.selenium.dev&#39;</span><span style=color:#000;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>try</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>let</span> <span style=color:#000>base64</span> <span style=color:#ce5c00;font-weight:700>=</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>printPage</span><span style=color:#000;font-weight:700>({</span><span style=color:#000>pageRanges</span><span style=color:#ce5c00;font-weight:700>:</span><span style=color:#000;font-weight:700>[</span><span style=color:#4e9a06>&#34;1-2&#34;</span><span style=color:#000;font-weight:700>]});</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>await</span> <span style=color:#000>fs</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>writeFileSync</span><span style=color:#000;font-weight:700>(</span><span style=color:#4e9a06>&#39;./test.pdf&#39;</span><span style=color:#000;font-weight:700>,</span> <span style=color:#000>base64</span><span style=color:#000;font-weight:700>,</span> <span style=color:#4e9a06>&#39;base64&#39;</span><span style=color:#000;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span> <span style=color:#204a87;font-weight:700>catch</span> <span style=color:#000;font-weight:700>(</span><span style=color:#000>e</span><span style=color:#000;font-weight:700>)</span> <span style=color:#000;font-weight:700>{</span>
</span></span><span style=display:flex><span> <span style=color:#000>console</span><span style=color:#000;font-weight:700>.</span><span style=color:#000>log</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>e</span><span style=color:#000;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>}</span>
</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>quit</span><span style=color:#000;font-weight:700>();</span>
</span></span><span style=display:flex><span> <span style=color:#000;font-weight:700>})();</span>
</span></span><span style=display:flex><span>
</span></span></code></pre></div></div><div class="tab-pane fade" id=tabs-17-06 role=tabpanel aria-labelled-by=tabs-17-06-tab tabindex=17><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-Kotlin data-lang=Kotlin><span style=display:flex><span> <span style=color:#000>driver</span><span style=color:#000;font-weight:700>.</span><span style=color:#204a87;font-weight:700>get</span><span style=color:#000;font-weight:700>(</span><span style=color:#4e9a06>&#34;https://www.selenium.dev&#34;</span><span style=color:#000;font-weight:700>)</span>
</span></span><span style=display:flex><span> </span></span></code></pre></div></div><div class="tab-body tab-pane fade" id=tabs-17-05 role=tabpanel aria-labelled-by=tabs-17-05-tab tabindex=17><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-js data-lang=js><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>get</span><span style=color:#000;font-weight:700>(</span><span style=color:#4e9a06>&#39;https://www.selenium.dev/selenium/web/alerts.html&#39;</span><span style=color:#000;font-weight:700>);</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>let</span> <span style=color:#000>base64</span> <span style=color:#ce5c00;font-weight:700>=</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>printPage</span><span style=color:#000;font-weight:700>({</span><span style=color:#000>pageRanges</span><span style=color:#ce5c00;font-weight:700>:</span> <span style=color:#000;font-weight:700>[</span><span style=color:#4e9a06>&#34;1-2&#34;</span><span style=color:#000;font-weight:700>]});</span>
</span></span><span style=display:flex><span> <span style=color:#8f5902;font-style:italic>// page can be saved as a PDF as below
</span></span></span><span style=display:flex><span><span style=color:#8f5902;font-style:italic></span> <span style=color:#8f5902;font-style:italic>// await fs.writeFileSync(&#39;./test.pdf&#39;, base64, &#39;base64&#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/javascript/test/interactions/windows.spec.js#L22-L25 target=_blank><i class="fas fa-external-link-alt pl-2"></i>
<strong>View full example on GitHub</strong></a></div></div><div class="tab-pane fade" id=tabs-17-06 role=tabpanel aria-labelled-by=tabs-17-06-tab tabindex=17><div class=highlight><pre tabindex=0 style=background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-Kotlin data-lang=Kotlin><span style=display:flex><span> <span style=color:#000>driver</span><span style=color:#000;font-weight:700>.</span><span style=color:#204a87;font-weight:700>get</span><span style=color:#000;font-weight:700>(</span><span style=color:#4e9a06>&#34;https://www.selenium.dev&#34;</span><span style=color:#000;font-weight:700>)</span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>val</span> <span style=color:#000>printer</span> <span style=color:#000;font-weight:700>=</span> <span style=color:#000>driver</span> <span style=color:#204a87;font-weight:700>as</span> <span style=color:#000>PrintsPage</span>
</span></span><span style=display:flex><span>
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>val</span> <span style=color:#000>printOptions</span> <span style=color:#000;font-weight:700>=</span> <span style=color:#000>PrintOptions</span><span style=color:#000;font-weight:700>()</span>
Expand Down Expand Up @@ -14003,9 +13989,9 @@
<label><a href=https://github.com/neben>@neben</a></label>
<span class=contributions>1 commits</span></div></div><h4 id=selenium-website--docsgithubcomseleniumhqseleniumhqgithubio><a href=//github.com/SeleniumHQ/seleniumhq.github.io/>Selenium Website & Docs</a></h4><style type=text/css>.ghContributors{display:flex;flex-flow:wrap;align-content:flex-start}.ghContributors>div{width:50%;display:inline-flex;margin-bottom:5px}.ghContributors>div label{padding-left:4px}.ghContributors>div span{font-size:x-small;padding-left:4px}</style><div class=ghContributors><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/5992658?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<label><a href=https://github.com/diemol>@diemol</a></label>
<span class=contributions>720 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/12621691?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<span class=contributions>722 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/12621691?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<label><a href=https://github.com/harsha509>@harsha509</a></label>
<span class=contributions>684 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/3331063?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<span class=contributions>686 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/3331063?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<label><a href=https://github.com/selenium-ci>@selenium-ci</a></label>
<span class=contributions>323 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/777185?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<label><a href=https://github.com/titusfortner>@titusfortner</a></label>
Expand Down
4 changes: 2 additions & 2 deletions documentation/about/_print/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,9 @@
<label><a href=https://github.com/neben>@neben</a></label>
<span class=contributions>1 commits</span></div></div><h4 id=selenium-website--docsgithubcomseleniumhqseleniumhqgithubio><a href=//github.com/SeleniumHQ/seleniumhq.github.io/>Selenium Website & Docs</a></h4><style type=text/css>.ghContributors{display:flex;flex-flow:wrap;align-content:flex-start}.ghContributors>div{width:50%;display:inline-flex;margin-bottom:5px}.ghContributors>div label{padding-left:4px}.ghContributors>div span{font-size:x-small;padding-left:4px}</style><div class=ghContributors><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/5992658?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<label><a href=https://github.com/diemol>@diemol</a></label>
<span class=contributions>720 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/12621691?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<span class=contributions>722 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/12621691?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<label><a href=https://github.com/harsha509>@harsha509</a></label>
<span class=contributions>684 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/3331063?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<span class=contributions>686 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/3331063?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<label><a href=https://github.com/selenium-ci>@selenium-ci</a></label>
<span class=contributions>323 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/777185?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<label><a href=https://github.com/titusfortner>@titusfortner</a></label>
Expand Down
4 changes: 2 additions & 2 deletions documentation/about/copyright/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,9 @@
<label><a href=https://github.com/neben>@neben</a></label>
<span class=contributions>1 commits</span></div></div><h4 id=selenium-website--docsgithubcomseleniumhqseleniumhqgithubio><a href=//github.com/SeleniumHQ/seleniumhq.github.io/>Selenium Website & Docs</a></h4><style type=text/css>.ghContributors{display:flex;flex-flow:wrap;align-content:flex-start}.ghContributors>div{width:50%;display:inline-flex;margin-bottom:5px}.ghContributors>div label{padding-left:4px}.ghContributors>div span{font-size:x-small;padding-left:4px}</style><div class=ghContributors><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/5992658?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<label><a href=https://github.com/diemol>@diemol</a></label>
<span class=contributions>720 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/12621691?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<span class=contributions>722 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/12621691?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<label><a href=https://github.com/harsha509>@harsha509</a></label>
<span class=contributions>684 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/3331063?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<span class=contributions>686 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/3331063?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<label><a href=https://github.com/selenium-ci>@selenium-ci</a></label>
<span class=contributions>323 commits</span></div><div style=padding:10px><img src="https://avatars.githubusercontent.com/u/777185?v=4" class=inline width=100 height=100 style=height:100px;height:100px;margin-bottom:.25em;vertical-align:middle>
<label><a href=https://github.com/titusfortner>@titusfortner</a></label>
Expand Down
Loading

0 comments on commit c218b05

Please sign in to comment.