Exemplo n.º 1
0
 def getInfo(self):
     self.company = 'Citi'
     self.bureaus = 'Equifax'
     try:
         browser = Browser(driver_name='firefox')
         browser.visit(self.url)
         browser.driver.set_window_size(self.window_size_x, self.window_size_y)
         time.sleep(5)
         browser.find_by_id(self.username_id).fill(self.username)
         time.sleep(5)
         browser.find_by_name(self.password_name).fill(self.password)
         time.sleep(5)
         browser.find_by_value(self.loginbutton_value).click()
         time.sleep(10)
         browser.find_by_id(self.fico_button).click()
         time.sleep(10)
         self.score = browser.find_by_id(self.score_id).text.encode('ascii','ignore')
         self.score = re.sub("[^0-9]", "", self.score)
         self.scoreDate =  browser.find_by_id(self.date_id).text.encode('ascii','ignore')
         browser.quit()
         print(self.company + " succeeds!")
     except:
         print(self.company + " failed!")
         pdb.set_trace()
         if browser:
             browser.quit()
Exemplo n.º 2
0
def supreme(url, keyword, color):

# all are strings ''
    b = Browser(driver_name = "chrome")
    input("Press Enter to continue...")
    b.visit(url)
    b.find_link_by_partial_text(keyword).click()
    #choose color
    if color == 'Black':
        b.find_by_xpath("/html/body//a[@data-style-name='Black']").click()
    elif color == 'Red':
        b.find_by_xpath("/html/body//a[@data-style-name='Red']").click()
    elif color == 'Blue':
        b.find_by_xpath("/html/body//a[@data-style-name='Blue]").click()
    elif color == 'Navy':
        b.find_by_xpath("/html/body//a[@data-style-name='Navy]").click()
    elif color == 'Green':
        b.find_by_xpath("/html/body//a[@data-style-name='Green']").click()
        
    while True:
        elementList = b.find_by_value("add to cart")
        if not elementList.is_empty():
            break
    b.find_by_value("add to cart").click()
 

    while True:
        elementList = b.find_link_by_href("https://www.supremenewyork.com/checkout")
        if not elementList.is_empty():
            break
    b.find_link_by_href("https://www.supremenewyork.com/checkout").click()

    while True:
        elementList = b.find_by_value('USA')
        if not elementList.is_empty():
            break

    threads = []
    t_1 = Thread(target = AutoInfo, args = [b])
    t_1.start()
    threads.append(t_1)
    
    t_2 = Thread(target = AutoAddress, args = [b])
    t_2.start()
    threads.append(t_2)
    
    t_3= Thread(target = AutoCardInfoOne, args = [b])
    t_3.start()
    threads.append(t_3)
    
    t_4= Thread(target = AutoCardInfoTwo, args = [b])
    t_4.start()
    threads.append(t_4)  
Exemplo n.º 3
0
def test_op():
	print("hello world!")
	#browser = Browser("firefox")#模拟浏览器
	browser = Browser("chrome")#模拟浏览器
	#browser = Browser()#模拟浏览器
	browser.visit("http://unptest.xiaobalei.com:5288/gbpayserver/mgr/")#访问指定URL
	browser.fill("name", "root")
	browser.fill("pwd", "111111")
	browser.find_by_value("登陆")[0].click()
	browser.find_by_text("计费应用管理").click()
	time.sleep(8)
	browser.quit()
Exemplo n.º 4
0
def test_op():
    print("hello world!")
    #browser = Browser("firefox")#模拟浏览器
    browser = Browser("chrome")  #模拟浏览器
    #browser = Browser()#模拟浏览器
    browser.visit(
        "http://unptest.xiaobalei.com:5288/gbpayserver/mgr/")  #访问指定URL
    browser.fill("name", "root")
    browser.fill("pwd", "111111")
    browser.find_by_value("登陆")[0].click()
    browser.find_by_text("计费应用管理").click()
    time.sleep(8)
    browser.quit()
