selenium skeleton and README

This commit is contained in:
Marcello Stanisci 2016-04-25 16:24:00 +02:00
parent 52707f87e7
commit c5a8773b17
2 changed files with 39 additions and 0 deletions

7
selenium/README Normal file
View File

@ -0,0 +1,7 @@
Directory containing testscases for testing the wallet with Selenium ChromeDriver.
[1] Contains the ChromeDriver Pythonic documentation
[2] Tells which fields (and which values) the 'loggingPrefs' capability expects
[1] http://seleniumhq.github.io/selenium/docs/api/py/index.html
[2] https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities#loggingpreferences-json-object

32
selenium/wallet-test.py Normal file
View File

@ -0,0 +1,32 @@
from selenium import webdriver
import time
co = webdriver.ChromeOptions()
co.add_argument("load-extension=/home/marcello/Taler/wallet-webex")
cap = webdriver.DesiredCapabilities.CHROME.copy()
cap['loggingPrefs'] = {'driver': 'INFO', 'browser': 'INFO'}
client = webdriver.Chrome(chrome_options=co, desired_capabilities=cap)
client.get('https://taler.net')
listener = """\
document.addEventListener('taler-id', function(evt){
window['extId'] = evt.detail.id;
});
evt = new CustomEvent('taler-query-id');
document.dispatchEvent(evt);
"""
client.execute_script(listener)
poll = """\
if(window.extId)
return window.extId;
else return false;
"""
# TODO intelligent poller needed
time.sleep(1)
ext_id = client.execute_script(poll)
labels = ['balance']
for l in labels:
client.get('chrome-extensio://' + ext_id + '/popup/popup.html#/' + l)
for log_type in ['browser']:
for log in client.get_log(log_type):
print(log['level'] + ': ' + log['message'])