This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import httplib, json, urllib | |
# get | |
conn = httplib.HTTPConnection('localhost', 5000) | |
conn.request('GET', '/') | |
r1 = conn.getresponse() | |
print r1.status, r1.reason | |
data = r1.read() | |
print json.loads(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, jsonify, g, request | |
from sqlite3 import dbapi2 as sqlite3 | |
DATABASE = './db/test.db' | |
app = Flask(__name__) | |
def get_db(): | |
db = getattr(g, '_database', None) | |
if db is None: | |
db = g._database = sqlite3.connect(DATABASE) | |
db.row_factory = sqlite3.Row |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
def login(browser, user_name, password) | |
login_url = 'http://localhost/wordpress/wp-login.php' | |
browser.goto login_url | |
browser.text_field(:id, 'user_login').set user_name | |
browser.text_field(:id, 'user_pass').set password | |
browser.button(:id, 'wp-submit').click | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
require 'watir-webdriver' | |
require './spec/public_function' | |
describe 'Delete Post' do | |
before :all do | |
puts 'start browser' | |
@b = Watir::Browser.new :chrome | |
@password = @user_name = 'admin' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
require 'watir-webdriver' | |
describe 'Create Post' do | |
before :all do | |
puts 'start browser' | |
@b = Watir::Browser.new :chrome | |
# 如何在watir里面使用原生的webdriver | |
#@b.wd == Selenium::WebDriver.for(:chrome) | |
@password = @user_name = 'admin' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
require 'watir-webdriver' | |
describe 'Create Post' do | |
before :all do | |
puts 'start browser' | |
@b = Watir::Browser.new :chrome | |
@password = @user_name = 'admin' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
class Employee | |
WORK_DAY_OF_MONTH = 20 | |
DOUBLE = 2 | |
attr_reader :name, :pay_per_day | |
def initialize name, pay_per_day | |
@name = name | |
@pay_per_day = pay_per_day | |
@pay_off = @over_time = 0 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
class Phone | |
attr_reader :type, :has_keyboard | |
def initialize(type, has_keyboard) | |
# 型号 | |
@type = type | |
# 键盘 | |
@has_keyboard = has_keyboard | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'optparse' | |
require 'watir-webdriver' | |
ENV.delete('HTTP_PROXY') | |
module Inter | |
def self.parse | |
opts = {} | |
opts[:from] = 'qq' | |
opts[:browser] = 'chrome' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: utf-8 | |
# print all the inter news with waitr-webdriver | |
require 'watir-webdriver' | |
url = 'http://sports.qq.com/seriea/' | |
b = Watir::Browser.new :chrome | |
b.goto url | |
b.div(:id, 'inter').div(:class, 'hot_list').links.each do |link| |