summaryrefslogtreecommitdiff
path: root/selenium
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2016-04-27 16:58:06 +0200
committerMarcello Stanisci <marcello.stanisci@inria.fr>2016-04-27 16:58:06 +0200
commit5ea6f8dd00266e1b5cf76826f54364119a295948 (patch)
treeacc0224f4397633f0762d23db5ecdbf07635ba2c /selenium
parent07715206e54cab23788e3167e5a77509ffd3e369 (diff)
downloadwallet-core-5ea6f8dd00266e1b5cf76826f54364119a295948.tar.gz
wallet-core-5ea6f8dd00266e1b5cf76826f54364119a295948.tar.bz2
wallet-core-5ea6f8dd00266e1b5cf76826f54364119a295948.zip
selenium tests in "/component" form + fetching baseurl from env
Diffstat (limited to 'selenium')
-rw-r--r--selenium/test.py45
1 files changed, 39 insertions, 6 deletions
diff --git a/selenium/test.py b/selenium/test.py
index c0a5de742..a6155321e 100644
--- a/selenium/test.py
+++ b/selenium/test.py
@@ -1,13 +1,22 @@
+#!/usr/bin/env python3
+
+"""
+Tests for the wallet. It looks for an env variable called TALER_BASEURL
+where it appends "/banks" etc. in order to find bank and shops. If not
+found, it defaults to https://test.taler.net/
+"""
+
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
+from urllib import parse
import time
import logging
+import os
logger = logging.getLogger(__name__)
-bank = 'http://bank.test.taler.net'
-donations = 'http://shop.test.taler.net'
+taler_baseurl = os.environ['TALER_BASEURL'] if 'TALER_BASEURL' in os.environ else 'https://test.taler.net/'
def client_setup():
"""Return a dict containing the driver and the extension's id"""
@@ -27,10 +36,19 @@ def client_setup():
document.dispatchEvent(evt);
"""
client.execute_script(listener)
- client.implicitly_wait(5)
html = client.find_element(By.TAG_NAME, "html")
return {'client': client, 'ext_id': html.get_attribute('data-taler-wallet-id')}
+# Note that the db appears to be reset automatically by the driver
+def destroy_db(client, ext_id):
+ url = 'chrome-extension://' + ext_id + '/popup/popup.html#/debug'
+ client.get(url)
+ button = client.find_element(By.XPATH, "//div[@id='content']/button[3]")
+ button.click()
+ time.sleep(4)
+ alert = client.switch_to.alert
+ alert.accept()
+
def is_error(client):
"""Return True in case of errors in the browser, False otherwise"""
@@ -44,7 +62,7 @@ def is_error(client):
def make_donation(client):
"""Make donation at shop.test.taler.net. Assume the wallet has coins"""
- client.get(donations)
+ client.get(parse.urljoin(taler_baseurl, "shop"))
form = client.find_element(By.TAG_NAME, "form")
form.submit() # amount and receiver chosen
confirm_taler = client.find_element(By.XPATH, "//form//input[@type='button']")
@@ -53,10 +71,23 @@ def make_donation(client):
confirm_pay = wait.until(EC.element_to_be_clickable((By.XPATH, "//button[@class='accept']")))
confirm_pay.click()
+
+def buy_article(client):
+ """Buy article at blog.test.taler.net. Assume the wallet has coins"""
+ client.get(parse.urljoin(taler_baseurl, "blog"))
+ teaser = client.find_element(By.XPATH, "//ul/h3/a[1]") # Pick 'Foreword' chapter
+ teaser.click()
+ wait = WebDriverWait(client, 10)
+ confirm_pay = wait.until(EC.element_to_be_clickable((By.XPATH, "//button[@class='accept']")))
+ confirm_pay.click()
+
+
def register(client):
"""Register a new user to the bank delaying its execution until the
profile page is shown"""
- client.get(bank + '/accounts/register')
+ client.get(parse.urljoin(taler_baseurl, "bank"))
+ register_link = client.find_element(By.XPATH, "//a[@href='/accounts/register/']")
+ register_link.click()
client.find_element(By.TAG_NAME, "form")
register = """\
var form = document.getElementsByTagName('form')[0];
@@ -107,6 +138,8 @@ def withdraw(client):
ret = client_setup()
client = ret['client']
+client.implicitly_wait(10)
withdraw(client)
make_donation(client)
-# client.close()
+buy_article(client)
+client.close()