def function():
    b = Browser("chrome")
    b.visit(AppSite)
    dictAppSite = {
        '': '澳大利亚',  # 选择访问国
        '': '中国',  # 选择居住国
        '': '澳大利亚签证中心-成都',  # 地点
        '': 'Work and Holiday Visa',  # 选择签证;类别
    }
    b.fill_form(dictAppSite)
    button = b.find_by_value(u"继续")
    button.click()

    b.visit(AppAdd)
    dictAppAdd = {
        '': 'G11111111',  # 护照号码
        '': '1/1/1999',  # 出生日期
        '': '1/1/2025',  # 护照失效期
        '': 'CHINA',  # 选择国籍
        '': '阿',  # 名
        '': '伟',  # 姓
        '': '男性',  # 性别
        '': '+8612345678900',  # 电话号码
        '': '*****@*****.**'  # 电子邮箱
        # 验证码
    }
    b.fill_form(dictAppSite)
    button = b.find_by_value(u"提交")
    button.click()

    b.visit(AppData)
    dictAppData = {
        '': '7/15/2019',  # 日期槽
        '': '8:30-8:45'  # 时间槽
        # 验证码
    }
    b.fill_form(dictAppAdata)
    button = b.find_by_value(u"提交")
    button.click()
Exemplo n.º 6
0
# Copyright (c) Rice University 2012-13
# This software is subject to
# the provisions of the GNU Affero General
# Public License version 3 (AGPLv3).
# See LICENCE.txt for details.
###


from splinter.browser import Browser

browser = Browser()
browser.visit("http://www.office.mikadosoftware.com")
browser.click_link_by_href("/login")
openidbox = browser.find_by_xpath("""id('column2')/form/p/input[1]""").first
openidbox.fill("https://www.google.com/accounts/o8/id")
browser.find_by_value("Sign in").first.click()
# id="Email"
# id="Passwd"
browser.find_by_id("Email").first.fill("*****@*****.**")
browser.find_by_id("Passwd").first.fill("empathy1")
browser.find_by_value("Sign in").first.click()

browser.uncheck("remember_choices")
browser.find_by_value("Allow").first.click()
print browser.title
print

for z in browser.cookies.driver.get_cookies():
    if z["domain"] == u"www.office.mikadosoftware.com" and z["name"] == u"session":
        print z["value"]
