view _ui_tests/ @ 1862:afa63a0cc1e1

partial revert of dab0253193eb
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 18 Nov 2012 16:58:06 +0100
parents d9429dafe608
children 384555088cab
line wrap: on
line source
# Copyright: 2012 MoinMoin:LiHaiyan
# Copyright: 2012 MoinMoin:HughPerkins
# License: GNU GPL v3 (or any later version), see LICENSE.txt for details.

"""Functions to facilitate functional testing"""
import pytest

import random

    from selenium import webdriver
except ImportError:
    pytest.skip('selenium needs to be installed for this test')

import config
import urllib

    f = urllib.urlopen(config.BASE_URL)
except IOError:
    pytest.skip('The UI tests need a wiki server running on %s' % config.BASE_URL)

import driver_register

def create_browser():
    Instantiates a firefox browser object, and configures it for English language
    and registers it for screenshots, and sets the timeout
    profile = webdriver.FirefoxProfile()
    profile.set_preference("intl.accept_languages", "en")
    driver = webdriver.Firefox(firefox_profile=profile)
    driver_register.register_driver(driver) # register with
    # driver_register, which is needed so that printscreen on test
    # failure works
    return driver

def generate_random_word(length):
    generates a random string containing numbers, of length 'length'
    word = unicode(random.randint(10**(length-1), 10**length))
    return word

def generate_random_name(prefix, totallength):
    create a random name, starting with 'prefix'
    of total length 'totallength'
    length = totallength - len(prefix)
    numberword = generate_random_word(length)
    name = prefix + numberword
    return name