-
Notifications
You must be signed in to change notification settings - Fork 1
/
web_test.py
69 lines (61 loc) · 2.45 KB
/
web_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from selenium import webdriver
from pandas import *
import csv
import time
import sys
import getopt
# load test data
inputfile = str(sys.argv[1])
with open(inputfile, 'rb') as f:
#with open('web_test_cat.csv', 'rb') as f:
#with open('web_test_src.csv', 'rb') as f:
#with open('web_test_funnel.csv', 'rb') as f:
#with open('web_test_camp.csv', 'rb') as f:
reader = csv.reader(f)
testbot_raw = list(reader)
testbot = sorted(testbot_raw, key=lambda testbot_raw: testbot_raw[2])
df = DataFrame(testbot, columns = testbot[len(testbot)-1])
# set test sample ec url
preurl = "http://locallhost.com/"
url = "http://localhost/"
#url = "file:///Users/summitsuen/Documents/erjsTesting/index.html"
#url = "https://suensummit.github.io/erjsTesting/"
#
driver = {}
k = 0
ssid = df.ssid.unique()
while k < len(ssid)-1:
key = ssid[k]
value = webdriver.PhantomJS()
#value = webdriver.Firefox()
driver[key] = value
k += 1
# send actions from testbot
for k in range(len(df)-2):
driver[df.ssid[k]].get(preurl)
driver[df.ssid[k]].find_element_by_link_text('http://localhost/').click()
driver[df.ssid[k]].find_element_by_id('agroup').send_keys("ER")
driver[df.ssid[k]].find_element_by_id('acid').send_keys("webtesting")
driver[df.ssid[k]].find_element_by_id('auid').send_keys(df.uid[k])
if df.lo[k] == '0':
driver[df.ssid[k]].find_element_by_id('auid').send_keys("")
pass
driver[df.ssid[k]].find_element_by_id('aact').send_keys(df.act[k])
driver[df.ssid[k]].find_element_by_id('acat').send_keys(df.cat[k])
driver[df.ssid[k]].find_element_by_id('apid').send_keys(df.pid[k])
driver[df.ssid[k]].find_element_by_id('apcat').send_keys(df.pcat[k])
driver[df.ssid[k]].find_element_by_id('apaypid').send_keys(df.paypid[k])
driver[df.ssid[k]].find_element_by_id('aunit_price').send_keys(df.unit_price[k])
#driver[df.ssid[k]].find_element_by_id('apmk').send_keys(df.pmk[k])
driver[df.ssid[k]].find_element_by_id('aqty').send_keys(df.qty[k])
driver[df.ssid[k]].find_element_by_id('aeturec').send_keys(df.eturec[k])
driver[df.ssid[k]].find_element_by_id('aoid').send_keys(df.oid[k])
driver[df.ssid[k]].find_element_by_id('aercamp').send_keys(df.ERCAMP[k])
driver[df.ssid[k]].find_element_by_id('aerad').send_keys(df.ERAD[k])
#print 'It is the ' + str(k+1) + 'th testbot\n'
#time.sleep(1)
driver[df.ssid[k]].find_element_by_id('custom-click').click()
# Take screenshot for verify
#driver[df.ssid[k]].save_screenshot('screenshot_' + str(k+1) + '.png')
for k in range(len(ssid)-1):
driver[ssid[k]].quit()