Exemplo n.º 7
0
class Amazon(object):
    def __init__(self, keyword):
        self.url = "https://www.amazon.com"
        self.name = "".join(random.sample(string.ascii_letters + string.digits, 6))
        self.email = "".join(random.sample(string.ascii_letters + string.digits, 16)) + "@163.com"
        self.password = "".join(random.sample(string.ascii_letters + string.digits, 8))
        self.keyword = keyword
        self.chrome_options = Options()
        logging.basicConfig(filename='amazon.log', level=logging.DEBUG)
        self.conn = pymysql.connect(host='192.168.0.211', port=6033, user='******', password='******', db='amazon')
        self.cs = self.conn.cursor()
        self.cs.execute('select id,ip,port from register_proxy_ips where is_alived = 1 order by id desc limit 1')
        self.proxy_ip = self.cs.fetchone()
        self.cs.execute('update register_proxy_ips set is_alived = 0 where id = %s' % self.proxy_ip[0])
        self.conn.commit()
        logging.debug(self.proxy_ip)
        # self.chrome_options.add_argument('--proxy-server=http://{host}:{port}'.format(host=self.proxy_ip[1], port=self.proxy_ip[2]))
        self.browser = Browser('chrome', user_agent=generate_user_agent(device_type='desktop'))

    def run(self):
        self.acess()
        self.search_kw()
        i = 1
        while i < 7:
            ad_list = self.browser.find_by_xpath('//li[contains(@class, "AdHolder")]')
            if ad_list:
                ad_list[0].find_by_tag('h2').click()
                break
            else:
                time.sleep(300)
                self.search_kw()
                i += 1
        if i > 6:
            self.browser.quit()
        self.register()
        self.add_pay_method()
        self.add_address()
        self.buy_goods()
        self.add_list()

    def acess(self):
        self.browser.visit(self.url)
        logging.error("代理IP失效,请求不成功")

    def search_kw(self):
        self.browser.find_by_xpath('//input[@id="twotabsearchtextbox"]').first.fill(self.keyword)
        self.browser.find_by_xpath('//input[@value="Go"]').click()
        draggble = self.browser.find_by_xpath('//*[@id="searchTemplate"]')
        target = self.browser.find_by_xpath('//*[@id="footer"]')
        draggble.drag_and_drop(target)
        # time.sleep(random.randint(1, 6))

    def register(self):
        self.browser.find_by_xpath('//*[@id="nav-link-accountList"]').click()
        self.browser.find_by_xpath('//*[@id="createAccountSubmit"]').click()
        self.browser.find_by_xpath('//input[@id="ap_customer_name"]').first.fill(self.name)
        self.browser.find_by_xpath('//input[@id="ap_email"]').first.fill(self.email)
        self.browser.find_by_xpath('//input[@id="ap_password"]').first.fill(self.password)
        self.browser.find_by_xpath('//input[@id="ap_password_check"]').first.fill(self.password)
        self.browser.find_by_xpath('//input[@class="a-button-input"]').click()

    def add_pay_method(self):
        self.browser.find_by_xpath('//*[@id="nav-link-accountList"]').click()
        self.browser.find_by_xpath('//*[@id="a-page"]/div[3]/div/div[2]/div[2]/a/div').click()
        self.browser.fill('ppw-accountHolderName', paras['card_name'])
        self.browser.fill('addCreditCardNumber', paras['card_num'])
        self.browser.execute_script('document.getElementsByName("ppw-expirationDate_month")[0].style.display="block"')
        self.browser.execute_script('document.getElementsByName("ppw-expirationDate_year")[0].style.display="block"')
        self.browser.find_by_text('04').click()
        self.browser.find_by_text('2019').click()
        self.browser.find_by_name('ppw-widgetEvent:AddCreditCardEvent').click()

    def add_address(self):
        self.browser.fill('ppw-fullName', paras['fullname'])
        self.browser.fill('ppw-line1', paras['line'])
        self.browser.fill('ppw-city', paras['city'])
        self.browser.fill('ppw-stateOrRegion', paras['stateOrRegion'])
        self.browser.fill('ppw-postalCode', paras['postalCode'])
        self.browser.fill('ppw-phoneNumber', paras['phoneNumber'])
        self.browser.find_by_name('ppw-widgetEvent:AddAddressEvent').click()

    def buy_goods(self):
        self.browser.find_by_xpath('//*[@id="nav-recently-viewed"]').click()
        self.browser.find_by_xpath('//*[@id="asin_list"]/div[1]/div/a/div[1]/span/div').click()
        try:
            self.browser.find_by_xpath('//*[@id="add-to-cart-button"]').click()  # add cart
            self.browser.find_by_xpath('//*[@id="smartShelfAddToCartNative"]').click()
        except Exception as e:
            logging.error(e)
        try:
            time.sleep(5)
            self.browser.is_element_present_by_xpath('//i[@class="a-icon a-icon-close"]', wait_time=30)
            self.browser.find_by_xpath('//i[@class="a-icon a-icon-close"]').click()
        except Exception:
            pass
        try:
            self.browser.find_by_xpath('//a[@id="hlb-view-cart-announce"]').click()  # enter cart
        except Exception:
            pass
        self.browser.execute_script('document.getElementsByName("quantity")[0].style.display="block"')
        self.browser.find_by_value('10').click()
        self.browser.find_by_name('quantityBox').clear()
        self.browser.fill('quantityBox', 999)
        self.browser.find_by_xpath('//span[@id="a-autoid-1"]').click()
        self.browser.find_by_xpath('//div[@class="sc-proceed-to-checkout"]').click()
        self.browser.find_by_xpath('//*[@id="address-book-entry-0"]/div[2]/span/a').click()
        self.browser.find_by_xpath('//*[@id="shippingOptionFormId"]/div[3]/div/div/span[1]').click()
        self.browser.find_by_xpath('//*[@id="order-summary-container"]/div/div/div').click()
        try:
            self.browser.find_by_xpath('//a[contains(@class, "prime-nothanks-button")]').click()
        except Exception:
            pass
        self.browser.find_by_xpath('//span[contains(@class, "place-order-button-link")]').click()

    def add_list(self):
        self.browser.find_by_xpath('//*[@id="nav-recently-viewed"]').click()
        self.browser.find_by_xpath('//*[@id="asin_list"]/div[1]/div/a/div[1]/span/div').click()
        self.browser.find_by_xpath('//input[@title="Add to List"]').click()
        if self.browser.is_element_present_by_text('Add to your list', wait_time=10):
            self.browser.find_by_xpath('//*[@id="WLHUC_result"]/form/div[2]/span[3]/span').click()
            self.browser.find_by_xpath('//i[@class="a-icon a-icon-close"]').click()
        time.sleep(2)
        self.browser.quit()
