Skip to content

Commit

Permalink
Start of Selenium WebDriver API support.
Browse files Browse the repository at this point in the history
  • Loading branch information
hugs committed Sep 25, 2012
1 parent 7c4810d commit ae8fe45
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
Binary file added python/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions python/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bottle>=0.10.11
2 changes: 2 additions & 0 deletions python/server-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
python server.py
75 changes: 75 additions & 0 deletions python/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
from applecart import Applecart
from bottle import Bottle, request, response
from bottle import run, static_file
import json
from time import time

app = Bottle()

@app.get('/favicon.ico')
def get_favicon():
return static_file('favicon.ico', root='.')

@app.route('/status', method='GET')
def status():
status = {'sessionId': None,
'status': 0,
'value': {'build': {'version': 'Applecart 1.0'}}}
return status

@app.route('/session', method='POST')
def create_session():
#TODO: Get app name from desired caps and start with applecart here
# app.ios_client = Applecart('/path/to/your/awesome.app')
# app.ios_client.start()
response = {'sessionId': '1',
'status': 0,
'value': None}
return response

@app.route('/session/<session_id>', method='DELETE')
def delete_session(session_id=''):
app.ios_client.stop()
response = {'sessionId': '1',
'status': 0,
'value': None}
return response

@app.route('/session/<session_id>/frame', method='POST')
def switch_to_frame(session_id=''):
status = 0
request_data = request.body.read()
try:
frame = json.loads(request_data).get('id')
if frame is None:
app.ios_client.proxy('wd_frame = mainWindow')
else:
app.ios_client.proxy('wd_frame = %s' % frame)
except:
response.status = 400
status = 13 # UnknownError

response = {'sessionId': '1',
'status': status,
'value': {}}
return response

@app.route('/session/<session_id>/element', method='POST')
def find_element(session_id=''):
status = 0
request_data = request.body.read()
try:
locator_strategy = json.loads(request_data).get('using')
element_id = json.loads(request_data).get('value')
element_var_name = 'wde' + str(int(time() * 1000000))
except:
response.status = 400
status = 13 # UnknownError
response = {'sessionId': '1',
'status': status,
'value': {'message':'Unknown Error'}}
return response


#run(app, server='paste', host='0.0.0.0', port=8080, reloader=True)
run(app, host='0.0.0.0', port=8080, reloader=True)

0 comments on commit ae8fe45

Please sign in to comment.