Skip to content

Commit e9cfaca

Browse files
committed
Added Python Example to PrintPage Documentation (#2009)[deploy site]
Co-authored-by: Sri Harsha <12621691+harsha509@users.noreply.github.com> 430587a
1 parent 85ca96f commit e9cfaca

File tree

25 files changed

+127
-47
lines changed

25 files changed

+127
-47
lines changed

documentation/_print/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5223,7 +5223,12 @@
52235223
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>String</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>printPage</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>browsingContext</span><span style=color:#000;font-weight:700>.</span><span style=color:#c4a000>print</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>printOptions</span><span style=color:#000;font-weight:700>);</span><span style=color:#f8f8f8;text-decoration:underline>
52245224
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>Assertions</span><span style=color:#000;font-weight:700>.</span><span style=color:#c4a000>assertTrue</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:#c4a000>length</span><span style=color:#000;font-weight:700>()</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#ce5c00;font-weight:700>&gt;</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>0</span><span style=color:#000;font-weight:700>);</span><span style=color:#f8f8f8;text-decoration:underline>
52255225
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </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/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L35-L42 target=_blank><i class="fas fa-external-link-alt pl-2"></i>
5226-
<strong>View full example on GitHub</strong></a></div></div><div class="tab-body tab-pane fade" id=tabs-08-01 role=tabpanel aria-labelled-by=tabs-08-01-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 class="tab-body tab-pane fade" id=tabs-08-02 role=tabpanel aria-labelled-by=tabs-08-02-tab tabindex=8><p><a href=https://github.com/SeleniumHQ/selenium><span class=selenium-badge-implementation data-bs-toggle=tooltip data-bs-placement=right title="This functionality is not available for this language">Implementation Missing</span></a></p></div><div class="tab-body tab-pane fade" id=tabs-08-03 role=tabpanel aria-labelled-by=tabs-08-03-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 class="tab-body tab-pane fade" id=tabs-08-04 role=tabpanel aria-labelled-by=tabs-08-04-tab tabindex=8><p><a href=https://github.com/SeleniumHQ/selenium><span class=selenium-badge-implementation data-bs-toggle=tooltip data-bs-placement=right title="This functionality is not available for this language">Implementation Missing</span></a></p></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=https://github.com/SeleniumHQ/selenium><span class=selenium-badge-implementation data-bs-toggle=tooltip data-bs-placement=right title="This functionality is not available for this language">Implementation Missing</span></a></p></div></div></div><div class=td-content style=page-break-before:always><h1 id=pg-0173104e5a75fd17aec00cf87e6f26d4>2.6.6 - Working with windows and tabs</h1><h2 id=windows-and-tabs>Windows and tabs</h2><h3 id=get-window-handle>Get window handle</h3><p>WebDriver does not make the distinction between windows and tabs. If
5226+
<strong>View full example on GitHub</strong></a></div></div><div class="tab-body tab-pane fade" id=tabs-08-01 role=tabpanel aria-labelled-by=tabs-08-01-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 class="tab-body tab-pane fade" id=tabs-08-02 role=tabpanel aria-labelled-by=tabs-08-02-tab tabindex=8><p><a href=https://github.com/SeleniumHQ/selenium><span class=selenium-badge-implementation data-bs-toggle=tooltip data-bs-placement=right title="This functionality is not available for this language">Implementation Missing</span></a></p></div><div class="tab-body tab-pane fade" id=tabs-08-03 role=tabpanel aria-labelled-by=tabs-08-03-tab tabindex=8><p><strong>print_page()</strong></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-py data-lang=py><span style=display:flex><span><span style=color:#204a87;font-weight:700>def</span> <span style=color:#000>test_prints_page</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>driver</span><span style=color:#000;font-weight:700>):</span>
5227+
</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>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>
5228+
</span></span><span style=display:flex><span> <span style=color:#000>print_options</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>PrintOptions</span><span style=color:#000;font-weight:700>()</span>
5229+
</span></span><span style=display:flex><span> <span style=color:#000>pdf</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:#000>print_options</span><span style=color:#000;font-weight:700>)</span>
5230+
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>assert</span> <span style=color:#204a87>len</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>pdf</span><span style=color:#000;font-weight:700>)</span> <span style=color:#ce5c00;font-weight:700>&gt;</span> <span style=color:#0000cf;font-weight:700>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/python/tests/interactions/test_prints_page.py#L11-L15 target=_blank><i class="fas fa-external-link-alt pl-2"></i>
5231+
<strong>View full example on GitHub</strong></a></div></div><div class="tab-body tab-pane fade" id=tabs-08-04 role=tabpanel aria-labelled-by=tabs-08-04-tab tabindex=8><p><a href=https://github.com/SeleniumHQ/selenium><span class=selenium-badge-implementation data-bs-toggle=tooltip data-bs-placement=right title="This functionality is not available for this language">Implementation Missing</span></a></p></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=https://github.com/SeleniumHQ/selenium><span class=selenium-badge-implementation data-bs-toggle=tooltip data-bs-placement=right title="This functionality is not available for this language">Implementation Missing</span></a></p></div></div></div><div class=td-content style=page-break-before:always><h1 id=pg-0173104e5a75fd17aec00cf87e6f26d4>2.6.6 - Working with windows and tabs</h1><h2 id=windows-and-tabs>Windows and tabs</h2><h3 id=get-window-handle>Get window handle</h3><p>WebDriver does not make the distinction between windows and tabs. If
52275232
your site opens a new tab or window, Selenium will let you work with it
52285233
using a window handle. Each window has a unique identifier which remains
52295234
persistent in a single session. You can get the window handle of the

documentation/webdriver/_print/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5024,7 +5024,12 @@
50245024
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>String</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>printPage</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#ce5c00;font-weight:700>=</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>browsingContext</span><span style=color:#000;font-weight:700>.</span><span style=color:#c4a000>print</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>printOptions</span><span style=color:#000;font-weight:700>);</span><span style=color:#f8f8f8;text-decoration:underline>
50255025
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>Assertions</span><span style=color:#000;font-weight:700>.</span><span style=color:#c4a000>assertTrue</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:#c4a000>length</span><span style=color:#000;font-weight:700>()</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#ce5c00;font-weight:700>&gt;</span><span style=color:#f8f8f8;text-decoration:underline> </span><span style=color:#000>0</span><span style=color:#000;font-weight:700>);</span><span style=color:#f8f8f8;text-decoration:underline>
50265026
</span></span></span><span style=display:flex><span><span style=color:#f8f8f8;text-decoration:underline> </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/java/src/test/java/dev/selenium/interactions/PrintsPageTest.java#L35-L42 target=_blank><i class="fas fa-external-link-alt pl-2"></i>
5027-
<strong>View full example on GitHub</strong></a></div></div><div class="tab-body tab-pane fade" id=tabs-08-01 role=tabpanel aria-labelled-by=tabs-08-01-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 class="tab-body tab-pane fade" id=tabs-08-02 role=tabpanel aria-labelled-by=tabs-08-02-tab tabindex=8><p><a href=https://github.com/SeleniumHQ/selenium><span class=selenium-badge-implementation data-bs-toggle=tooltip data-bs-placement=right title="This functionality is not available for this language">Implementation Missing</span></a></p></div><div class="tab-body tab-pane fade" id=tabs-08-03 role=tabpanel aria-labelled-by=tabs-08-03-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 class="tab-body tab-pane fade" id=tabs-08-04 role=tabpanel aria-labelled-by=tabs-08-04-tab tabindex=8><p><a href=https://github.com/SeleniumHQ/selenium><span class=selenium-badge-implementation data-bs-toggle=tooltip data-bs-placement=right title="This functionality is not available for this language">Implementation Missing</span></a></p></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=https://github.com/SeleniumHQ/selenium><span class=selenium-badge-implementation data-bs-toggle=tooltip data-bs-placement=right title="This functionality is not available for this language">Implementation Missing</span></a></p></div></div></div><div class=td-content style=page-break-before:always><h1 id=pg-0173104e5a75fd17aec00cf87e6f26d4>6.6 - Working with windows and tabs</h1><h2 id=windows-and-tabs>Windows and tabs</h2><h3 id=get-window-handle>Get window handle</h3><p>WebDriver does not make the distinction between windows and tabs. If
5027+
<strong>View full example on GitHub</strong></a></div></div><div class="tab-body tab-pane fade" id=tabs-08-01 role=tabpanel aria-labelled-by=tabs-08-01-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 class="tab-body tab-pane fade" id=tabs-08-02 role=tabpanel aria-labelled-by=tabs-08-02-tab tabindex=8><p><a href=https://github.com/SeleniumHQ/selenium><span class=selenium-badge-implementation data-bs-toggle=tooltip data-bs-placement=right title="This functionality is not available for this language">Implementation Missing</span></a></p></div><div class="tab-body tab-pane fade" id=tabs-08-03 role=tabpanel aria-labelled-by=tabs-08-03-tab tabindex=8><p><strong>print_page()</strong></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-py data-lang=py><span style=display:flex><span><span style=color:#204a87;font-weight:700>def</span> <span style=color:#000>test_prints_page</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>driver</span><span style=color:#000;font-weight:700>):</span>
5028+
</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>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>
5029+
</span></span><span style=display:flex><span> <span style=color:#000>print_options</span> <span style=color:#ce5c00;font-weight:700>=</span> <span style=color:#000>PrintOptions</span><span style=color:#000;font-weight:700>()</span>
5030+
</span></span><span style=display:flex><span> <span style=color:#000>pdf</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:#000>print_options</span><span style=color:#000;font-weight:700>)</span>
5031+
</span></span><span style=display:flex><span> <span style=color:#204a87;font-weight:700>assert</span> <span style=color:#204a87>len</span><span style=color:#000;font-weight:700>(</span><span style=color:#000>pdf</span><span style=color:#000;font-weight:700>)</span> <span style=color:#ce5c00;font-weight:700>&gt;</span> <span style=color:#0000cf;font-weight:700>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/python/tests/interactions/test_prints_page.py#L11-L15 target=_blank><i class="fas fa-external-link-alt pl-2"></i>
5032+
<strong>View full example on GitHub</strong></a></div></div><div class="tab-body tab-pane fade" id=tabs-08-04 role=tabpanel aria-labelled-by=tabs-08-04-tab tabindex=8><p><a href=https://github.com/SeleniumHQ/selenium><span class=selenium-badge-implementation data-bs-toggle=tooltip data-bs-placement=right title="This functionality is not available for this language">Implementation Missing</span></a></p></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=https://github.com/SeleniumHQ/selenium><span class=selenium-badge-implementation data-bs-toggle=tooltip data-bs-placement=right title="This functionality is not available for this language">Implementation Missing</span></a></p></div></div></div><div class=td-content style=page-break-before:always><h1 id=pg-0173104e5a75fd17aec00cf87e6f26d4>6.6 - Working with windows and tabs</h1><h2 id=windows-and-tabs>Windows and tabs</h2><h3 id=get-window-handle>Get window handle</h3><p>WebDriver does not make the distinction between windows and tabs. If
50285033
your site opens a new tab or window, Selenium will let you work with it
50295034
using a window handle. Each window has a unique identifier which remains
50305035
persistent in a single session. You can get the window handle of the

0 commit comments

Comments
 (0)