Exemplo n.º 8
0
class Redmine(object):

    activities_codes = {'Funcionalidade': '36', 'Codificacao': '25'}
    type_codes = {'Funcionalidade': '2', 'Codificacao': '7', 'Refatoramento': '14'}
    participants_code = {'59':'Douglas Camata',
                        '65': 'Felipe Norato Lacerda',
                        '60': 'Fernando Carvalho',
                        '149': 'Fábio Ribeiro',
                        '68': 'Priscila Manhaes da Silva',
                        '32': 'Rogério Atem'}

    def __init__(self):
        self.username = raw_input('Digite seu usuário: ')
        self.password = encode(getpass('Digite sua senha: '))
        self.prepare()

    def prepare(self):
        try:
          self.browser = Browser('chrome')
        except:
          self.browser = Browser()
        self.login()

    def login(self):
        self.browser.visit('http://sgsetec.renapi.gov.br/login')
        self.browser.fill('username', self.username)
        self.browser.fill('password', decode(self.password))
        self.browser.find_by_name('login').click()

    def visit_project(self, project_id):
        self.browser.visit('http://sgsetec.renapi.gov.br/kanban?project_id=%s' % project_id)

    def create_issue(self, project_id, type_name, title, description, begin, end, participants,
                        monitors):

        self.browser.visit('http://sgsetec.renapi.gov.br/projects/%s/issues/new' % project_id)
        self.browser.select('Tipo', self.type_codes[type_name])
        self.browser.fill('issue[subject]', title)
        self.browser.fill('issue[description]', description)
        self.browser.fill('issue[start_date]', begin)
        self.browser.fill('issue[due_date]', end)
        for participant in participants:
            self.browser.select('Participantes', self.participants_code[participant])
        for monitor in monitors:
            self.browser.select('Monitores', self.participants_code[monitor])
        self.browser.find_by_value('Criar').click()

    def update_issue(self, issue_id, activity, date,
                                    worked_hours=4, comment=None):
        self.browser.visit('http://sgsetec.renapi.gov.br/issues/%s/time_entries/new' % issue_id)
        self.browser.fill('time_entry[spent_on]', date)
        self.browser.find_by_id('time_entry_hours').fill(worked_hours)
        self.browser.select('time_entry[activity_id]', self.activities_codes[activity.capitalize()])
        self.browser.find_by_value('Salvar').click()

    def finish_issue(self, issue_id, begin, total_days, activity):
        #do not need to plus um day into cause first day of work is 'begin'
        day_worked = 0
        while day_worked < total_days:
            date = datetime.datetime.strptime(begin, "%Y-%m-%d")
            date = date.date() + datetime.timedelta(day_worked)
            day_worked += 1
            if date.weekday() > 4:
              total_days += 1
              continue
              date = date.date() + datetime.timedelta(day_worked)
            self.update_issue(issue_id=issue_id, date=str(date), activity=activity)
        self.close_issue(issue_id)


    def close_issue(self, issue_id):
        self.browser.visit('http://sgsetec.renapi.gov.br/issues/%s/time_entries/new' % issue_id)
        self.browser.select('issue[status_id]', '3')
        self.browser.select('issue[done_ratio]', '100')
        self.browser.find_by_value('Salvar').click()
