zoukankan      html  css  js  c++  java
  • Functional testing

    Functional testing  - python selenium django - Source Code :

    from selenium import webdriver
    from selenium.webdriver.common.by import By

    from django.test import LiveServerTestCase

    class Browser():  #(Run more than one testcases on one browser)
      browser = None
      def __new__(cls):
        Browser.browser = Browser.browser or webdriver.Firefox()
        return Browser.browser

    class Base(LiveServerTestCase):
      def setUp(self):
        self.browser = Browser()
        self.browser.maximize_window()
        self.browser.implicitly_wait(10)
        self.flag_close_browser = None
        self.browser.get(self.live_server_url)

      def tearDown(self):
        if self.flag_close_browser == 1:
          self.browser.quit()

      def login(self, user_name, password):
        self.find_element(By.NAME, 'user_name').send_keys(user_name)
        self.find_element(By.NAME, 'pwd').send_keys(password)
        self.find_element(By.TAG_NAME, 'button').submit()
      

      def find_element(self, find_type, element):
        obj = self.browser.find_element(find_type, element)
        if obj.get_attribute('type') == 'text' and obj.is_displayed():
          obj.clear()
        return obj

      def find_elements(self, find_type, element):
        obj_list = self.browser.find_elements(find_type, element)
        for obj in obj_list:
          if obj.get_attribute('type') == 'text' and obj.is_displayed():
            obj.clear()
        return obj_list

      

  • 相关阅读:
    Codeforces Round #336 B
    Codeforces Round #336 A
    hiho一下157
    Codeforces Round #420 E
    Codeforces Round #420 C
    Codeforces Round #420 B
    Codeforces Round #420 A
    Codeforces Round #418 C
    Codeforces Round #418 B
    CodeForces 811D Vladik and Favorite Game bfs,模拟
  • 原文地址:https://www.cnblogs.com/Vena/p/5578343.html
Copyright © 2011-2022 走看看