@@ -0,0 +1,2049 @@
+import os%0Aimport sys%0Aimport json%0Aimport time%0Afrom selenium import webdriver%0Afrom selenium.webdriver.chrome.options import Options%0A%0Aif os.path.dirname(sys.argv%5B0%5D) != '':%0A    os.chdir(os.path.dirname(sys.argv%5B0%5D))%0A%0A%0Adriver = None%0A%0A%0Adef start_up():%0A    global driver%0A    chrome_options = Options()%0A    chrome_options.add_argument('load-extension=../')%0A    print 'Opening a Chrome browser'%0A    driver = webdriver.Chrome(chrome_options=chrome_options)%0A    time.sleep(1)%0A%0A%0Adef clean_up():%0A    global driver%0A    time.sleep(1)%0A    if driver is not None:%0A        print 'Closing the Chrome browser'%0A        driver.quit()%0A        driver = None%0A%0A%0Adef run_tests():%0A    num_fails = 0%0A%0A    print 'Testing ipservice.163.com...',%0A    driver.get('http://ipservice.163.com/isFromMainland')%0A    flag = driver.find_elements_by_tag_name('pre').pop().text%0A    if flag != u'true':%0A        print 'Failed! Return value is not true'%0A        num_fails += 1%0A    else:%0A        print 'OK'%0A%0A    time.sleep(1)%0A    print 'Testing httpbin.org...',%0A    driver.get('http://httpbin.org/ip')%0A    ip_json = driver.find_elements_by_tag_name('pre').pop().text%0A    ip = json.loads(ip_json)%5B'origin'%5D%0A    time.sleep(1)%0A    driver.get('http://www.geoplugin.net/json.gp?ip=' + ip)%0A    geo_json = driver.find_elements_by_tag_name('pre').pop().text%0A    country_code = json.loads(geo_json)%5B'geoplugin_countryCode'%5D%0A    if country_code == 'CN':%0A        print 'Failed! Access to httpbin.org should not be through proxies'%0A        num_fails += 1%0A    elif country_code == '':%0A        print 'Unknown. Country code is unavailable'%0A    else:%0A        print 'OK'%0A%0A    return num_fails%0A%0A%0Adef main():%0A    try:%0A        start_up()%0A        num_failures = run_tests()%0A        if num_failures == 0:%0A            print 'All tests passed'%0A        else:%0A            print 'ATTENTION: %25d test(s) failed' %25 num_failures%0A        clean_up()%0A        return num_failures%0A    except Exception as err:%0A        print 'Got exception:', err%0A        clean_up()%0A        return -1%0A%0A%0Aif __name__ == '__main__':%0A    sys.exit(main())%0A

add two simple test cases using selenium