Skip to content

Commit 4a422d1

Browse files
authored
Add files via upload
1 parent 5761b55 commit 4a422d1

18 files changed

+2202
-0
lines changed

CCO_Locust.py

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
from selenium import webdriver as wd
2+
from selenium.webdriver.support.wait import WebDriverWait
3+
from selenium.webdriver.support import expected_conditions as EC
4+
from selenium.webdriver.common.by import By
5+
from lxml import html
6+
import requests as rq
7+
# import grequests
8+
from locust import HttpLocust, TaskSet, task, seq_task
9+
import locust.clients as lc
10+
from locust.clients import HttpSession
11+
import random, time
12+
13+
'''
14+
def request ( driver ):
15+
s = rq.session()
16+
cookies = driver.get_cookies ()
17+
for cookie in cookies:
18+
# s.cookies.set (cookie['name'] , cookie['value'])
19+
return s
20+
'''
21+
user = [#"[email protected]",
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+
69+
70+
71+
72+
73+
class MyTaskSet(TaskSet):
74+
def order(self):
75+
#name = user[random.randint(39)]
76+
self.driver = wd.Chrome("C:\\Users\\patelvi\\PycharmProjects\\NCE\\Common\\Drivers\\chromedriver.exe")
77+
#driver = wd.PhantomJS ("C:\\Users\\patelvi\\PycharmProjects\\NCE\\Common\\Drivers\\phantomjs.exe")
78+
self.driver.implicitly_wait(30)
79+
self.driver.get("https://cco-fit-uat.lifelabs.com")
80+
time.sleep(1)
81+
self.driver.maximize_window()
82+
83+
self.driver.find_elements_by_name("loginfmt")[0].send_keys('[email protected]')#(name) # "[email protected]")
84+
self.driver.find_elements_by_id("idSIButton9")[0].click()
85+
time.sleep(1)
86+
self.driver.find_elements_by_name("passwd")[0].send_keys("Shlok1998")
87+
# print(driver.get_cookies())
88+
time.sleep(2)
89+
self.driver.find_elements_by_id("idSIButton9")[0].click()
90+
time.sleep(2)
91+
self.driver.find_elements_by_id("idSIButton9")[0].click()
92+
93+
@task
94+
def search_ord(self):
95+
url="https://cco-fit-uat.lifelabs.com/Search/GetSearchOrderList?sort=&page=1&pageSize=10&group=&filter=&SearchText=1015423476&searchType=2"
96+
a =self.client.post(url)
97+
print(a.text)
98+
99+
100+
class MyLocust(HttpLocust):
101+
task_set = MyTaskSet
102+
min_wait = 3000
103+
max_wait = 5000
104+
host = "http://localhost:8089"
105+
106+
# locust -f C:\Users\patelvi\PycharmProjects\NCE\CCO_Locust.py

CCO_Thread.py

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
from selenium import webdriver as wd
2+
from selenium.webdriver.support import expected_conditions as EC
3+
from selenium.common.exceptions import TimeoutException
4+
from selenium.webdriver.support.ui import WebDriverWait
5+
from selenium.webdriver.common.by import By
6+
7+
import time, random
8+
from selenium.webdriver.common.keys import Keys
9+
from selenium.webdriver.common.action_chains import ActionChains
10+
import threading
11+
from multiprocessing import Process
12+
import gevent
13+
14+
15+
def order(name):
16+
driver = wd.Chrome("C:\\Users\\patelvi\\PycharmProjects\\NCE\\Common\\Drivers\\chromedriver.exe")
17+
driver.implicitly_wait(3)
18+
threadLock.acquire()
19+
driver.get("https://cco-fit-uat.lifelabs.com")
20+
time.sleep(1)
21+
driver.find_elements_by_name("loginfmt")[0].send_keys(name)
22+
driver.find_elements_by_id("idSIButton9")[0].click()
23+
time.sleep(1)
24+
driver.find_elements_by_name("passwd")[0].send_keys("Shlok1998")
25+
# print(driver.get_cookies())
26+
driver.find_elements_by_id("idSIButton9")[0].click()
27+
time.sleep(1)
28+
driver.find_elements_by_id("idSIButton9")[0].click()
29+
s1 = time.perf_counter()
30+
# time.sleep(1)
31+
#print(time.ctime())
32+
driver.find_element_by_xpath("//*[@title='Order Queue']").click()
33+
print(time.ctime())
34+
35+
order = driver.find_element_by_css_selector("div#requisition-grid tr:nth-child(1) > td:nth-child(3)").text
36+
print(order)
37+
s2 = time.perf_counter()
38+
print(round((s2 - s1), 3))
39+
threadLock.release()
40+
41+
# driver.find_element_by_id("btnCancel").click()
42+
43+
44+
threads = []
45+
46+
47+
48+
49+
50+
51+
52+
53+
54+
55+
56+
threadLock = threading.Lock()
57+
for i in range(50):
58+
usr =user[random.randint(1,9)]
59+
t = threading.Thread(target=order(usr))
60+
t.start()
61+
threads.append(t)
62+
#t.start()
63+
64+
65+
"""
66+
procs =[]
67+
if __name__ == '__main__':
68+
for i in range(50):
69+
usr =user[random.randint(1,9)]
70+
proc = Process(target=order(usr))
71+
proc.start()
72+
proc.join()
73+
"""
74+
"""
75+
greenlets = [ gevent.spawn(order(user[i])) for i in range(5) ]
76+
gevent.joinall(greenlets)
77+
"""
78+
"""
79+
80+
81+
82+
if __name__ == "__main__":
83+
asyncio.run(main())
84+
time.sleep(1000)
85+
"""
86+
87+

Next_req_CCO.py

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
2+
from selenium import webdriver as wd
3+
from selenium.webdriver.support import expected_conditions as EC
4+
from selenium.webdriver.support.wait import WebDriverWait
5+
from selenium.webdriver.common.by import By
6+
from selenium.webdriver.common.keys import Keys
7+
from selenium.webdriver import ChromeOptions
8+
9+
#from seleniumrequests import Chrome
10+
import time , random
11+
import asyncio
12+
#from bs4 import BeautifulSoup
13+
pro = ['10.144.56.84:1234','10.144.56.36:1234','10.144.56.47:1234']
14+
15+
async def next_req(name):
16+
options = ChromeOptions()
17+
options.add_argument('--proxy-server='+random.choice(pro))
18+
#driver = wd.PhantomJS("C:\\Users\\patelvi\\PycharmProjects\\NCE\\Common\\Drivers\\phantomjs.exe")
19+
driver = wd.Chrome("C:\\Users\\patelvi\\PycharmProjects\\NCE\\Common\\Drivers\\chromedriver.exe",options=options)
20+
#driver =Chrome("C:\\Users\\patelvi\\PycharmProjects\\NCE\\Common\\Drivers\\chromedriver.exe")
21+
driver.implicitly_wait (3)
22+
23+
driver.get("https://cco-fit-uat.lifelabs.com")
24+
time.sleep(1)
25+
driver.maximize_window()
26+
27+
driver.find_elements_by_name("loginfmt")[0].send_keys(name)#"[email protected]")
28+
driver.find_elements_by_id("idSIButton9")[0].click()
29+
time.sleep(3)
30+
driver.find_elements_by_name("passwd")[0].send_keys("Shlok1998")
31+
#print(driver.get_cookies())
32+
time.sleep (3)
33+
driver.find_elements_by_id("idSIButton9")[0].click()
34+
time.sleep(3)
35+
driver.find_elements_by_id("idSIButton9")[0].click()
36+
time.sleep(3)
37+
driver.find_element_by_tag_name('body').send_keys(Keys.COMMAND + 't')
38+
driver.get("https://cco-fit-uat.lifelabs.com/name.html")
39+
print(driver.find_element_by_xpath("/html/body/h1").text)
40+
driver.find_element_by_tag_name('body').send_keys(Keys.COMMAND + 'w')
41+
42+
43+
await asyncio.sleep(1)
44+
driver.find_element_by_id("btnNextRequisition").click()
45+
time.sleep(2)
46+
#driver.get('https://cco-fit-uat.lifelabs.com/Order/EditRequisition')
47+
#res =driver.request('GET','https://cco-fit-uat.lifelabs.com/Order/EditRequisition')
48+
#a = BeautifulSoup(res.text)
49+
#order=a.find('b',id='order-form')
50+
driver._switch_to.window(driver.window_handles[1])
51+
driver.close()
52+
driver._switch_to.window(driver.window_handles[0])
53+
54+
order = driver.find_element_by_xpath(("//*[@id='order-form']/div[1]/table/tbody/tr/td/b")).text
55+
#print(order)
56+
#order = driver.find_element_by_xpath(("//*[@id='order-form']/div[1]/table/tbody/tr/td/b")).text
57+
print(name + "|" + order +"|" + time.asctime())
58+
59+
#driver.find_element_by_id("btnCancel").click()
60+
61+
62+
users = ['[email protected]',
63+
64+
65+
66+
67+
68+
69+
70+
71+
72+
73+
74+
75+
76+
77+
78+
79+
80+
81+
82+
83+
84+
85+
86+
87+
88+
89+
90+
91+
92+
93+
94+
95+
96+
97+
98+
99+
100+
101+
102+
103+
104+
105+
106+
107+
108+
109+
110+
111+
112+
]
113+
114+
ord=[]
115+
for i in range(48):
116+
usr = users[i]
117+
ord.append(next_req(usr))
118+
119+
120+
async def main():
121+
await asyncio.gather(*ord)
122+
#await asyncio.gather(*problem_ords)
123+
#await asyncio.gather(*search_ords)
124+
125+
if __name__ == "__main__":
126+
asyncio.run(main())
127+
#time.sleep(1000)

SMS_web.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from gevent import monkey
2+
monkey.patch_all()
3+
import gevent
4+
from selenium import webdriver as wd
5+
from selenium.webdriver.support import expected_conditions as EC
6+
from selenium.common.exceptions import TimeoutException
7+
from selenium.webdriver.support.ui import WebDriverWait
8+
from selenium.webdriver.chrome.options import Options
9+
from lxml import html
10+
import requests
11+
import time
12+
import random
13+
14+
15+
def login ():
16+
chrome_options = Options()
17+
#chrome_options.add_argument("--headless")
18+
driver = wd.Chrome ('C:\\Users\\patelvi\\PycharmProjects\\NCE\\Common\\Drivers\\chromedriver.exe',options=chrome_options)
19+
20+
#driver = wd.PhantomJS ("C:\\Users\\patelvi.DIAGLABS\\PycharmProjects\\NCE\\Common\\Drivers\\phantomjs.exe")
21+
s1 = time.perf_counter ()
22+
driver.get ("https://192.168.152.24/static/lifelabs/dev.html")
23+
time.sleep(3)
24+
driver.find_element_by_css_selector ("div#mapWindow input").clear()
25+
driver.find_element_by_css_selector("div#mapWindow input").send_keys("Peterborough,ON")
26+
driver.find_element_by_css_selector('div#mapWindow td:nth-child(4) > button[type="button"]').click()
27+
time.sleep(2)
28+
29+
driver.find_element_by_partial_link_text("Alexander Crt").click()
30+
time.sleep (2)
31+
driver.find_element_by_xpath("//input[@placeholder='First name']").send_keys("SMS"+str(random.randint(1,100)))
32+
driver.find_element_by_xpath ("//input[@placeholder='Last name']").send_keys ("SMS"+str(random.randint(1,100)))
33+
driver.find_element_by_xpath ("//input[@placeholder='(###) ###-####']").send_keys (random.randint(4164160000,4164169999))
34+
driver.find_element_by_css_selector('td > button[type="submit"]').click()
35+
time.sleep (2)
36+
driver.find_element_by_css_selector('div.icsButtonBar > table > tbody > tr > td > button[type="button"]').click()
37+
driver.quit()
38+
s2 = time.perf_counter()
39+
print(round((s2-s1),3))
40+
41+
#login()
42+
greenlets = [ gevent.spawn(login) for i in range(3) ]
43+
gevent.joinall(greenlets)

0 commit comments

Comments
 (0)