Skip to content

Commit ae8fe45

Browse files
committed
Start of Selenium WebDriver API support.
1 parent 7c4810d commit ae8fe45

4 files changed

Lines changed: 78 additions & 0 deletions

File tree

python/favicon.ico

1.12 KB
Binary file not shown.

python/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bottle>=0.10.11

python/server-start.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env sh
2+
python server.py

python/server.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
from applecart import Applecart
2+
from bottle import Bottle, request, response
3+
from bottle import run, static_file
4+
import json
5+
from time import time
6+
7+
app = Bottle()
8+
9+
@app.get('/favicon.ico')
10+
def get_favicon():
11+
return static_file('favicon.ico', root='.')
12+
13+
@app.route('/status', method='GET')
14+
def status():
15+
status = {'sessionId': None,
16+
'status': 0,
17+
'value': {'build': {'version': 'Applecart 1.0'}}}
18+
return status
19+
20+
@app.route('/session', method='POST')
21+
def create_session():
22+
#TODO: Get app name from desired caps and start with applecart here
23+
# app.ios_client = Applecart('/path/to/your/awesome.app')
24+
# app.ios_client.start()
25+
response = {'sessionId': '1',
26+
'status': 0,
27+
'value': None}
28+
return response
29+
30+
@app.route('/session/<session_id>', method='DELETE')
31+
def delete_session(session_id=''):
32+
app.ios_client.stop()
33+
response = {'sessionId': '1',
34+
'status': 0,
35+
'value': None}
36+
return response
37+
38+
@app.route('/session/<session_id>/frame', method='POST')
39+
def switch_to_frame(session_id=''):
40+
status = 0
41+
request_data = request.body.read()
42+
try:
43+
frame = json.loads(request_data).get('id')
44+
if frame is None:
45+
app.ios_client.proxy('wd_frame = mainWindow')
46+
else:
47+
app.ios_client.proxy('wd_frame = %s' % frame)
48+
except:
49+
response.status = 400
50+
status = 13 # UnknownError
51+
52+
response = {'sessionId': '1',
53+
'status': status,
54+
'value': {}}
55+
return response
56+
57+
@app.route('/session/<session_id>/element', method='POST')
58+
def find_element(session_id=''):
59+
status = 0
60+
request_data = request.body.read()
61+
try:
62+
locator_strategy = json.loads(request_data).get('using')
63+
element_id = json.loads(request_data).get('value')
64+
element_var_name = 'wde' + str(int(time() * 1000000))
65+
except:
66+
response.status = 400
67+
status = 13 # UnknownError
68+
response = {'sessionId': '1',
69+
'status': status,
70+
'value': {'message':'Unknown Error'}}
71+
return response
72+
73+
74+
#run(app, server='paste', host='0.0.0.0', port=8080, reloader=True)
75+
run(app, host='0.0.0.0', port=8080, reloader=True)

0 commit comments

Comments
 (0)