-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathClass6
206 lines (150 loc) · 6.22 KB
/
Class6
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
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<Class6>
<Intro>
<Review>
Programming in a Nutshell
</Review>
</Intro>
<CourseInfo>
Course information: All course info is posted to GitHub.
<web_resource>https://github.com/scott------/ACC_SFT_AUTO_SP18</web_resource>
The make up day for our cancelled class will be July 12th
</CourseInfo>
<ClassFlow>
Survey
Short Lecture
Lab
</ClassFlow>
<Survey>
How was the meetup? Who went?
Have you heard of the IBM Debater project?
<web_resource>https://www.research.ibm.com/artificial-intelligence/project-debater/faq.html</web_resource>
<web_resource>https://www.youtube.com/watch?v=UeF_N1r91RQ</web_resource>
What is the difference between Selenium and Selenium IDE?
</Survey>
<Lecture>
Potential solutions for flipping a coin problem
Functions
<web_resource>https://www.w3schools.com/python/python_functions.asp</web_resource>
Arguments/Parameters (by value / by reference)
def
Range function (start, stop, step)
##################################
for i in range(10):
print(i)
for n in range(3,10)
print(n)
For ducks in range(2,2,50)
print(ducks)
###################################
Casting
<web_resource>http://www.pitt.edu/~naraehan/python2/data_types_conversion.html</web_resource>
Review Classes, Methods, Properties
<web_resource>https://www.w3schools.com/python/python_classes.asp</web_resource>
Libraries/Modules
<web_resource>https://www.w3schools.com/python/python_modules.asp</web_resource>
#####################################################
#MontyHall Problem Code walk through
import random
games = 100000
doors = ["goat","goat", "car"]
change_wins = 0
change_loses = 0
while games > 0:
#change the order of the "doors" to increase randomness
random.shuffle(doors)
#randomly you pick a door (n)
your_pick = random.randrange(3)
#monty removes a goat
#monty picks a door, monty can not pick your door and doors[choice]!="car"
#generate a range of 3 numbers
sequence = range(3)
#shuffle those numbers
random.shuffle(sequence)
#use the numbrs to chose which door monty chooses aka montys_choice
for montys_choice in sequence:
#if monty matches your door or the car keep spinning aka continue
if montys_choice == your_pick or doors[montys_choice] == "car":
continue
# now if you change, you lose if doors[n]=="car"
if doors[your_pick] == "car":
change_loses += 1
else:
change_wins += 1
games = games - 1
print "Changing has %s wins and %s losses" % (change_wins, change_loses)
perc = (100.0 * change_wins) / (change_wins + change_loses)
print "Percentage winning if you change every time %.1f%% of the time" % perc
####################################################################
Software Tools - PyCharm, Selenium, Katalon Studio, Katalon Chrome Extension
<web_resource>https://chrome.google.com/webstore/detail/katalon-recorder-selenium/ljdobmomdgdljniojadhoplhkpialdid</web_resource>
Software Platforms - Database, Operating Systems, Containers/VMs, Cloud / App Fabrics
Walk through code:
######################################################################
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re
class LoginAndBook(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "http://demoaut.katalon.com/"
self.verificationErrors = []
self.accept_next_alert = True
def test_login_and_book(self):
driver = self.driver
driver.get("http://demoaut.katalon.com/")
driver.find_element_by_id("btn-make-appointment").click()
driver.find_element_by_id("txt-username").click()
driver.find_element_by_id("txt-username").clear()
driver.find_element_by_id("txt-username").send_keys("John Doe")
driver.find_element_by_id("txt-password").clear()
driver.find_element_by_id("txt-password").send_keys("ThisIsNotAPassword")
driver.find_element_by_id("btn-login").click()
driver.quit()
def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException as e: return False
return True
def is_alert_present(self):
try: self.driver.switch_to_alert()
except NoAlertPresentException as e: return False
return True
def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
alert_text = alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert_text
finally: self.accept_next_alert = True
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
#################################################################
</Lecture>
<Lab>
Launch IDLE, open a new file, copy the webdriver code we walked through during lecture, run it, and observe.
Install/Download/Setup Katalon
<web_resource>https://www.katalon.com/resources-center/tutorials/web/get-started/install-setup-katalon-studio/</web_resource>
Work through the sample web automation test project
<web_resource>https://www.katalon.com/resources-center/tutorials/sample-web-automation-test-project/</web_resource>
</Lab>
<Exercises>
Go through this tutorial on the Katalon page:
<web_resource>https://www.katalon.com/resources-center/tutorials/create-test-case-using-manual-mode/</web_resource>
Go through this tutorial and run all the test scripts. Try exporting them to python (click export and choose python) and see if you can walk through/edit the code:
<web_resource>https://docs.katalon.com/pages/viewpage.action?pageId=13697321</web_resource>
Optional:
Walk through the data driven testing tutorial (we will cover this next week)
<web_resource>https://www.katalon.com/resources-center/tutorials/data-driven-testing/</web_resource>
</Exercises>
</Class6>