• 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

      

  • 相关阅读:
    【hacker101 CTF】Photo Gallery
    Linux内网渗透(一)——容器逃逸
    JWT原理及常见攻击方式
    【红日安全VulnStack】ATT&CK实战系列——红队实战(二)
    内网穿透的常用方法总结
    文件上传利用总结
    Windows&Linux文件传输方式总结
    通过WebGoat学习java反序列化漏洞
    绕过WAF进行常见Web漏洞利用
    wifi钓鱼
  • 原文地址:https://www.cnblogs.com/Vena/p/5578343.html
Copyright © 2020-2023  润新知