def oneTimeSetUp(request, browser):

    print("This will run once before every test")
    wdf = WebDriverFactory(browser)
    driver = wdf.getBrowserInstance()
    # if browser=='firefox':
    #     url = "https://learn.letskodeit.com/p/practice/"
    #     driver = webdriver.Firefox()
    #     driver.get(url)
    #     driver.maximize_window()
    #
    # elif browser=='chrome':
    #     driver_location = 'D:\seleniumpythonsoftware\chromedriver.exe'
    #     os.environ['webdriver.chrome.driver'] = driver_location
    #     url = "https://learn.letskodeit.com/p/practice/"
    #     driver = webdriver.Chrome(driver_location)
    #     driver.get(url)
    #     driver.maximize_window()

    if request.cls is not None:
        request.cls.driver = driver

    yield driver
    driver.quit()
    print("This will run Once after every test")
def oneTimeSetUp(request, browser):
    wdf = WebDriverFactory(browser)
    driver = wdf.getBrowserInstance('https://www.baidu.com')
    if request.cls is not None:
        request.cls.driver = driver

    yield
    driver.quit()
def oneTimeSetUp(request, browser):
    print("Running one time setUp")
    wdf = WebDriverFactory(browser)
    driver = wdf.getBrowserInstance()

    if request.cls is not None:
        request.cls.driver = driver
    yield driver
    driver.quit()
    print("Running one time tearDown")
        self.actionOnElement()
        self.searchSetting()
        self.getSleep(1)
        self.saveSetting()

    def veryfyAlertTextMatchAndAccept(self, expected):
        alert = self.getAlert()
        if alert:
            actualAlertText = alert.text
            result = self.util.isTextMatch(actualAlertText, expected)
            if result:
                alert.accept()
                msg = '点选弹窗“确认”选项'
                print(msg)
            return result
        return alert


if __name__ == '__main__':
    try:
        from base.webdriverfactory import WebDriverFactory
        wdf = WebDriverFactory('chrome')
        driver = wdf.getBrowserInstance('https://www.baidu.com')
        bs = BaiduSetting(driver)
        bs.performBaiduSetting()
        result = bs.veryfyAlertTextMatchAndAccept('已经记录下您的使用偏好')
        msg = ('实际弹窗信息与提供的弹窗信息是否相符:{}'.format(result))
        print(msg)
    finally:
        bs.getClose()