Skip to content

Commit 10c2b89

Browse files
author
Kamil Democko
committedJul 8, 2024·
added is_selected
1 parent 8e28d07 commit 10c2b89

File tree

7 files changed

+202
-69
lines changed

7 files changed

+202
-69
lines changed
 

‎docs/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h1 class="title">Package <code>pysapscript</code></h1>
2626
<p>SAP scripting for use in Python.<br>
2727
Can perform different actions in SAP GUI client on Windows.</p>
2828
<h1 id="documentation">Documentation</h1>
29-
<p><a href="https://kamildemocko.github.io/PySapScript/pysapscript.html">https://kamildemocko.github.io/PySapScript/pysapscript.html</a></p>
29+
<p><a href="https://kamildemocko.github.io/PySapScript/">https://kamildemocko.github.io/PySapScript/</a></p>
3030
<h1 id="installation">Installation</h1>
3131
<pre><code class="language-pip">pip install pysapscript
3232
</code></pre>
@@ -77,6 +77,7 @@ <h2 id="performing-action">Performing action:</h2>
7777
window.press(element)
7878
window.send_v_key(value[, focus_element=True, value=0])
7979
window.select(element)
80+
selected = window.is_selected(element)
8081
window.read(element)
8182
window.set_checkbox(value)
8283
window.visualize(element[, seconds=1])

‎docs/window.html

+101
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,30 @@ <h1 class="title">Module <code>pysapscript.window</code></h1>
163163
except Exception as ex:
164164
raise exceptions.ActionException(f&#34;Error clicking element {element}: {ex}&#34;)
165165

166+
def is_selected(self, element: str) -&gt; bool:
167+
&#34;&#34;&#34;
168+
Gets status of select element
169+
170+
Args:
171+
element (str): element select
172+
173+
Returns:
174+
bool: selected state
175+
176+
Raises:
177+
ActionException: error selecting element
178+
179+
Example:
180+
```
181+
main_window.is_selected(&#34;wnd[2]/tbar[0]/field[1]&#34;)
182+
```
183+
&#34;&#34;&#34;
184+
try:
185+
return self.session_handle.findById(element).selected
186+
187+
except Exception as ex:
188+
raise exceptions.ActionException(f&#34;Error getting status of element {element}: {ex}&#34;)
189+
166190
def set_checkbox(self, element: str, selected: bool) -&gt; None:
167191
&#34;&#34;&#34;
168192
Selects checkbox element
@@ -482,6 +506,30 @@ <h2 class="section-title" id="header-classes">Classes</h2>
482506
except Exception as ex:
483507
raise exceptions.ActionException(f&#34;Error clicking element {element}: {ex}&#34;)
484508

509+
def is_selected(self, element: str) -&gt; bool:
510+
&#34;&#34;&#34;
511+
Gets status of select element
512+
513+
Args:
514+
element (str): element select
515+
516+
Returns:
517+
bool: selected state
518+
519+
Raises:
520+
ActionException: error selecting element
521+
522+
Example:
523+
```
524+
main_window.is_selected(&#34;wnd[2]/tbar[0]/field[1]&#34;)
525+
```
526+
&#34;&#34;&#34;
527+
try:
528+
return self.session_handle.findById(element).selected
529+
530+
except Exception as ex:
531+
raise exceptions.ActionException(f&#34;Error getting status of element {element}: {ex}&#34;)
532+
485533
def set_checkbox(self, element: str, selected: bool) -&gt; None:
486534
&#34;&#34;&#34;
487535
Selects checkbox element
@@ -671,6 +719,58 @@ <h3>Methods</h3>
671719
self.session_handle.findById(&#34;wnd[0]&#34;).close()</code></pre>
672720
</details>
673721
</dd>
722+
<dt id="pysapscript.window.Window.is_selected"><code class="name flex">
723+
<span>def <span class="ident">is_selected</span></span>(<span>self, element: str) ‑> bool</span>
724+
</code></dt>
725+
<dd>
726+
<div class="desc"><p>Gets status of select element</p>
727+
<h2 id="args">Args</h2>
728+
<dl>
729+
<dt><strong><code>element</code></strong> :&ensp;<code>str</code></dt>
730+
<dd>element select</dd>
731+
</dl>
732+
<h2 id="returns">Returns</h2>
733+
<dl>
734+
<dt><code>bool</code></dt>
735+
<dd>selected state</dd>
736+
</dl>
737+
<h2 id="raises">Raises</h2>
738+
<dl>
739+
<dt><code>ActionException</code></dt>
740+
<dd>error selecting element</dd>
741+
</dl>
742+
<h2 id="example">Example</h2>
743+
<pre><code>main_window.is_selected(&quot;wnd[2]/tbar[0]/field[1]&quot;)
744+
</code></pre></div>
745+
<details class="source">
746+
<summary>
747+
<span>Expand source code</span>
748+
</summary>
749+
<pre><code class="python">def is_selected(self, element: str) -&gt; bool:
750+
&#34;&#34;&#34;
751+
Gets status of select element
752+
753+
Args:
754+
element (str): element select
755+
756+
Returns:
757+
bool: selected state
758+
759+
Raises:
760+
ActionException: error selecting element
761+
762+
Example:
763+
```
764+
main_window.is_selected(&#34;wnd[2]/tbar[0]/field[1]&#34;)
765+
```
766+
&#34;&#34;&#34;
767+
try:
768+
return self.session_handle.findById(element).selected
769+
770+
except Exception as ex:
771+
raise exceptions.ActionException(f&#34;Error getting status of element {element}: {ex}&#34;)</code></pre>
772+
</details>
773+
</dd>
674774
<dt id="pysapscript.window.Window.maximize"><code class="name flex">
675775
<span>def <span class="ident">maximize</span></span>(<span>self) ‑> None</span>
676776
</code></dt>
@@ -1239,6 +1339,7 @@ <h1>Index</h1>
12391339
<h4><code><a title="pysapscript.window.Window" href="#pysapscript.window.Window">Window</a></code></h4>
12401340
<ul class="two-column">
12411341
<li><code><a title="pysapscript.window.Window.close_window" href="#pysapscript.window.Window.close_window">close_window</a></code></li>
1342+
<li><code><a title="pysapscript.window.Window.is_selected" href="#pysapscript.window.Window.is_selected">is_selected</a></code></li>
12421343
<li><code><a title="pysapscript.window.Window.maximize" href="#pysapscript.window.Window.maximize">maximize</a></code></li>
12431344
<li><code><a title="pysapscript.window.Window.navigate" href="#pysapscript.window.Window.navigate">navigate</a></code></li>
12441345
<li><code><a title="pysapscript.window.Window.press" href="#pysapscript.window.Window.press">press</a></code></li>

0 commit comments

Comments
 (0)
Please sign in to comment.