예제 #1
0
파일: atm.py 프로젝트: fengfumin/maple
def login():
    print('登入')
    count = 0
    while True:
        name = input('请输入登入账户名(q退出)>>>:').strip()
        if name == 'q': return
        pwd = input('请输入登入密码>>>:').strip()
        flag, msg = user.login(name, pwd)
        if flag:
            user_data['name'] = name
            user_shop['name'] = name
            print(msg)
            break
        else:
            print(msg)
            count += 1
            if count > 3:
                user.lock_user(name)
                print('尝试太多次输错,你已被锁定')
                break
from lib.utils import get_sreenshot_path, create_webdriver  # Changed


success = True
wd = create_webdriver()


def is_alert_present(wd):
    try:
        wd.switch_to_alert().text
        return True
    except:
        return False

try:
    login(wd)
    wd.find_element_by_link_text("New application").click()
    wd.find_element_by_css_selector("div.dropdownValue.iconDown").click()
    wd.find_element_by_css_selector("li.item-3").click()
    wd.find_element_by_id("application_title").send_keys("testing fullscreen alternative template")
    wd.find_element_by_id("application_slug").send_keys("testing_fullscreen_alternative_template")
    wd.find_element_by_id("application_description").send_keys("run a test to create a new application based on the fullscreen alternative template")
    wd.find_element_by_css_selector("input.button").click()
    if not ("testing fullscreen alternative template" in wd.find_element_by_tag_name("html").text):
        raise Exception("find_element_by_tag_name failed: testing fullscreen alternative template")
    logout(wd)
except Exception as e:  # Changed ff
    wd.save_screenshot(get_sreenshot_path('error'))
    wd.quit()
    raise e
finally:
예제 #3
0
from lib.utils import get_sreenshot_path, create_webdriver  # Changed

success = True
wd = create_webdriver()


def is_alert_present(wd):
    try:
        wd.switch_to_alert().text
        return True
    except:
        return False


try:
    login(wd)
    wd.find_element_by_css_selector("h1.contentTitle").click()
    wd.find_element_by_link_text("New user").click()
    wd.find_element_by_id("user_username").click()
    wd.find_element_by_id("user_username").clear()
    wd.find_element_by_id("user_username").send_keys("test")
    wd.find_element_by_id("user_email").click()
    wd.find_element_by_id("user_email").clear()
    wd.find_element_by_id("user_email").send_keys("*****@*****.**")
    wd.find_element_by_id("user_password_first").click()
    wd.find_element_by_id("user_password_first").clear()
    wd.find_element_by_id("user_password_first").send_keys("test1234")
    wd.find_element_by_id("user_password_second").click()
    wd.find_element_by_id("user_password_second").clear()
    wd.find_element_by_id("user_password_second").send_keys("test1234")
    wd.find_element_by_css_selector("input.button").click()