selenium: fixing up to make_donation. Fail due to #4762
This commit is contained in:
parent
a4c073bfa4
commit
49b7c644c0
@ -69,7 +69,7 @@ def switch_base():
|
|||||||
if url[1] == 'demo.taler.net':
|
if url[1] == 'demo.taler.net':
|
||||||
taler_baseurl = "https://test.taler.net"
|
taler_baseurl = "https://test.taler.net"
|
||||||
|
|
||||||
def make_donation(client, amount_value=None):
|
def make_donation(client, amount_menuentry=None):
|
||||||
"""Make donation at shop.test.taler.net. Assume the wallet has coins"""
|
"""Make donation at shop.test.taler.net. Assume the wallet has coins"""
|
||||||
client.get(parse.urljoin(taler_baseurl, "shop"))
|
client.get(parse.urljoin(taler_baseurl, "shop"))
|
||||||
try:
|
try:
|
||||||
@ -77,11 +77,17 @@ def make_donation(client, amount_value=None):
|
|||||||
except NoSuchElementException:
|
except NoSuchElementException:
|
||||||
logger.error('No donation form found')
|
logger.error('No donation form found')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if amount_value:
|
if amount_menuentry:
|
||||||
xpath = "//select[@id='taler-donation']/option[@value='" + str(amount_value) + "']"
|
xpath_menu = '//select[@id="taler-donation"]'
|
||||||
try:
|
try:
|
||||||
desired_amount = client.find_element(By.XPATH, xpath)
|
dropdown = client.find_element(By.XPATH, xpath_menu)
|
||||||
desired_amount.click()
|
for option in dropdown.find_elements_by_tag_name("option"):
|
||||||
|
# Tried option.text, did not work.
|
||||||
|
if option.get_attribute("innerHTML") == amount_menuentry:
|
||||||
|
option = WebDriverWait(client, 10).until(EC.visibility_of(option))
|
||||||
|
logger.info("Picked donation %s" % option.text)
|
||||||
|
option.click()
|
||||||
|
break
|
||||||
except NoSuchElementException:
|
except NoSuchElementException:
|
||||||
logger.error("value '" + str(amount_value) + "' is not offered by this shop to donate, please adapt it")
|
logger.error("value '" + str(amount_value) + "' is not offered by this shop to donate, please adapt it")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@ -245,7 +251,7 @@ logger.info("Withdrawing..")
|
|||||||
withdraw(client, "10.00 PUDOS")
|
withdraw(client, "10.00 PUDOS")
|
||||||
# switch_base() # inducing error
|
# switch_base() # inducing error
|
||||||
logger.info("Making donations..")
|
logger.info("Making donations..")
|
||||||
make_donation(client, 6.0)
|
make_donation(client, "1.0 PUDOS")
|
||||||
logger.info("Buying article..")
|
logger.info("Buying article..")
|
||||||
buy_article(client)
|
buy_article(client)
|
||||||
logger.info("Test passed")
|
logger.info("Test passed")
|
||||||
|
Loading…
Reference in New Issue
Block a user