• python selenium 使用unittest 示例


    python selenium 使用unittest 示例 并等待某个元素示例

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.webdriver.common.by import By
    from selenium import webdriver
    import unittest
    
    
    class TestBaidu(unittest.TestCase):
        def setUp(self):
            browser_engine = BrowerEngine(self)
            self.driver = browser_engine.get_browser()
            print(browser_engine)
            print(self.driver)
            print(browser_engine)
    
        def tearDown(self):
            self.driver.quit()
    
        def test_baidu(self):
            self.driver.get("http://www.baidu.com")
            element = WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable((By.ID, "kw")))
    
    
    class BrowerEngine:
        def __init__(self,driver):
            self.driver = driver
        brower_type = 'Chrome'
    
        def get_browser(self):
            if self.brower_type == 'Chrome':
                driver = webdriver.Chrome("D:/AutoConf/bin/chromedriver.exe")
            elif self.brower_type == 'Firefox':
                driver = webdriver.Firefox()
            elif self.brower_type == 'IE':
                driver = webdriver.Ie()
            else:
                driver = webdriver.Chrome
            return driver
    
    
    if __name__ == '__main__':
        unittest.main()
  • 相关阅读:
    uap
    打印机驱动下载
    hsf
    系统安装
    npm
    webuploader传递参数
    thinkphp5集成H-ui后台(五)集成webUploader
    webUploader上传视频,包括上传进度、上传状态、暂停和取消等
    webuploader php上传视频
    使用Webuploader大文件分片传输
  • 原文地址:https://www.cnblogs.com/testway/p/8330606.html
Copyright © 2020-2023  润新知