Most viewed recipes tagged "selenium" Code RecipesMusic Downloader (Python) 2013-05-25T06:52:51-07:00Christian Careaga <p style="color: grey"> Python recipe 578530 by <a href="/recipes/users/4186639/">Christian Careaga</a> (<a href="/recipes/tags/download/">download</a>, <a href="/recipes/tags/downloader/">downloader</a>, <a href="/recipes/tags/music/">music</a>, <a href="/recipes/tags/program/">program</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/python_scripts/">python_scripts</a>, <a href="/recipes/tags/selenium/">selenium</a>, <a href="/recipes/tags/urllib/">urllib</a>, <a href="/recipes/tags/urllib2/">urllib2</a>). </p> <p>A Python Program i wrote that downloads music from the web</p> Testing Tkinter or Selenium for Tkinter (Python) 2017-01-24T20:34:52-08:00Miguel Martínez López <p style="color: grey"> Python recipe 580751 by <a href="/recipes/users/4189907/">Miguel Martínez López</a> (<a href="/recipes/tags/debugging/">debugging</a>, <a href="/recipes/tags/rpyc/">rpyc</a>, <a href="/recipes/tags/selenium/">selenium</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). Revision 3. </p> <p>This code is a little variation of my other trick:</p> <p><a href="" rel="nofollow"></a></p> <p>It makes more easy to create tests for Tkinter.</p> <p>Install rpyc:</p> <blockquote> <p>pip install rpyc</p> </blockquote> <p>Save the code below to a file named for example</p> <p>This is the usage:</p> <blockquote> <p>python [-h] [-p PORT] filename</p> </blockquote> <p>where filename is the path to main file of Tkinter application, and port is an optional port number for the remote interpreter. Otherwise it uses default port.</p> <p>Then in another python interpreter you can interact with the application. For example, write:</p> <pre class="prettyprint"><code>import rpyc c = rpyc.classic.connect("localhost") c.execute(""" from Tkinter import Button, Toplevel import tkMessageBox responsive_button = Button(Toplevel(), text="It's responsive", command = lambda:tkMessageBox.showinfo("alert window", "It's responsive!")) responsive_button.pack() """) responsive_button = c.eval("responsive_button") responsive_button.invoke() </code></pre> <p>(This example only works for Python 2. For python 3 use "tkinter" instead of "Tkinter" and so on)</p> <p>Use port keyword argument to <em>"repyc.classic.connect"</em> if you want a different port number than default port. For example:</p> <pre class="prettyprint"><code>import rpyc c = rpyc.classic.connect("localhost", port=8000) </code></pre> <p>For the selection of tkinter widgets, I have this other trick:</p> <p><a href="" rel="nofollow"></a></p> <p>Using this remote debugging utility and selectors makes easy to test tkinter applications similar to selenium.</p> <p>This utility could be used not only for Tkinter applications. It could be used also for wxpython, pygtk and pyqt applications.</p> <p>NOTE: Interact with remote application using python of same version. If the application is running using a Python 2 interpreter, use a python 2 interpreter for remote interaction. Similarly use a python 3 interpreter for remote interaction with a python 3 application.</p>