from splinter.browser import Browser
browser = Browser()
browser.visit('http://www.office.mikadosoftware.com')
browser.click_link_by_href('/login')
openidbox = browser.find_by_xpath('''id('column2')/form/p/input[1]''').first
openidbox.fill('https://www.google.com/accounts/o8/id')
browser.find_by_value('Sign in').first.click()
#id="Email"
#id="Passwd"
browser.find_by_id("Email").first.fill('*****@*****.**') 
browser.find_by_id("Passwd").first.fill('empathy1') 
browser.find_by_value('Sign in').first.click()

browser.uncheck('remember_choices')
browser.find_by_value('Allow').first.click()
print browser.title
print 

for z in browser.cookies.driver.get_cookies():
    if z['domain'] == u'www.office.mikadosoftware.com' and z['name'] == u'session': 
        print z['value']
Exemplo n.º 10
0
from splinter.browser import Browser
b = Browser(driver_name="chrome")
b.visit("http://www.qq.com")
b.find_by_value(u"百度一下")
Exemplo n.º 11
0
class TestEngine(object):
    __sleep_time = 2
    __mouse_over = True
    __mouse_over_sleep = 1

    def __init__(self, browser_name, execute_path=None):
        if execute_path is None:
            self.__browser = Browser(browser_name, fullscreen=True)
            self.__quit = False
        else:
            self.__browser = Browser(browser_name, executable_path=execute_path, fullscreen=True)
            self.__quit = False

    @staticmethod
    def set_config(config):
        TestEngine.__sleep_time = 2 if config.get("sleep_time") is None else config.get("sleep_time")
        TestEngine.__mouse_over = True if config.get("mouse_over") is None else config.get("mouse_over")
        TestEngine.__mouse_over_sleep = 1 if config.get("mouse_over_sleep") is None else config.get("mouse_over_sleep")

    def test_list_acts(self, domain, action_list, back_fun=None, result_back=None):
        thread_deal = threading.Thread(target=self.__test_list_thread, args=(domain, action_list, back_fun, result_back), name="TestEngine deal tester")
        thread_deal.start()

    def test_deal(self, domain, action_obj, back_fun=None, result_back=None):
        thread_deal = threading.Thread(target=self.__test_do_thread, args=(domain, action_obj, back_fun, result_back), name="TestEngine deal tester")
        # hasattr(result_back, "__call__")
        thread_deal.start()

    def quit(self):
        self.__quit = True
        self.__browser.quit()

    def is_quited(self):
        return self.__quit

    def __test_list_thread(self, domain, action_list, back_fun=None, result_back=None):
        try:
            for action in action_list:
                self.__test_do(domain, action, result_back)
        except Exception as e:
            raise Exception("[Error code] deal test list failed, error code=", e)
        finally:
            if action_list[0].waitClose != 0:
                sleep(action_list[0].waitClose)

                if back_fun is None:
                    self.quit()
                else:
                    back_fun()


    def __test_do_thread(self, domain, action_obj, back_fun=None, result_back=None):
        try:
            self.__test_do(domain, action_obj, result_back)
        except Exception as e:
            raise Exception("[Error code] deal test failed, error code=", e)
        finally:
            if action_obj.waitClose != 0:
                sleep(action_obj.waitClose)

                if back_fun is None:
                    self.quit()
                else:
                    back_fun()


    def __test_do(self, domain, action_obj, result_back=None):
        test_url = domain+action_obj.urlPath
        self.__browser.visit(test_url)

        # form表单默认为第一个action循环测试,之后的action按照顺序执行
        action_list = TesterActionData().dict_to_list(action_obj.actionList)
        if action_obj.forms is not None:
            form_action = action_list[0] if action_list else None

            forms = TesterForms().dict_to_list(action_obj.forms)
            for form in forms:
                params = TesterFormData().dict_to_list(form.params)
                for param in params:
                    self.__set_value(int(param.formType), param.formElName, param.formElValue.decode("utf-8"), int(param.index))
                    sleep(TestEngine.__sleep_time)

                if form_action is not None:
                    self.__deal_action(form_action, result_back)

                sleep(action_obj.sleepTime)

            for action_deal in action_list[1:]:
                self.__deal_action(action_deal, result_back)
                sleep(action_obj.sleepTime)
        else:
            for action_deal in action_list:
                self.__deal_action(action_deal, result_back)
                sleep(action_obj.sleepTime)


    def __set_value(self, form_type, el_name, el_value, index):
        elements = self.__event_element(form_type, el_name)
        element = elements[index]
        if element['type'] in ['text', 'password', 'tel'] or element.tag_name == 'textarea':
            element.value = el_value
        elif element['type'] == 'checkbox':
            if el_value:
                element.check()
            else:
                element.uncheck()
        elif element['type'] == 'radio':
            element.click()
        elif element._element.tag_name == 'select':
            element.find_by_value(el_value).first._element.click()
        else:
            element.value = el_value


    def __event_element(self, el_type, el_value):
        ele_type = EL_TYPE.value(el_type)

        if ele_type == "id":
            return self.__browser.find_by_id(el_value)
        elif ele_type == "name":
            return self.__browser.find_by_name(el_value)
        elif ele_type == "tag":
            return self.__browser.find_by_tag(el_value)
        elif ele_type == "value":
            return self.__browser.find_by_value(el_value)
        elif ele_type == "selector":
            return self.__browser.find_by_xpath(el_value)
        elif ele_type == "css":
            return self.__browser.find_by_css(el_value)
        else:
            raise ValueError("Test Engine can't deal the element type:%s, el_type:%s", ele_type, el_type)


    def __deal_action(self, action_data, result_back=None):
        action_type = ACTION_TYPE.value(action_data.action)

        # 当页面跳转是抓取最后一个打开的窗口页面
        self.__browser.windows.current = self.__browser.windows[-1]

        if action_type == "click":
            self.__mouse_of_click(self.__event_element(action_data.elType, action_data.elValue)[int(action_data.index)])
        elif action_type == "double click":
            self.__mouse_of_double_click(self.__event_element(action_data.elType, action_data.elValue)[int(action_data.index)])
        elif action_type == "right click":
            self.__mouse_of_right_click(self.__event_element(action_data.elType, action_data.elValue)[int(action_data.index)])
        elif action_type == "mouse over":
            self.__event_element(action_data.elType, action_data.elValue)[int(action_data.index)].mouse_over()
        elif action_type == "mouse out":
            self.__event_element(action_data.elType, action_data.elValue)[int(action_data.index)].mouse_out()
        elif action_type == "select":
            self.__event_element(action_data.elType, action_data.elValue)[int(action_data.index)].select()
        else:
            raise Exception("don't find action for action:%s", action_data.action)

        try:
            if action_data.testerResult is not None and result_back is not None:
                sleep(3)
                result_back(TesterResult(action_data.testerResult, self.__browser.is_text_present(action_data.testerResult)))
        except Exception:
            result_back(TesterResult(action_data.testerResult, False))


    def __mouse_of_click(self, event_deal_obj):
        if TestEngine.__mouse_over:
            event_deal_obj.mouse_over()
            sleep(TestEngine.__mouse_over_sleep)
            event_deal_obj.click()
        else:
            event_deal_obj.click()


    def __mouse_of_right_click(self, event_deal_obj):
        if TestEngine.__mouse_over:
            event_deal_obj.mouse_over()
            sleep(TestEngine.__mouse_over_sleep)
            event_deal_obj.right_click()
        else:
            event_deal_obj.click()


    def __mouse_of_double_click(self, event_deal_obj):
        if TestEngine.__mouse_over:
            event_deal_obj.mouse_over()
            sleep(TestEngine.__mouse_over_sleep)
            event_deal_obj.double_click()
        else:
            event_deal_obj.click()
