Tag Archives: python

a very nasty python2 python3 hack

i did have a very nasty python 2 to python 3 hack to get the eclipse ide nokia/RED robot framework editor to work with python 3 but theres a better version below

$ cd ~
$ mkdir eclipse-red
$ ln -s /usr/bin/python3 eclipse-red/python

after you have created your symlink run eclipse

  • and goto Window → Preferences → Robot Framework → Installed frameworks → Add 
  • and if you are lucky nokia/RED should find Robot Framework 3.0.2 (Python 3.5.2 on linux) instead of the python 2 version

how to use eclipse ide and nokia red with python 3

windows 10 python 3 robotframework 3 webdrivers

windows 10 python 3 robotframework 3 seleniumlibrary webdrivers for web testing

install python

  • install python (see https://goo.gl/y36JcN)
  • pip install robotframework
  • pip install robotframework-seleniumlibrary

install browsers

  • download and install browsers (chrome, edge, firefox)

download drivers

install webdrivers

  • unzip webdrivers
  • move exes to a folder in your windows PATH

such as

C:\Users\MYUSERNAME\AppData\Local\Microsoft\WindowsApps\

then you can run python robot

C:\Users\MYUSERNAME> python -m robot mytests.robot

 

free python resources from @sitepoint

free python resources from @sitepoint

#python uses #ascii instead of #unicode by default #gotcha

by default python seems to run in ascii which means if you try and process a string with a utf-8 unicode character in it you will get the error

UnicodeEncodeError: 'ascii' codec can't encode character 
u'\xXX' in position YYYYY: ordinal not in range(128)

so to force your script to use utf-8 unicode instead you need to

see http://nedbatchelder.com/text/unipain.html and

import sys
reload(sys)
sys.setdefaultencoding('utf8')
print sys.getdefaultencoding()

#webdev #python curl #http post requests

webdev python curl http requests

simple python curl http post request example

import requests
url = 'https://www.example.com/'
data = {'requestXml': '<MYREQUESTXML>'}

r = requests.post(url, data)

print 'U '
print url
print 'S '
print r.status_code
print 'H '
print r.headers
print 'T '
print r.text