comp_analysis.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:atsy 作者: EricRahm 项目源码 文件源码
def test_browser(browser, stats, binary, urls,
                 per_tab_pause, settle_wait_time,
                 proxy, process_count):

    test_options = {
        'per_tab_pause': per_tab_pause,
        'settle_wait_time': settle_wait_time
    }

    if browser == 'Chrome':
        options = webdriver.chrome.options.Options()
        options.binary_location = binary
        caps = options.to_capabilities()

        if proxy:
            webdriver_proxy = webdriver.Proxy()
            webdriver_proxy.http_proxy = proxy
            webdriver_proxy.add_to_capabilities(caps)

        driver = webdriver.Chrome(desired_capabilities=caps)

        test = MultiTabTest(driver, stats, **test_options)
        test.open_urls(urls)

        driver.quit()
    elif browser == 'Firefox':
        for count in process_count:
            print "FIREFOX WITH %d CONTENT PROCESSES" % count
            test = FirefoxMultiTabTest(binary, stats, proxy=proxy, process_count=count, **test_options)
            test.open_urls(urls)
    elif browser in ('Safari', 'IE'):
        # Currently this is a manual test, sorry.
        manual_test = os.path.abspath(os.path.join(
            os.path.dirname(__file__), 'comp_analysis_manual_test.htm'))
        test = ManualMultiTabTest(binary, stats, **test_options)
        prefix = 'file://' if browser == 'IE' else ''
        test.open_urls([prefix + manual_test])
    elif browser == 'Edge':
        # Currently this is even more manual than IE and Safari. Edge won't
        # let us provide a path to launch.
        print "Open up explorer, find 'atsy/example/comp_analysis_manual_test.htm'"
        print "Right-click, 'Open with' -> 'Microsoft Edge'"
        print "Run the test, press enter when it's done."
        import sys
        sys.stdin.read(1)
        stats.print_stats()
    else:
        raise Exception("Unhandled browser: %s" % browser)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号