Exemplo n.º 12
0
class TestOpenstackDashboard(tests.FunctionalTest):
    def setUp(self):
        self.browser = ""

    def tearDown(self):
        self.browser = ""

    def _logIn(self):
        self.browser.visit("http://%s" % self.config['dash']['host'])
        self.browser.fill('username', self.config['dash']['admin_user'])
        self.browser.fill('password', self.config['dash']['admin_pass'])
        button = self.browser.find_by_id('home_login_btn')
        button.click()

    def _logOut(self):
        drop_button = self.browser.find_by_id("drop_btn")
        drop_button.click()
        logout = self.browser.find_link_by_href("/auth/logout/")
        logout.click()

    def lookForError(self):
        self.assertFalse(self.browser.is_text_present("Error"))

    def validateOverview(self):
        self.assertTrue(self.browser.is_text_present("Cores"),
            "CPU Status is not showing properly")
        self.assertTrue(self.browser.is_text_present("RAM"),
            "RAM Status is not showing properly")
        self.assertTrue(self.browser.is_text_present("Disk"),
            "Disk Status is not showing properly")

#    @tests.skip_test("--Skipping--")
    def test_overview_page(self):
        self.browser = Browser()
        self._logIn()
        overview = self.browser.find_link_by_text("Overview")
        overview.click()
        self.lookForError()
        self.validateOverview()
        self._logOut()
        self.browser.quit()

    @tests.skip_test("--Skipping--")
    def test_instances_page(self):
        self.browser = Browser()
        self._logIn()
        instances = self.browser.find_link_by_text("Instances")
        instances.click()
        self.lookForError()
        self._logOut()
        self.browser.quit()

    def test_adding_a_keypair(self):
        self.browser = Browser()
        self._logIn()
        keypair = self.browser.find_link_by_text("Keypairs")
        keypair.click()
        self.lookForError()
        keypair_btn = self.browser.find_by_id("keypairs_create_link")
        keypair_btn.click()
        self.browser.fill('name', "test_keypair_test")
        # Create Keypair in d5
        button = self.browser.find_by_value('Add Keypair')
        button.click()
        return_link = self.browser.find_link_by_partial_text("Return to keypairs")
        return_link.click()
        self.assertTrue(self.browser.is_text_present("test_keypair_test"),
            "Created keypair not found")
        delete_link = self.browser.find_by_id("delete_test_keypair_test")
        delete_link.click()
        # accept the js alert
        alert = self.browser.get_alert()
        alert.accept()
        # verify delete message
        self.assertTrue(self.browser.is_text_present(
            "Successfully deleted keypair: test_keypair_test"),
            "Keypair not successfully deleted")
        self._logOut()
        self.browser.quit()
Exemplo n.º 13
0
from splinter.browser import Browser
 
b = Browser(driver_name="chrome")
 
b.visit("http://www.baidu.com")  ###注意不要去掉http://

b.fill("wd","splinter")

button = b.find_by_value(u"百度一下")

#button = b.find_by_id(u"su")

button.click()

#b.quit()